| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
FreeC.IR.Syntax.Type
Description
This module contains the definition of type expressions of our intermediate language.
Synopsis
- data Type
- = TypeVar { }
- | TypeCon { }
- | TypeApp {
- typeSrcSpan :: SrcSpan
- typeAppLhs :: Type
- typeAppRhs :: Type
- | FuncType {
- typeSrcSpan :: SrcSpan
- funcTypeArg :: Type
- funcTypeRes :: Type
- typeApp :: SrcSpan -> Type -> [Type] -> Type
- typeConApp :: SrcSpan -> TypeConName -> [Type] -> Type
- funcType :: SrcSpan -> [Type] -> Type -> Type
- splitFuncType :: Type -> Int -> ([Type], Type)
- getTypeConName :: Type -> Maybe ConName
- isTypeVar :: Type -> Bool
- isTypeCon :: Type -> Bool
- isTypeApp :: Type -> Bool
- isFuncType :: Type -> Bool
- prettyTypePred :: Int -> Type -> Doc
Documentation
A type expression.
Built-in types are represented by applications of their type constructors.
E.g. the type [a] is represented as
.
The only exception to this rule is the function type TypeApp (TypeCon "[]") (TypeVar "a")a -> b. It is
represented directly as .
The syntax FuncType (TypeVar "a") (TypeVar "b")(->) a b is not supported at the moment. This is due to the
special role of functions during the lifting.
Constructors
| TypeVar | A type variable. |
Fields | |
| TypeCon | A type constructor. |
Fields | |
| TypeApp | A type constructor application. |
Fields
| |
| FuncType | A function type. |
Fields
| |
Instances
| Eq Type Source # | |
| Show Type Source # | |
| Pretty Type Source # | Pretty instance for type expressions. |
Defined in FreeC.IR.Syntax.Type | |
| FromJSON Type | Restores a Haskell type from the interface file. |
Defined in FreeC.Environment.ModuleInterface.Decoder | |
| ToJSON Type | |
Defined in FreeC.Environment.ModuleInterface.Encoder Methods toEncoding :: Type -> Encoding toJSONList :: [Type] -> Value toEncodingList :: [Type] -> Encoding | |
| Similar Type Source # | The similarity relation of type expressions is governed by the the following inference rules.
|
Defined in FreeC.IR.Similar | |
| HasRefs Type Source # | Type expressions refer to the used type variables and type constructors. |
Defined in FreeC.IR.Reference | |
| Parseable Type Source # | Type expressions can be parsed. |
Defined in FreeC.Frontend.IR.Parser | |
| ApplySubst Type Type Source # | Applies the given type substitution to a type expression. |
Defined in FreeC.IR.Subst | |
| ApplySubst Type TypeScheme Source # | Applies the given type substitution to a type scheme. |
Defined in FreeC.IR.Subst Methods applySubst :: Subst Type -> TypeScheme -> TypeScheme Source # | |
| ApplySubst Type Bind Source # | Applies the given type substitution to the variable pattern and expression
of the given |
Defined in FreeC.IR.Subst | |
| ApplySubst Type VarPat Source # | Applies the given type substitution to the type annotation of the given variable pattern. |
Defined in FreeC.IR.Subst | |
| ApplySubst Type Alt Source # | Applies the given type substitution to the right-hand side of the
given |
Defined in FreeC.IR.Subst | |
| ApplySubst Type Expr Source # | Applies the given type substitution to an expression. |
Defined in FreeC.IR.Subst | |
| ApplySubst Type FuncDecl Source # | Applies the given type substitution to the right-hand side of a function declaration. |
Defined in FreeC.IR.Subst | |
Arguments
| :: SrcSpan | The source span to insert into generated nodes. |
| -> Type | The partially applied type constructor. |
| -> [Type] | The type arguments to pass to the type constructor. |
| -> Type |
Creates a type constructor application type.
The given source span is inserted into the generated type constructor and every generated type constructor application.
Arguments
| :: SrcSpan | The source span to insert into generated nodes. |
| -> TypeConName | The name of the type constructor to apply. |
| -> [Type] | The type arguments to pass to the type constructor. |
| -> Type |
Creates a type constructor application type for the constructor with the given name.
The given source span is inserted into the generated type constructor and every generated type constructor application.
funcType :: SrcSpan -> [Type] -> Type -> Type Source #
Creates a function type with the given argument and return types.
splitFuncType :: Type -> Int -> ([Type], Type) Source #
Splits the type of a function or constructor with the given arity into the argument and return types.
This is basically the inverse of funcType.
getTypeConName :: Type -> Maybe ConName Source #
Returns the name of the outermost type constructor, or Nothing if there
is no such type constructor.
isFuncType :: Type -> Bool Source #
Checks whether the given type is a function type.
prettyTypePred :: Int -> Type -> Doc Source #
Pretty prints a type and adds parentheses if necessary.
The first argument indicates the precedence of the surrounding
context.
* 0 - Top level. No parentheses are necessary.
* 1 - Parentheses are needed around function types.
* 2 - Parentheses are also needed around type constructor
applications.