moduleHint.Configuration(setGhcOption,setGhcOptions,defaultConf,fromConf,onConf,get,set,Option,OptionVal(..),languageExtensions,availableExtensions,glasgowExtensions,Extension(..),installedModulesInScope,setUseLanguageExtensions,setInstalledModsAreInScopeQualified,searchPath)whereimportControl.Monad.ErrorimportData.CharimportData.List(intersect,intercalate)importqualifiedHint.GHCasGHCimportqualifiedHint.CompatasCompatimportHint.BaseimportHint.Util(partition)importHint.ExtensionsetGhcOptions::MonadInterpreterm=>[String]->m()setGhcOptionsopts=doold_flags<-runGhcGHC.getSessionDynFlags(new_flags,not_parsed)<-runGhc2Compat.parseDynamicFlagsold_flagsoptswhen(not.null$not_parsed)$throwError$UnknownError(concat["flag: '",unwordsopts,"' not recognized"])runGhc1GHC.setSessionDynFlagsnew_flagsreturn()setGhcOption::MonadInterpreterm=>String->m()setGhcOptionopt=setGhcOptions[opt]defaultConf::InterpreterConfigurationdefaultConf=Conf{language_exts=[],all_mods_in_scope=False,search_path=["."]}-- | Available options are:---- * 'languageExtensions'---- * 'installedModulesInScope'dataOptionma=Option{_set::MonadInterpreterm=>a->m(),_get::MonadInterpreterm=>ma}dataOptionValm=foralla.(Optionma):=a-- | Use this function to set or modify the value of any option. It is-- invoked like this:---- @set [opt1 := val1, opt2 := val2,... optk := valk]@set::MonadInterpreterm=>[OptionValm]->m()set=mapM_$\(opt:=val)->_setoptval-- | Retrieves the value of an option.get::MonadInterpreterm=>Optionma->maget=_get-- | Language extensions in use by the interpreter.---- Default is: @[]@ (i.e. none, pure Haskell 98)languageExtensions::MonadInterpreterm=>Optionm[Extension]languageExtensions=Optionsettergetterwheresetteres=dosetGhcOptions$map(mkFlagFalse)availableExtensionssetGhcOptions$map(mkFlagTrue)esonConf$\c->c{language_exts=es}--getter=fromConflanguage_exts--mkFlagb(UnknownExtensiono)="-X"++concat["No"|notb]++omkFlagbo|('N':'o':c:_)<-showo,isUpperc=ifbthen"-X"++showoelse"-X"++(drop2$showo)|otherwise="-X"++concat["No"|notb]++showo-- | List of the extensions known by the interpreter.availableExtensions::[Extension]availableExtensions=asExtensionListGHC.supportedLanguagesasExtensionList::[String]->[Extension]asExtensionListexts=mapreadknownPos++mapread(map("No"++)knownNegs)++mapUnknownExtensionunknownwhere(knownPos,unknownPos)=partitionisKnownexts(knownNegs,unknown)=partition(isKnown.("No"++))unknownPosisKnowne=e`elem`mapshowknownExtensions-- | List of extensions turned on when the @-fglasgow-exts@ flag is usedglasgowExtensions::[Extension]glasgowExtensions=intersectavailableExtensionsexts610-- works also for 608whereexts610=asExtensionList["ForeignFunctionInterface","UnliftedFFITypes","GADTs","ImplicitParams","ScopedTypeVariables","UnboxedTuples","TypeSynonymInstances","StandaloneDeriving","DeriveDataTypeable","FlexibleContexts","FlexibleInstances","ConstrainedClassMethods","MultiParamTypeClasses","FunctionalDependencies","MagicHash","PolymorphicComponents","ExistentialQuantification","UnicodeSyntax","PostfixOperators","PatternGuards","LiberalTypeSynonyms","RankNTypes","ImpredicativeTypes","TypeOperators","RecursiveDo","ParallelListComp","EmptyDataDecls","KindSignatures","GeneralizedNewtypeDeriving","TypeFamilies"]-- | When set to @True@, every module in every available package is implicitly-- imported qualified. This is very convenient for interactive-- evaluation, but can be a problem in sandboxed environments-- (e.g. 'System.Unsafe.unsafePerformIO' is in scope).---- Default value is @True@.---- Observe that due to limitations in the GHC-API, when set to @False@, the-- private symbols in interpreted modules will not be in scope.installedModulesInScope::MonadInterpreterm=>OptionmBoolinstalledModulesInScope=Optionsettergetterwheregetter=fromConfall_mods_in_scopesetterb=doonConf$\c->c{all_mods_in_scope=b}when(ghcVersion>=610)$setGhcOption$"-f"++concat["no-"|notb]++"implicit-import-qualified"-- | The search path for source files. Observe that every time it is set,-- it overrides the previous search path. The default is @[\".\"]@.---- Keep in mind that by a limitation in ghc, @\".\"@ is always in scope.searchPath::MonadInterpreterm=>Optionm[FilePath]searchPath=Optionsettergetterwheregetter=fromConfsearch_pathsetterp=doonConf$\c->c{search_path=p}setGhcOption$"-i"-- clear the old pathsetGhcOption$"-i"++intercalate":"pfromConf::MonadInterpreterm=>(InterpreterConfiguration->a)->mafromConff=fromState(f.configuration)onConf::MonadInterpreterm=>(InterpreterConfiguration->InterpreterConfiguration)->m()onConff=onState$\st->st{configuration=f(configurationst)}{-# DEPRECATED setUseLanguageExtensions "Use set [languageExtensions := (ExtendedDefaultRules:glasgowExtensions)] instead." #-}setUseLanguageExtensions::MonadInterpreterm=>Bool->m()setUseLanguageExtensionsFalse=set[languageExtensions:=[]]setUseLanguageExtensionsTrue=set[languageExtensions:=exts]whereexts=ExtendedDefaultRules:glasgowExtensions{-# DEPRECATED setInstalledModsAreInScopeQualified "Use set [installedModulesInScope := b] instead." #-}setInstalledModsAreInScopeQualified::MonadInterpreterm=>Bool->m()setInstalledModsAreInScopeQualifiedb=set[installedModulesInScope:=b]