sifflet-2.3.0: Simple, visual, functional language for learning about recursion.

Safe HaskellNone




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.

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)

substComp :: Subst -> Subst -> Subst Source

Composing two substitutions

idSubst :: Subst Source

Identity substitution

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


TypeScheme [TypeVarName] Type 

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


NameSupply TypeVarName Int 

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

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.

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.

baseTypeEnv :: TypeEnv Source

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.