libcspm-1.0.0: A library providing a parser, type checker and evaluator for CSPM.

Safe HaskellNone




freshTypeVar :: MonadIO m => m TypeSource

getType :: Name -> TypeCheckMonad TypeSchemeSource

Get the type of n and throw an exception if it doesn't exist.

setType :: Name -> TypeScheme -> TypeCheckMonad ()Source

Sets the type of n to be t in the current scope only. No unification is performed.

compress :: Type -> TypeCheckMonad TypeSource

Takes a type and compresses the type by reading all type variables and if they point to another type, it returns that type instead.

compressTypeScheme :: TypeScheme -> TypeCheckMonad TypeSchemeSource

Apply compress to the type of a type scheme.

runTypeChecker :: TypeInferenceState -> TypeCheckMonad a -> IO aSource

Runs the typechecker, starting from state st. If any errors are encountered then a SourceError will be thrown with the relevent error messages.

data TypeInferenceState Source




environment :: Environment

The type environment, which is a map from names to types.

srcSpan :: SrcSpan

Location of the current AST element - used for error pretty printing

errorContexts :: [ErrorContext]

Error stack - provides context information for any errors that might be raised

errors :: [ErrorMessage]

Errors that have occured

warnings :: [ErrorMessage]

List of warnings that have occured

unificationStack :: [(Type, Type)]

Stack of attempted unifications - the current one is at the front. In the form (expected, actual).

definitionStack :: [Name]

The stack of names that we are currently type-checking.

inError :: Bool

Are we currently in an error state

symUnificationAllowed :: Bool
comparableForEqualityDataTypes :: [Name]

The set of datatypes that can be compared for equality.

errorOptions :: ErrorOptions

The error options to use

setSrcSpan :: SrcSpan -> TypeCheckMonad a -> TypeCheckMonad aSource

Sets the SrcSpan only within prog.

raiseMessagesAsError :: [Error] -> TypeCheckMonad aSource

Report a message as an error

panic :: String -> aSource

Given a string causes a Panic to be thrown.

errorIfFalse :: Bool -> Error -> TypeCheckMonad ()Source

Report the error if first parameter is False.