Language.PureScript.TypeChecker.Skolems

purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.TypeChecker.Skolems

Description

Functions relating to skolemization used during typechecking

Synopsis

- newSkolemConstant :: MonadState CheckState m => m Int
- introduceSkolemScope :: MonadState CheckState m => Type a -> m (Type a)
- newSkolemScope :: MonadState CheckState m => m SkolemScope
- skolemize :: a -> Text -> Maybe (Type a) -> Int -> SkolemScope -> Type a -> Type a
- skolemizeTypesInValue :: SourceAnn -> Text -> Maybe SourceType -> Int -> SkolemScope -> Expr -> Expr
- skolemEscapeCheck :: MonadError MultipleErrors m => Expr -> m ()

# Documentation

newSkolemConstant :: MonadState CheckState m => m Int #

Generate a new skolem constant

introduceSkolemScope :: MonadState CheckState m => Type a -> m (Type a) #

Introduce skolem scope at every occurrence of a ForAll

newSkolemScope :: MonadState CheckState m => m SkolemScope #

Generate a new skolem scope

skolemize :: a -> Text -> Maybe (Type a) -> Int -> SkolemScope -> Type a -> Type a #

Skolemize a type variable by replacing its instances with fresh skolem constants

skolemizeTypesInValue :: SourceAnn -> Text -> Maybe SourceType -> Int -> SkolemScope -> Expr -> Expr #

This function skolemizes type variables appearing in any type signatures or `DeferredDictionary` placeholders. These type variables are the only places where scoped type variables can appear in expressions.

skolemEscapeCheck :: MonadError MultipleErrors m => Expr -> m () #

Ensure skolem variables do not escape their scope

Every skolem variable is created when a `ForAll` type is skolemized. This determines the scope of that skolem variable, which is copied from the `SkolemScope` field of the `ForAll` constructor.

This function traverses the tree top-down, and collects any `SkolemScope`s introduced by `ForAll`s. If a `Skolem` is encountered whose `SkolemScope` is not in the current list, then we have found an escaped skolem variable.