Safe Haskell | None |
---|---|
Language | Haskell2010 |
- resolve :: (Data l, Eq l) => [Module l] -> Environment -> Environment
- annotate :: (Data l, Eq l, SrcInfo l) => Environment -> Module l -> Module (Scoped l)
- type Environment = Map ModuleName [Symbol]
- data Symbol
- = Value { }
- | Method { }
- | Selector {
- symbolModule :: ModuleName
- symbolName :: Name
- typeName :: Name
- constructors :: [Name]
- | Constructor {
- symbolModule :: ModuleName
- symbolName :: Name
- typeName :: Name
- | Type { }
- | Data { }
- | NewType { }
- | TypeFam { }
- | DataFam { }
- | Class { }
- data Scoped l = Scoped (NameInfo l) l
- data NameInfo l
- = GlobalSymbol Symbol QName
- | LocalValue SrcLoc
- | TypeVar SrcLoc
- | ValueBinder
- | TypeBinder
- | Import (Map QName [Symbol])
- | ImportPart [Symbol]
- | Export [Symbol]
- | RecPatWildcard [Symbol]
- | RecExpWildcard [(Name, NameInfo l)]
- | None
- | ScopeError (Error l)
- data Error l
- = ENotInScope (QName l)
- | EAmbiguous (QName l) [Symbol]
- | ETypeAsClass (QName l)
- | EClassAsType (QName l)
- | ENotExported (Maybe (Name l)) (Name l) (ModuleName l)
- | EModNotFound (ModuleName l)
- | EInternal String
- readSymbols :: FilePath -> IO [Symbol]
- writeSymbols :: FilePath -> [Symbol] -> IO ()
- loadBase :: IO Environment
- ppError :: SrcInfo l => Error l -> String
- ppSymbol :: Symbol -> String
Functions
resolve :: (Data l, Eq l) => [Module l] -> Environment -> Environment Source #
Takes a list of modules and an environment and updates the environment with each of the given modules' exported symbols.
annotate :: (Data l, Eq l, SrcInfo l) => Environment -> Module l -> Module (Scoped l) Source #
Annotate a module with scoping information using the given environment. All imports of the given module should be in the environment.
Types
type Environment = Map ModuleName [Symbol] Source #
A map from module name to list of symbols it exports.
Information about an entity. Carries at least the module it was originally declared in and its name.
Value | value or function |
| |
Method | class method |
| |
Selector | record field selector |
| |
Constructor | data constructor |
| |
Type | type synonym |
| |
Data | data type |
| |
NewType | newtype |
| |
TypeFam | type family |
| |
DataFam | data family |
| |
Class | type class |
|
A pair of the name information and original annotation. Used as an annotation type for AST.
Information about the names used in an AST.
GlobalSymbol Symbol QName | global entitiy and the way it is referenced |
LocalValue SrcLoc | local value, and location where it is bound |
TypeVar SrcLoc | type variable, and location where it is bound |
ValueBinder | here the value name is bound |
TypeBinder | here the type name is defined |
Import (Map QName [Symbol]) |
|
ImportPart [Symbol] | part of an |
Export [Symbol] | part of an |
RecPatWildcard [Symbol] | wildcard in a record pattern. The list contains resolved names of the fields that are brought in scope by this pattern. |
RecExpWildcard [(Name, NameInfo l)] | wildcard in a record construction expression. The list contains resolved names of the fields and information about values assigned to those fields. |
None | no annotation |
ScopeError (Error l) | scope error |
Errors during name resolution.
ENotInScope (QName l) | name is not in scope |
EAmbiguous (QName l) [Symbol] | name is ambiguous |
ETypeAsClass (QName l) | type is used where a type class is expected |
EClassAsType (QName l) | type class is used where a type is expected |
ENotExported (Maybe (Name l)) (Name l) (ModuleName l) | Attempt to explicitly import a name which is not exported (or, possibly, does not even exist). For example: import Prelude(Bool(Right)) The fields are:
|
EModNotFound (ModuleName l) | module not found |
EInternal String | internal error |
Reading and writing environments
loadBase :: IO Environment Source #
Load a basic environment that contains modules very similar to GHC's base package.