Safe Haskell | None |
---|---|
Language | Haskell2010 |
- valueType :: Value -> SuccFail Type
- typeCheckValues :: [String] -> [Type] -> [Value] -> SuccFail [Value]
- typeVarsIn :: Type -> [TypeVarName]
- type Subst = TypeVarName -> Type
- subst :: Subst -> Type -> Type
- substComp :: Subst -> Subst -> Subst
- idSubst :: Subst
- deltaSubst :: TypeVarName -> Type -> Subst
- extend :: Subst -> TypeVarName -> Type -> SuccFail Subst
- unify :: Subst -> (Type, Type) -> SuccFail Subst
- data TypeScheme = TypeScheme [TypeVarName] Type
- schematicsTS :: TypeScheme -> [TypeVarName]
- unknownsTS :: TypeScheme -> [TypeVarName]
- substTS :: Subst -> TypeScheme -> TypeScheme
- type TypeEnv = Map TypeVarName TypeScheme
- emptyTypeEnv :: TypeEnv
- install :: TypeEnv -> TypeVarName -> TypeScheme -> TypeEnv
- unknownsTE :: TypeEnv -> [TypeVarName]
- substTE :: Subst -> TypeEnv -> TypeEnv
- data NameSupply = NameSupply TypeVarName Int
- newNameSupply :: TypeVarName -> NameSupply
- nameSupplyNext :: NameSupply -> (TypeVarName, NameSupply)
- nameSupplyTake :: NameSupply -> Int -> ([TypeVarName], NameSupply)
- tcExpr :: TypeEnv -> NameSupply -> Expr -> SuccFail (Subst, Type, NameSupply)
- tcExprs :: TypeEnv -> NameSupply -> [Expr] -> SuccFail (Subst, [Type], NameSupply)
- tcVar :: TypeEnv -> NameSupply -> String -> SuccFail (Subst, Type, NameSupply)
- newInstance :: NameSupply -> TypeScheme -> (Type, NameSupply)
- arrow :: Type -> Type -> Type
- envToTypeEnv :: Env -> TypeEnv
- baseTypeEnv :: TypeEnv
- fromLambdaType :: Type -> SuccFail ([Type], Type)
- decideTypes :: String -> Expr -> [String] -> Env -> SuccFail ([Type], Type)
Documentation
valueType :: Value -> SuccFail Type Source
Determine the type of a value. May result in a type variable.
typeCheckValues :: [String] -> [Type] -> [Value] -> SuccFail [Value] Source
Check whether the values agree with the types (which may be abstract)
This is *probably* too lenient in the case of type variables: it can pass a mixed-type list.
typeVarsIn :: Type -> [TypeVarName] Source
type Subst = TypeVarName -> Type Source
The type of a substitution function, which maps type variables to types
subst :: Subst -> Type -> Type Source
Apply a substitution function to a type (possibly a type with variables)
deltaSubst :: TypeVarName -> Type -> Subst Source
A delta substitution is one that affects just a single variable.
extend :: Subst -> TypeVarName -> Type -> SuccFail Subst Source
Try to extend a substitution by adding a single variable-value pair
data TypeScheme Source
A TypeScheme (TypeScheme schematicVariables typeExpression) is a sort of type template, in which schematic variables (i.e., type parameters or "generics") are made explicit; any other type variables in the type expression are unknowns
schematicsTS :: TypeScheme -> [TypeVarName] Source
unknownsTS :: TypeScheme -> [TypeVarName] Source
substTS :: Subst -> TypeScheme -> TypeScheme Source
Apply a substitution to a type scheme, taking care to affect only the unknowns, not the schematic variables
type TypeEnv = Map TypeVarName TypeScheme Source
A type environment maps type variable names to type schemes. Oh, is it really type variable names, or just names? It seems to me that in envToTypeEnv, it's function names, instead of type variable names.
install :: TypeEnv -> TypeVarName -> TypeScheme -> TypeEnv Source
Insert a new type variable and its type scheme value
unknownsTE :: TypeEnv -> [TypeVarName] Source
The unknowns of a type environment
data NameSupply Source
A source of variable names
newNameSupply :: TypeVarName -> NameSupply Source
Creates a name supply
nameSupplyNext :: NameSupply -> (TypeVarName, NameSupply) Source
Produces next variable from a name supply
nameSupplyTake :: NameSupply -> Int -> ([TypeVarName], NameSupply) Source
Produces next several variables from a name supply
tcExpr :: TypeEnv -> NameSupply -> Expr -> SuccFail (Subst, Type, NameSupply) Source
Type check an expression
tcExprs :: TypeEnv -> NameSupply -> [Expr] -> SuccFail (Subst, [Type], NameSupply) Source
tcVar :: TypeEnv -> NameSupply -> String -> SuccFail (Subst, Type, NameSupply) Source
Type check a variable (actually the variable name). Find the type scheme associated with the variable in the type environment. Return a "new instance" of the type scheme, in which its schematic variables are replaced by new variables, and the unknowns are left as they are.
newInstance :: NameSupply -> TypeScheme -> (Type, NameSupply) Source
envToTypeEnv :: Env -> TypeEnv Source
Create a TypeEnv from an Env Bindings on the left replace bindings of the same name on the right, if any.
The base type environment, derived from the base environment of the Sifflet language (built-in functions)
fromLambdaType :: Type -> SuccFail ([Type], Type) Source
Convert a function type, such as a -> (b -> c), to a pair consisting of the list of argument types and the result type, such as ([a, b], c).
decideTypes :: String -> Expr -> [String] -> Env -> SuccFail ([Type], Type) Source
Decide the type of a function -- called by the function editor when the Apply button is clicked. decideTypes tries to find the argument types and return type of an expression considered as the body of a function, at the same time checking for consistency of inputs and outputs between the parts of the expression. It returns Succ (argtypes, returntype) if successful; Fail errormessage otherwise.