Copyright | (c) 2019 disco team (see LICENSE) |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
The ModuleInfo
record representing a disco module, and functions
to resolve the location of a module on disk.
Synopsis
- data LoadingMode
- = REPL
- | Standalone
- data Defn = Defn (Name ATerm) [Type] Type [Clause]
- type Clause = Bind [APattern] ATerm
- eraseClause :: Clause -> Bind [Pattern] Term
- data ModuleInfo = ModuleInfo {}
- miTys :: Lens' ModuleInfo TyCtx
- miTydefs :: Lens' ModuleInfo TyDefCtx
- miTerms :: Lens' ModuleInfo [(ATerm, PolyType)]
- miTermdefs :: Lens' ModuleInfo (Ctx ATerm Defn)
- miProps :: Lens' ModuleInfo (Ctx ATerm [AProperty])
- miNames :: Lens' ModuleInfo [QName Term]
- miName :: Lens' ModuleInfo ModuleName
- miImports :: Lens' ModuleInfo (Map ModuleName ModuleInfo)
- miExts :: Lens' ModuleInfo ExtSet
- miDocs :: Lens' ModuleInfo (Ctx Term Docs)
- withImports :: Monoid a => Getting a ModuleInfo a -> ModuleInfo -> a
- allTys :: ModuleInfo -> TyCtx
- allTydefs :: ModuleInfo -> TyDefCtx
- emptyModuleInfo :: ModuleInfo
- data Resolver
- withStdlib :: Resolver -> Resolver
- resolveModule :: Member (Embed IO) r => Resolver -> String -> Sem r (Maybe (FilePath, ModuleProvenance))
Documentation
data LoadingMode Source #
When loading a module, we could be loading it from code entered at the REPL, or from a standalone file. The two modes have slightly different behavior.
A definition consists of a name being defined, the types of any pattern arguments (each clause must have the same number of patterns), the type of the body of each clause, and a list of clauses. For example,
f x (0,z) = 3*x + z > 5 f x (y,z) = z == 9
might look like Defn f [Z, Z*Z] B [clause 1 ..., clause 2 ...]
Instances
type Clause = Bind [APattern] ATerm Source #
A clause in a definition consists of a list of patterns (the LHS
of the =) and a term (the RHS). For example, given the concrete
syntax f n (x,y) = n*x + y
, the corresponding Clause
would be
something like [n, (x,y)] (n*x + y)
.
data ModuleInfo Source #
Type checking a module yields a value of type ModuleInfo which contains mapping from terms to their relavent documenation, a mapping from terms to properties, and a mapping from terms to their types.
Instances
Show ModuleInfo Source # | |
Defined in Disco.Module showsPrec :: Int -> ModuleInfo -> ShowS # show :: ModuleInfo -> String # showList :: [ModuleInfo] -> ShowS # | |
Semigroup ModuleInfo Source # | |
Defined in Disco.Module (<>) :: ModuleInfo -> ModuleInfo -> ModuleInfo # sconcat :: NonEmpty ModuleInfo -> ModuleInfo # stimes :: Integral b => b -> ModuleInfo -> ModuleInfo # | |
Monoid ModuleInfo Source # | |
Defined in Disco.Module mempty :: ModuleInfo # mappend :: ModuleInfo -> ModuleInfo -> ModuleInfo # mconcat :: [ModuleInfo] -> ModuleInfo # |
miTermdefs :: Lens' ModuleInfo (Ctx ATerm Defn) Source #
withImports :: Monoid a => Getting a ModuleInfo a -> ModuleInfo -> a Source #
Get something from a module and its direct imports.
allTys :: ModuleInfo -> TyCtx Source #
Get the types of all names bound in a module and its direct imports.
allTydefs :: ModuleInfo -> TyDefCtx Source #
Get all type definitions from a module and its direct imports.
emptyModuleInfo :: ModuleInfo Source #
The empty module info record.
A data type indicating where we should look for Disco modules to be loaded.
FromStdlib | Load only from the stdlib (standard lib modules) |
FromDir FilePath | Load only from a specific directory (:load) |
FromCwdOrStdlib | Load from current working dir or stdlib (import at REPL) |
FromDirOrStdlib FilePath | Load from specific dir or stdlib (import in file) |
withStdlib :: Resolver -> Resolver Source #
Add the possibility of loading imports from the stdlib. For example, this is what we want to do after a user loads a specific file using `:load` (for which we will NOT look in the stdlib), but then we need to recursively load modules which it imports (which may either be in the stdlib, or the same directory as the `:load`ed module).
resolveModule :: Member (Embed IO) r => Resolver -> String -> Sem r (Maybe (FilePath, ModuleProvenance)) Source #
Given a module resolution mode and a raw module name, relavent directories are searched for the file containing the provided module name. Returns Nothing if no module with the given name could be found.