cryptol-3.5.0: Cryptol: The Language of Cryptography
Copyright(c) 2013-2016 Galois Inc.
LicenseBSD3
Maintainercryptol@galois.com
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Cryptol.ModuleSystem.Env

Description

 
Synopsis

Documentation

data ModuleEnv Source #

This is the current state of the interpreter.

Constructors

ModuleEnv 

Fields

Instances

Instances details
Generic ModuleEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData ModuleEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: ModuleEnv -> () #

type Rep ModuleEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

data CoreLint Source #

Should we run the linter?

Constructors

NoCoreLint

Don't run core lint

CoreLint

Run core lint

Instances

Instances details
Generic CoreLint Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep CoreLint 
Instance details

Defined in Cryptol.ModuleSystem.Env

type Rep CoreLint = D1 ('MetaData "CoreLint" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "NoCoreLint" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CoreLint" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: CoreLint -> Rep CoreLint x #

to :: Rep CoreLint x -> CoreLint #

NFData CoreLint Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: CoreLint -> () #

type Rep CoreLint Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

type Rep CoreLint = D1 ('MetaData "CoreLint" "Cryptol.ModuleSystem.Env" "cryptol-3.5.0-HoSGjqdyafy4TMoEJgOBMg" 'False) (C1 ('MetaCons "NoCoreLint" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CoreLint" 'PrefixI 'False) (U1 :: Type -> Type))

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

Instances details
Eq EvalForeignPolicy Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

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.

loadedNominalTypes :: ModuleEnv -> Map Name NominalType Source #

Get a Map of all the loaded nominal types, where the keys of the Map are the Names of each nominal type. Note that this includes parameterized modules.

hasParamModules :: ModuleEnv -> Bool Source #

Are any parameterized modules loaded?

data ModContext Source #

Contains enough information to browse what's in scope, or type check new expressions.

Constructors

ModContext 

Fields

mainContexts :: ModuleEnv -> [ModContext] Source #

Find all normal modules named Main

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

Instances details
Generic ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep ModulePath 
Instance details

Defined in Cryptol.ModuleSystem.Env

Read ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Show ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

PP ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: ModulePath -> () #

Eq ModulePath Source #

In-memory things are compared by label.

Instance details

Defined in Cryptol.ModuleSystem.Env

Ord ModulePath Source #

In-memory things are compared by label.

Instance details

Defined in Cryptol.ModuleSystem.Env

type Rep ModulePath Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

modulePathLabel :: ModulePath -> String Source #

The name of the content---either the file path, or the provided label.

data LoadedModules Source #

Constructors

LoadedModules 

Fields

Instances

Instances details
Monoid LoadedModules Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Semigroup LoadedModules Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Generic LoadedModules Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep LoadedModules 
Instance details

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]))))
Show LoadedModules Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData LoadedModules Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: LoadedModules -> () #

type Rep LoadedModules Source # 
Instance details

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]))))

withLoadedEntity :: LoadedEntity -> (forall a. LoadedModuleG a -> b) -> b 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 #

data LoadedModuleG a Source #

A generic type for loaded things. The things can be either modules or signatures.

Constructors

LoadedModule 

Fields

Instances

Instances details
Generic (LoadedModuleG a) Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep (LoadedModuleG a) 
Instance details

Defined in Cryptol.ModuleSystem.Env

Show a => Show (LoadedModuleG a) Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData a => NFData (LoadedModuleG a) Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: LoadedModuleG a -> () #

type Rep (LoadedModuleG a) Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

data LoadedModuleData Source #

Constructors

LoadedModuleData 

Fields

Instances

Instances details
Generic LoadedModuleData Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep LoadedModuleData 
Instance details

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)))))
Show LoadedModuleData Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData LoadedModuleData Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: LoadedModuleData -> () #

type Rep LoadedModuleData Source # 
Instance details

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)))))

isLoaded :: ImpName Name -> LoadedModules -> Bool Source #

Has this module been loaded already.

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 (Set TParam) and definitions (Set Name) from the supplied LoadedModules value that another definition (of type a) depends on.

lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule Source #

Try to find a previously loaded module

lookupMainModules :: ModuleEnv -> [LoadedModule] Source #

Find all loaded Main modules

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.

data FileInfo Source #

Constructors

FileInfo 

Fields

Instances

Instances details
Generic FileInfo Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep FileInfo 
Instance details

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)))))

Methods

from :: FileInfo -> Rep FileInfo x #

to :: Rep FileInfo x -> FileInfo #

Show FileInfo Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

NFData FileInfo Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Methods

rnf :: FileInfo -> () #

type Rep FileInfo Source # 
Instance details

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)))))

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

Instances details
Monoid DynamicEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Semigroup DynamicEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Generic DynamicEnv Source # 
Instance details

Defined in Cryptol.ModuleSystem.Env

Associated Types

type Rep DynamicEnv 
Instance details

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))))
type Rep DynamicEnv Source # 
Instance details

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.