Safe Haskell | None |
---|---|
Language | Haskell98 |
Data types for modules and declarations
- data Module = Module ModuleName [Declaration] (Maybe [DeclarationRef])
- getModuleName :: Module -> ModuleName
- isExported :: Maybe [DeclarationRef] -> Declaration -> Bool
- exportedDeclarations :: Module -> [Declaration]
- isDctorExported :: ProperName -> Maybe [DeclarationRef] -> ProperName -> Bool
- exportedDctors :: Module -> ProperName -> [ProperName]
- data DeclarationRef
- data ImportDeclarationType
- data Declaration
- = DataDeclaration DataDeclType ProperName [(String, Maybe Kind)] [(ProperName, [Type])]
- | DataBindingGroupDeclaration [Declaration]
- | TypeSynonymDeclaration ProperName [(String, Maybe Kind)] Type
- | TypeDeclaration Ident Type
- | ValueDeclaration Ident NameKind [Binder] (Either [(Guard, Expr)] Expr)
- | BindingGroupDeclaration [(Ident, NameKind, Expr)]
- | ExternDeclaration ForeignImportType Ident (Maybe JS) Type
- | ExternDataDeclaration ProperName Kind
- | ExternInstanceDeclaration Ident [Constraint] (Qualified ProperName) [Type]
- | FixityDeclaration Fixity String
- | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName)
- | TypeClassDeclaration ProperName [(String, Maybe Kind)] [Constraint] [Declaration]
- | TypeInstanceDeclaration Ident [Constraint] (Qualified ProperName) [Type] [Declaration]
- | PositionedDeclaration SourceSpan [Comment] Declaration
- isValueDecl :: Declaration -> Bool
- isDataDecl :: Declaration -> Bool
- isImportDecl :: Declaration -> Bool
- isExternDataDecl :: Declaration -> Bool
- isExternInstanceDecl :: Declaration -> Bool
- isFixityDecl :: Declaration -> Bool
- isExternDecl :: Declaration -> Bool
- isTypeClassDeclaration :: Declaration -> Bool
- flattenDecls :: [Declaration] -> [Declaration]
- type Guard = Expr
- data Expr
- = NumericLiteral (Either Integer Double)
- | StringLiteral String
- | BooleanLiteral Bool
- | UnaryMinus Expr
- | BinaryNoParens (Qualified Ident) Expr Expr
- | Parens Expr
- | ArrayLiteral [Expr]
- | ObjectLiteral [(String, Expr)]
- | Accessor String Expr
- | ObjectUpdate Expr [(String, Expr)]
- | Abs (Either Ident Binder) Expr
- | App Expr Expr
- | Var (Qualified Ident)
- | IfThenElse Expr Expr Expr
- | Constructor (Qualified ProperName)
- | Case [Expr] [CaseAlternative]
- | TypedValue Bool Expr Type
- | Let [Declaration] Expr
- | Do [DoNotationElement]
- | TypeClassDictionaryConstructorApp (Qualified ProperName) Expr
- | TypeClassDictionary Bool Constraint [TypeClassDictionaryInScope]
- | SuperClassDictionary (Qualified ProperName) [Type]
- | PositionedValue SourceSpan [Comment] Expr
- data CaseAlternative = CaseAlternative {
- caseAlternativeBinders :: [Binder]
- caseAlternativeResult :: Either [(Guard, Expr)] Expr
- data DoNotationElement
Documentation
A module declaration, consisting of a module name, a list of declarations, and a list of the declarations that are explicitly exported. If the export list is Nothing, everything is exported.
getModuleName :: Module -> ModuleName Source
Return a module's name.
isExported :: Maybe [DeclarationRef] -> Declaration -> Bool Source
Test if a declaration is exported, given a module's export list.
exportedDeclarations :: Module -> [Declaration] Source
isDctorExported :: ProperName -> Maybe [DeclarationRef] -> ProperName -> Bool Source
Test if a data constructor for a given type is exported, given a module's export list.
exportedDctors :: Module -> ProperName -> [ProperName] Source
Return the exported data constructors for a given type.
data DeclarationRef Source
An item in a list of explicit imports or exports
TypeRef ProperName (Maybe [ProperName]) | A type constructor with data constructors |
ValueRef Ident | A value |
TypeClassRef ProperName | A type class |
TypeInstanceRef Ident | A type class instance, created during typeclass desugaring (name, class name, instance types) |
PositionedDeclarationRef SourceSpan [Comment] DeclarationRef | A declaration reference with source position information |
data ImportDeclarationType Source
The data type which specifies type of import declaration
Unqualified | Unqualified import |
Qualifying [DeclarationRef] | Qualified import with a list of references to import |
Hiding [DeclarationRef] | Import with hiding clause with a list of references to hide |
data Declaration Source
The data type of declarations
DataDeclaration DataDeclType ProperName [(String, Maybe Kind)] [(ProperName, [Type])] | A data type declaration (data or newtype, name, arguments, data constructors) |
DataBindingGroupDeclaration [Declaration] | A minimal mutually recursive set of data type declarations |
TypeSynonymDeclaration ProperName [(String, Maybe Kind)] Type | A type synonym declaration (name, arguments, type) |
TypeDeclaration Ident Type | A type declaration for a value (name, ty) |
ValueDeclaration Ident NameKind [Binder] (Either [(Guard, Expr)] Expr) | A value declaration (name, top-level binders, optional guard, value) |
BindingGroupDeclaration [(Ident, NameKind, Expr)] | A minimal mutually recursive set of value declarations |
ExternDeclaration ForeignImportType Ident (Maybe JS) Type | A foreign import declaration (type, name, optional inline Javascript, type) |
ExternDataDeclaration ProperName Kind | A data type foreign import (name, kind) |
ExternInstanceDeclaration Ident [Constraint] (Qualified ProperName) [Type] | A type class instance foreign import |
FixityDeclaration Fixity String | A fixity declaration (fixity data, operator name) |
ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName) | A module import (module name, qualifiedunqualifiedhiding, optional "qualified as" name) |
TypeClassDeclaration ProperName [(String, Maybe Kind)] [Constraint] [Declaration] | A type class declaration (name, argument, implies, member declarations) |
TypeInstanceDeclaration Ident [Constraint] (Qualified ProperName) [Type] [Declaration] | A type instance declaration (name, dependencies, class name, instance types, member declarations) |
PositionedDeclaration SourceSpan [Comment] Declaration | A declaration with source position information |
isValueDecl :: Declaration -> Bool Source
Test if a declaration is a value declaration
isDataDecl :: Declaration -> Bool Source
Test if a declaration is a data type or type synonym declaration
isImportDecl :: Declaration -> Bool Source
Test if a declaration is a module import
isExternDataDecl :: Declaration -> Bool Source
Test if a declaration is a data type foreign import
isExternInstanceDecl :: Declaration -> Bool Source
Test if a declaration is a type class instance foreign import
isFixityDecl :: Declaration -> Bool Source
Test if a declaration is a fixity declaration
isExternDecl :: Declaration -> Bool Source
Test if a declaration is a foreign import
isTypeClassDeclaration :: Declaration -> Bool Source
Test if a declaration is a type class or instance declaration
flattenDecls :: [Declaration] -> [Declaration] Source
Recursively flatten data binding groups in the list of declarations
A guard is just a boolean-valued expression that appears alongside a set of binders
Data type for expressions and terms
NumericLiteral (Either Integer Double) | A numeric literal |
StringLiteral String | A string literal |
BooleanLiteral Bool | A boolean literal |
UnaryMinus Expr | A prefix -, will be desugared |
BinaryNoParens (Qualified Ident) Expr Expr | Binary operator application. During the rebracketing phase of desugaring, this data constructor will be removed. |
Parens Expr | Explicit parentheses. During the rebracketing phase of desugaring, this data constructor will be removed. |
ArrayLiteral [Expr] | An array literal |
ObjectLiteral [(String, Expr)] | An object literal |
Accessor String Expr | An record property accessor expression |
ObjectUpdate Expr [(String, Expr)] | Partial record update |
Abs (Either Ident Binder) Expr | Function introduction |
App Expr Expr | Function application |
Var (Qualified Ident) | Variable |
IfThenElse Expr Expr Expr | Conditional (if-then-else expression) |
Constructor (Qualified ProperName) | A data constructor |
Case [Expr] [CaseAlternative] | A case expression. During the case expansion phase of desugaring, top-level binders will get desugared into case expressions, hence the need for guards and multiple binders per branch here. |
TypedValue Bool Expr Type | A value with a type annotation |
Let [Declaration] Expr | A let binding |
Do [DoNotationElement] | A do-notation block |
TypeClassDictionaryConstructorApp (Qualified ProperName) Expr | An application of a typeclass dictionary constructor. The value should be an ObjectLiteral. |
TypeClassDictionary Bool Constraint [TypeClassDictionaryInScope] | A placeholder for a type class dictionary to be inserted later. At the end of type checking, these placeholders will be replaced with actual expressions representing type classes dictionaries which can be evaluated at runtime. The constructor arguments represent (in order): whether or not to look at superclass implementations when searching for a dictionary, the type class name and instance type, and the type class dictionaries in scope. |
SuperClassDictionary (Qualified ProperName) [Type] | A placeholder for a superclass dictionary to be turned into a TypeClassDictionary during typechecking |
PositionedValue SourceSpan [Comment] Expr | A value with source position information |
data CaseAlternative Source
An alternative in a case statement
CaseAlternative | |
|
data DoNotationElement Source
A statement in a do-notation block
DoNotationValue Expr | A monadic value without a binder |
DoNotationBind Binder Expr | A monadic value with a binder |
DoNotationLet [Declaration] | A let statement, i.e. a pure value with a binder |
PositionedDoNotationElement SourceSpan [Comment] DoNotationElement | A do notation element with source position information |