| Copyright | (c) 2013-2016 Galois Inc. |
|---|---|
| License | BSD3 |
| Maintainer | cryptol@galois.com |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Cryptol.ModuleSystem.Env
Description
Synopsis
- data ModuleEnv = ModuleEnv {}
- data CoreLint
- data EvalForeignPolicy
- defaultEvalForeignPolicy :: EvalForeignPolicy
- resetModuleEnv :: ModuleEnv -> IO ModuleEnv
- initialModuleEnv :: IO ModuleEnv
- focusModule :: ImpName Name -> ModuleEnv -> Maybe ModuleEnv
- loadedModules :: ModuleEnv -> [Module]
- loadedNonParamModules :: ModuleEnv -> [Module]
- loadedNominalTypes :: ModuleEnv -> Map Name NominalType
- hasParamModules :: ModuleEnv -> Bool
- allDeclGroups :: ModuleEnv -> [DeclGroup]
- data ModContextParams
- modContextParamNames :: ModContextParams -> ModParamNames
- data ModContext = ModContext {}
- findEnv :: Name -> Iface -> ModuleG a -> Maybe (NamingEnv, Set Name)
- modContextOf :: ImpName Name -> ModuleEnv -> Maybe ModContext
- mainContexts :: ModuleEnv -> [ModContext]
- lmModContext :: ModuleEnv -> LoadedModule -> ModContext
- lmSignatureContext :: ModuleEnv -> LoadedSignature -> ModContext
- dynModContext :: ModuleEnv -> ModContext
- focusedEnv :: ModuleEnv -> ModContext
- focusedEnv' :: Maybe (ImpName Name) -> ModuleEnv -> ModContext
- data ModulePath
- modulePathLabel :: ModulePath -> String
- data LoadedModules = LoadedModules {}
- data LoadedEntity
- getLoadedEntities :: LoadedModules -> Map ModName LoadedEntity
- withLoadedEntity :: LoadedEntity -> (forall a. LoadedModuleG a -> b) -> b
- getLoadedModules :: LoadedModules -> [LoadedModule]
- getLoadedField :: Ord a => (forall b. LoadedModuleG b -> a) -> LoadedModules -> Set a
- getLoadedFieldMap :: Ord k => (forall b. LoadedModuleG b -> (k, v)) -> LoadedModules -> Map k v
- getLoadedNames :: LoadedModules -> Set ModName
- getLoadedIds :: LoadedModules -> Set String
- getLoadedFiles :: LoadedModules -> Map ModulePath FileInfo
- data LoadedModuleG a = LoadedModule {
- lmName :: ModName
- lmFilePath :: ModulePath
- lmModuleId :: String
- lmNamingEnv :: !NamingEnv
- lmFileInfo :: !FileInfo
- lmRenamedModule :: Maybe (Module Name)
- lmData :: a
- type LoadedModule = LoadedModuleG LoadedModuleData
- lmModule :: LoadedModule -> Module
- lmInterface :: LoadedModule -> Iface
- data LoadedModuleData = LoadedModuleData {}
- type LoadedSignature = LoadedModuleG ModParamNames
- isLoaded :: ImpName Name -> LoadedModules -> Bool
- isLoadedStrict :: ImpName Name -> String -> LoadedModules -> Bool
- isLoadedParamMod :: ImpName Name -> LoadedModules -> Bool
- isLoadedInterface :: ImpName Name -> LoadedModules -> Bool
- loadedParamModDeps :: FreeVars a => LoadedModules -> a -> (Set TParam, Set Name)
- lookupTCEntity :: ModName -> ModuleEnv -> Maybe (LoadedModuleG TCTopEntity)
- lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule
- lookupMainModules :: ModuleEnv -> [LoadedModule]
- lookupModuleWith :: (LoadedModule -> Bool) -> ModuleEnv -> Maybe LoadedModule
- lookupSignature :: ModName -> ModuleEnv -> Maybe LoadedSignature
- lookupSignatureWith :: (LoadedSignature -> Bool) -> ModuleEnv -> Maybe LoadedSignature
- addLoadedSignature :: ModulePath -> String -> FileInfo -> NamingEnv -> ModName -> Maybe (Module Name) -> ModParamNames -> LoadedModules -> LoadedModules
- addLoadedModule :: ModulePath -> String -> FileInfo -> NamingEnv -> Maybe ForeignSrc -> Maybe (Module Name) -> Module -> LoadedModules -> LoadedModules
- removeLoadedModule :: (forall a. LoadedModuleG a -> Bool) -> LoadedModules -> LoadedModules
- data FileInfo = FileInfo {}
- fileInfo :: Fingerprint -> Map FilePath Fingerprint -> Set ModName -> Maybe ForeignSrc -> FileInfo
- data DynamicEnv = DEnv {}
- deIfaceDecls :: DynamicEnv -> IfaceDecls
Documentation
This is the current state of the interpreter.
Constructors
| ModuleEnv | |
Fields
| |
Instances
Should we run the linter?
Constructors
| NoCoreLint | Don't run core lint |
| CoreLint | Run core lint |
data EvalForeignPolicy Source #
How to evaluate foreign bindings.
Constructors
| AlwaysEvalForeign | Use foreign implementation and report an error at module load time if it is unavailable. |
| PreferEvalForeign | Use foreign implementation by default, and when unavailable, fall back to cryptol implementation if present and report runtime error otherwise. |
| NeverEvalForeign | Always use cryptol implementation if present, and report runtime error otherwise. |
Instances
| Eq EvalForeignPolicy Source # | |
Defined in Cryptol.ModuleSystem.Env Methods (==) :: EvalForeignPolicy -> EvalForeignPolicy -> Bool # (/=) :: EvalForeignPolicy -> EvalForeignPolicy -> Bool # | |
focusModule :: ImpName Name -> ModuleEnv -> Maybe ModuleEnv Source #
Try to focus a loaded module in the module environment. FIXME: This function is dead code. (And confusingly, there is another function of same name.)
loadedModules :: ModuleEnv -> [Module] Source #
Get a list of all the loaded modules. Each module in the resulting list depends only on other modules that precede it. Note that this includes parameterized modules.
loadedNonParamModules :: ModuleEnv -> [Module] Source #
Get a list of all the loaded non-parameterized modules. These are the modules that can be used for evaluation, proving etc.
hasParamModules :: ModuleEnv -> Bool Source #
Are any parameterized modules loaded?
allDeclGroups :: ModuleEnv -> [DeclGroup] Source #
data ModContextParams Source #
Constructors
| InterfaceParams ModParamNames | |
| FunctorParams FunctorParams | |
| NoParams |
data ModContext Source #
Contains enough information to browse what's in scope, or type check new expressions.
Constructors
| ModContext | |
Fields
| |
Instances
| Monoid ModContext Source # | |
Defined in Cryptol.ModuleSystem.Env Methods mempty :: ModContext # mappend :: ModContext -> ModContext -> ModContext # mconcat :: [ModContext] -> ModContext # | |
| Semigroup ModContext Source # | |
Defined in Cryptol.ModuleSystem.Env Methods (<>) :: ModContext -> ModContext -> ModContext # sconcat :: NonEmpty ModContext -> ModContext # stimes :: Integral b => b -> ModContext -> ModContext # | |
modContextOf :: ImpName Name -> ModuleEnv -> Maybe ModContext Source #
mainContexts :: ModuleEnv -> [ModContext] Source #
Find all normal modules named Main
lmModContext :: ModuleEnv -> LoadedModule -> ModContext Source #
dynModContext :: ModuleEnv -> ModContext Source #
focusedEnv :: ModuleEnv -> ModContext Source #
focusedEnv me - Given me, the state of the environment, compute
information about what's in scope on the REPL. This includes
what's in the focused module (`meFocusedModule me`), plus any
additional definitions from the REPL (e.g., let bound names, and
it).
focusedEnv' :: Maybe (ImpName Name) -> ModuleEnv -> ModContext Source #
focusedEnv' mfm me - Given me (the state of the environment),
compute information about what's in scope on the REPL. It also
includes additional definitions from the REPL (e.g., let bound
names, and it).
In contrast to focusedEnv,
- it does not include (`meFocusedModule me`)
- it optionally includes mfm
data ModulePath Source #
The location of a module
Constructors
| InFile FilePath | |
| InMem String ByteString | Label, content |
Instances
| Generic ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
| |||||
| Read ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods readsPrec :: Int -> ReadS ModulePath # readList :: ReadS [ModulePath] # readPrec :: ReadPrec ModulePath # readListPrec :: ReadPrec [ModulePath] # | |||||
| Show ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods showsPrec :: Int -> ModulePath -> ShowS # show :: ModulePath -> String # showList :: [ModulePath] -> ShowS # | |||||
| PP ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods ppPrec :: Int -> ModulePath -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModulePath -> Doc Source # | |||||
| NFData ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods rnf :: ModulePath -> () # | |||||
| Eq ModulePath Source # | In-memory things are compared by label. | ||||
Defined in Cryptol.ModuleSystem.Env | |||||
| Ord ModulePath Source # | In-memory things are compared by label. | ||||
Defined in Cryptol.ModuleSystem.Env Methods compare :: ModulePath -> ModulePath -> Ordering # (<) :: ModulePath -> ModulePath -> Bool # (<=) :: ModulePath -> ModulePath -> Bool # (>) :: ModulePath -> ModulePath -> Bool # (>=) :: ModulePath -> ModulePath -> Bool # max :: ModulePath -> ModulePath -> ModulePath # min :: ModulePath -> ModulePath -> ModulePath # | |||||
| type Rep ModulePath Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep ModulePath = D1 ('MetaData "ModulePath" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "InFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "InMem" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
modulePathLabel :: ModulePath -> String Source #
The name of the content---either the file path, or the provided label.
data LoadedModules Source #
Constructors
| LoadedModules | |
Fields
| |
Instances
| Monoid LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods mempty :: LoadedModules # mappend :: LoadedModules -> LoadedModules -> LoadedModules # mconcat :: [LoadedModules] -> LoadedModules # | |||||
| Semigroup LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods (<>) :: LoadedModules -> LoadedModules -> LoadedModules # sconcat :: NonEmpty LoadedModules -> LoadedModules # stimes :: Integral b => b -> LoadedModules -> LoadedModules # | |||||
| Generic LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
| |||||
| Show LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods showsPrec :: Int -> LoadedModules -> ShowS # show :: LoadedModules -> String # showList :: [LoadedModules] -> ShowS # | |||||
| NFData LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods rnf :: LoadedModules -> () # | |||||
| type Rep LoadedModules Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep LoadedModules = D1 ('MetaData "LoadedModules" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "LoadedModules" 'PrefixI 'True) (S1 ('MetaSel ('Just "lmLoadedModules") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LoadedModule]) :*: (S1 ('MetaSel ('Just "lmLoadedParamModules") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LoadedModule]) :*: S1 ('MetaSel ('Just "lmLoadedSignatures") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [LoadedSignature])))) | |||||
data LoadedEntity Source #
withLoadedEntity :: LoadedEntity -> (forall a. LoadedModuleG a -> b) -> b Source #
getLoadedModules :: LoadedModules -> [LoadedModule] Source #
getLoadedField :: Ord a => (forall b. LoadedModuleG b -> a) -> LoadedModules -> Set a Source #
getLoadedFieldMap :: Ord k => (forall b. LoadedModuleG b -> (k, v)) -> LoadedModules -> Map k v Source #
getLoadedNames :: LoadedModules -> Set ModName Source #
getLoadedIds :: LoadedModules -> Set String Source #
data LoadedModuleG a Source #
A generic type for loaded things. The things can be either modules or signatures.
Constructors
| LoadedModule | |
Fields
| |
Instances
| Generic (LoadedModuleG a) Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
Methods from :: LoadedModuleG a -> Rep (LoadedModuleG a) x # to :: Rep (LoadedModuleG a) x -> LoadedModuleG a # | |||||
| Show a => Show (LoadedModuleG a) Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods showsPrec :: Int -> LoadedModuleG a -> ShowS # show :: LoadedModuleG a -> String # showList :: [LoadedModuleG a] -> ShowS # | |||||
| NFData a => NFData (LoadedModuleG a) Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods rnf :: LoadedModuleG a -> () # | |||||
| type Rep (LoadedModuleG a) Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep (LoadedModuleG a) = D1 ('MetaData "LoadedModuleG" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "LoadedModule" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lmName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModName) :*: (S1 ('MetaSel ('Just "lmFilePath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModulePath) :*: S1 ('MetaSel ('Just "lmModuleId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) :*: ((S1 ('MetaSel ('Just "lmNamingEnv") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NamingEnv) :*: S1 ('MetaSel ('Just "lmFileInfo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FileInfo)) :*: (S1 ('MetaSel ('Just "lmRenamedModule") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Module Name))) :*: S1 ('MetaSel ('Just "lmData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))) | |||||
lmModule :: LoadedModule -> Module Source #
lmInterface :: LoadedModule -> Iface Source #
data LoadedModuleData Source #
Constructors
| LoadedModuleData | |
Fields
| |
Instances
| Generic LoadedModuleData Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
Methods from :: LoadedModuleData -> Rep LoadedModuleData x # to :: Rep LoadedModuleData x -> LoadedModuleData # | |||||
| Show LoadedModuleData Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods showsPrec :: Int -> LoadedModuleData -> ShowS # show :: LoadedModuleData -> String # showList :: [LoadedModuleData] -> ShowS # | |||||
| NFData LoadedModuleData Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods rnf :: LoadedModuleData -> () # | |||||
| type Rep LoadedModuleData Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep LoadedModuleData = D1 ('MetaData "LoadedModuleData" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "LoadedModuleData" 'PrefixI 'True) (S1 ('MetaSel ('Just "lmdInterface") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Iface) :*: (S1 ('MetaSel ('Just "lmdModule") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Module) :*: S1 ('MetaSel ('Just "lmForeignSrc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ForeignSrc))))) | |||||
isLoadedStrict :: ImpName Name -> String -> LoadedModules -> Bool Source #
isLoadedParamMod :: ImpName Name -> LoadedModules -> Bool Source #
Is this a loaded parameterized module.
isLoadedInterface :: ImpName Name -> LoadedModules -> Bool Source #
Is this a loaded interface module.
loadedParamModDeps :: FreeVars a => LoadedModules -> a -> (Set TParam, Set Name) Source #
Return the set of type parameters () and definitions
(Set TParam) from the supplied Set NameLoadedModules value that another
definition (of type a) depends on.
lookupTCEntity :: ModName -> ModuleEnv -> Maybe (LoadedModuleG TCTopEntity) Source #
lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule Source #
Try to find a previously loaded module
lookupMainModules :: ModuleEnv -> [LoadedModule] Source #
Find all loaded Main modules
lookupModuleWith :: (LoadedModule -> Bool) -> ModuleEnv -> Maybe LoadedModule Source #
lookupSignature :: ModName -> ModuleEnv -> Maybe LoadedSignature Source #
lookupSignatureWith :: (LoadedSignature -> Bool) -> ModuleEnv -> Maybe LoadedSignature Source #
addLoadedSignature :: ModulePath -> String -> FileInfo -> NamingEnv -> ModName -> Maybe (Module Name) -> ModParamNames -> LoadedModules -> LoadedModules Source #
addLoadedModule :: ModulePath -> String -> FileInfo -> NamingEnv -> Maybe ForeignSrc -> Maybe (Module Name) -> Module -> LoadedModules -> LoadedModules Source #
Add a freshly loaded module. If it was previously loaded, then the new version is ignored.
removeLoadedModule :: (forall a. LoadedModuleG a -> Bool) -> LoadedModules -> LoadedModules Source #
Remove a previously loaded module.
Note that this removes exactly the modules specified by the predicate.
One should be careful to preserve the invariant on LoadedModules.
Constructors
| FileInfo | |
Fields
| |
Instances
| Generic FileInfo Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
| |||||
| Show FileInfo Source # | |||||
| NFData FileInfo Source # | |||||
Defined in Cryptol.ModuleSystem.Env | |||||
| type Rep FileInfo Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep FileInfo = D1 ('MetaData "FileInfo" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "FileInfo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "fiFingerprint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Fingerprint) :*: S1 ('MetaSel ('Just "fiIncludeDeps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map FilePath Fingerprint))) :*: (S1 ('MetaSel ('Just "fiImportDeps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set ModName)) :*: S1 ('MetaSel ('Just "fiForeignDeps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map FilePath Bool))))) | |||||
fileInfo :: Fingerprint -> Map FilePath Fingerprint -> Set ModName -> Maybe ForeignSrc -> FileInfo Source #
data DynamicEnv Source #
Extra information we need to carry around to dynamically extend
an environment outside the context of a single module. Particularly
useful when dealing with interactive declarations as in let or
it.
Constructors
| DEnv | |
Instances
| Monoid DynamicEnv Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods mempty :: DynamicEnv # mappend :: DynamicEnv -> DynamicEnv -> DynamicEnv # mconcat :: [DynamicEnv] -> DynamicEnv # | |||||
| Semigroup DynamicEnv Source # | |||||
Defined in Cryptol.ModuleSystem.Env Methods (<>) :: DynamicEnv -> DynamicEnv -> DynamicEnv # sconcat :: NonEmpty DynamicEnv -> DynamicEnv # stimes :: Integral b => b -> DynamicEnv -> DynamicEnv # | |||||
| Generic DynamicEnv Source # | |||||
Defined in Cryptol.ModuleSystem.Env Associated Types
| |||||
| type Rep DynamicEnv Source # | |||||
Defined in Cryptol.ModuleSystem.Env type Rep DynamicEnv = D1 ('MetaData "DynamicEnv" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "DEnv" 'PrefixI 'True) ((S1 ('MetaSel ('Just "deNames") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NamingEnv) :*: S1 ('MetaSel ('Just "deDecls") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [DeclGroup])) :*: (S1 ('MetaSel ('Just "deTySyns") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Name TySyn)) :*: S1 ('MetaSel ('Just "deEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EvalEnv)))) | |||||
deIfaceDecls :: DynamicEnv -> IfaceDecls Source #
Build IfaceDecls that correspond to all of the bindings in the
dynamic environment.
XXX: if we add newtypes, etc. at the REPL, revisit this.