purescript-0.7.2.0: PureScript Programming Language Compiler

Safe HaskellNone
LanguageHaskell98

Control.Monad.Unify

Description

 

Synopsis

Documentation

type Unknown = Int Source

Untyped unification variables

class Partial t where Source

A type which can contain unification variables

Instances

class Partial t => Unifiable m t | t -> m where Source

Identifies types which support unification

Methods

(=?=) :: t -> t -> UnifyT t m () Source

data Substitution t Source

A substitution maintains a mapping from unification variables to their values

Constructors

Substitution 

Instances

data UnifyState t Source

State required for type checking

Constructors

UnifyState 

Fields

unifyNextVar :: Int

The next fresh unification variable

unifyCurrentSubstitution :: Substitution t

The current substitution

defaultUnifyState :: Partial t => UnifyState t Source

An empty UnifyState

newtype UnifyT t m a Source

The type checking monad, which provides the state of the type checker, and error reporting capabilities

Constructors

UnifyT 

Fields

unUnify :: StateT (UnifyState t) m a
 

Instances

MonadError e m => MonadError e (UnifyT t m) 
MonadState s m => MonadState s (UnifyT t m) 
(Functor m, MonadPlus m) => Alternative (UnifyT t m) 
Monad m => Monad (UnifyT t m) 
Functor m => Functor (UnifyT t m) 
MonadPlus m => MonadPlus (UnifyT t m) 
(Monad m, Functor m) => Applicative (UnifyT t m) 

runUnify :: UnifyState t -> UnifyT t m a -> m (a, UnifyState t) Source

Run a computation in the Unify monad, failing with an error, or succeeding with a return value and the new next unification variable

substituteOne :: Partial t => Unknown -> t -> Substitution t Source

Substitute a single unification variable

(=:=) :: (UnificationError t e, Monad m, MonadError e m, Unifiable m t) => Unknown -> t -> UnifyT t m () Source

Replace a unification variable with the specified value in the current substitution

occursCheck :: (UnificationError t e, Monad m, MonadError e m, Partial t) => Unknown -> t -> UnifyT t m () Source

Perform the occurs check, to make sure a unification variable does not occur inside a value

fresh' :: Monad m => UnifyT t m Unknown Source

Generate a fresh untyped unification variable

fresh :: (Monad m, Partial t) => UnifyT t m t Source

Generate a fresh unification variable at a specific type