Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module deals with imports of nested modules (import submodule
).
This is more complex than it might seem at first because to resolve a
declaration like import submodule X
we need to resolve what X
referes to before we know what it will import.
Even triciker is the case for functor instantiations:
module M = F { X } import M
In this case, even if we know what M
referes to, we first need to
resolve F
, so that we can generate the instantiation and generate
fresh names for names defined by M
.
If we want to support applicative semantics, then before instantiation
M
we also need to resolve X
so that we know if this instantiation has
already been generated.
An overall guiding principle of the design is that we assume that declarations can be ordered in dependency order, and submodules can be processed one at a time. In particular, this does not allow recursion across modules, or functor instantiations depending on their arguments.
Thus, the following is OK:
module A where x = 0x2
submodule B where y = x
z = B::y
However, this is not OK:
submodule A = F X submodule F where import A
Synopsis
- resolveImports :: (ImpName Name -> Mod ()) -> TopDef -> Supply -> (Map (ImpName Name) ResolvedLocal, Supply)
- data ResolvedModule imps = ResolvedModule {
- rmodDefines :: NamingEnv
- rmodPublic :: !(Set Name)
- rmodKind :: ModKind
- rmodNested :: Set Name
- rmodImports :: imps
- data ModKind
- type ResolvedLocal = ResolvedModule NamingEnv
- type ResolvedExt = ResolvedModule ()
Documentation
resolveImports :: (ImpName Name -> Mod ()) -> TopDef -> Supply -> (Map (ImpName Name) ResolvedLocal, Supply) Source #
data ResolvedModule imps Source #
This represents a resolved module or signaure. The type parameter helps us distinguish between two types of resolved modules:
- Resolved modules that are *inputs* to the algorithm (i.e., they are
defined outside the current module). For such modules the type
parameter is
imps
is () - Resolved modules that are *outputs* of the algorithm (i.e., they
are defined within the current module). For such modules the type
parameter
imps
contains the naming environment for things that came in through the import.
Note that signaures are never "imported", however we do need to keep them here so that signatures in a functor are properly instantiated when the functor is instantiated.
ResolvedModule | |
|
Instances
Generic ModKind Source # | |
Show ModKind Source # | |
PP ModKind Source # | |
NFData ModKind Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Error | |
Eq ModKind Source # | |
Ord ModKind Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Error | |
type Rep ModKind Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Error type Rep ModKind = D1 ('MetaData "ModKind" "Cryptol.ModuleSystem.Renamer.Error" "cryptol-3.2.0-35bDsq0QUVdvBXha47jji" 'False) (C1 ('MetaCons "AFunctor" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ASignature" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AModule" 'PrefixI 'False) (U1 :: Type -> Type))) |
type ResolvedLocal = ResolvedModule NamingEnv Source #
A resolved module that's defined in (or is) the current top-level module
type ResolvedExt = ResolvedModule () Source #
A resolved module that's not defined in the current top-level module