unification-fd-0.11.0: Simple generic unification algorithms.
CopyrightCopyright (c) 2007--2015 wren gayle romano
LicenseBSD
Maintainerwren@community.haskell.org
Stabilityexperimental
Portabilitysemi-portable (MPTCs,...)
Safe HaskellNone
LanguageHaskell98

Control.Unification.IntVar

Description

This module defines a state monad for functional pointers represented by integers as keys into an IntMap. This technique was independently discovered by Dijkstra et al. This module extends the approach by using a state monad transformer, which can be made into a backtracking state monad by setting the underlying monad to some MonadLogic (part of the logict library, described by Kiselyov et al.).

  • Atze Dijkstra, Arie Middelkoop, S. Doaitse Swierstra (2008) Efficient Functional Unification and Substitution, Technical Report UU-CS-2008-027, Utrecht University.
  • Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry (2005) Backtracking, Interleaving, and Terminating Monad Transformers, ICFP.
Synopsis

Documentation

newtype IntVar Source #

A "mutable" unification variable implemented by an integer. This provides an entirely pure alternative to truly mutable alternatives (like STVar), which can make backtracking easier.

N.B., because this implementation is pure, we can use it for both ranked and unranked monads.

Constructors

IntVar Int 

Instances

Instances details
Eq IntVar Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

(==) :: IntVar -> IntVar -> Bool #

(/=) :: IntVar -> IntVar -> Bool #

Show IntVar Source # 
Instance details

Defined in Control.Unification.IntVar

Variable IntVar Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

getVarID :: IntVar -> Int Source #

(Unifiable t, Applicative m, Monad m) => RankedBindingMonad t IntVar (IntRBindingT t m) Source # 
Instance details

Defined in Control.Unification.Ranked.IntVar

(Unifiable t, Applicative m, Monad m) => BindingMonad t IntVar (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

(Unifiable t, Applicative m, Monad m) => BindingMonad t IntVar (IntRBindingT t m) Source # 
Instance details

Defined in Control.Unification.Ranked.IntVar

data IntBindingState t Source #

Binding state for IntVar.

Instances

Instances details
Show (t (UTerm t IntVar)) => Show (IntBindingState t) Source # 
Instance details

Defined in Control.Unification.IntVar

Monad m => MonadState (IntBindingState t) (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

data IntBindingT t m a Source #

A monad for storing IntVar bindings, implemented as a StateT. For a plain state monad, set m = Identity; for a backtracking state monad, set m = Logic.

Instances

Instances details
(Unifiable t, Applicative m, Monad m) => BindingMonad t IntVar (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

MonadTrans (IntBindingT t) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

lift :: Monad m => m a -> IntBindingT t m a #

Monad m => MonadState (IntBindingState t) (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Monad m => Monad (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

(>>=) :: IntBindingT t m a -> (a -> IntBindingT t m b) -> IntBindingT t m b #

(>>) :: IntBindingT t m a -> IntBindingT t m b -> IntBindingT t m b #

return :: a -> IntBindingT t m a #

Functor m => Functor (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

fmap :: (a -> b) -> IntBindingT t m a -> IntBindingT t m b #

(<$) :: a -> IntBindingT t m b -> IntBindingT t m a #

(Functor m, Monad m) => Applicative (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

pure :: a -> IntBindingT t m a #

(<*>) :: IntBindingT t m (a -> b) -> IntBindingT t m a -> IntBindingT t m b #

liftA2 :: (a -> b -> c) -> IntBindingT t m a -> IntBindingT t m b -> IntBindingT t m c #

(*>) :: IntBindingT t m a -> IntBindingT t m b -> IntBindingT t m b #

(<*) :: IntBindingT t m a -> IntBindingT t m b -> IntBindingT t m a #

(Functor m, MonadPlus m) => Alternative (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

empty :: IntBindingT t m a #

(<|>) :: IntBindingT t m a -> IntBindingT t m a -> IntBindingT t m a #

some :: IntBindingT t m a -> IntBindingT t m [a] #

many :: IntBindingT t m a -> IntBindingT t m [a] #

MonadPlus m => MonadPlus (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

mzero :: IntBindingT t m a #

mplus :: IntBindingT t m a -> IntBindingT t m a -> IntBindingT t m a #

MonadLogic m => MonadLogic (IntBindingT t m) Source # 
Instance details

Defined in Control.Unification.IntVar

Methods

msplit :: IntBindingT t m a -> IntBindingT t m (Maybe (a, IntBindingT t m a)) #

interleave :: IntBindingT t m a -> IntBindingT t m a -> IntBindingT t m a #

(>>-) :: IntBindingT t m a -> (a -> IntBindingT t m b) -> IntBindingT t m b #

ifte :: IntBindingT t m a -> (a -> IntBindingT t m b) -> IntBindingT t m b -> IntBindingT t m b #

once :: IntBindingT t m a -> IntBindingT t m a #

lnot :: IntBindingT t m a -> IntBindingT t m () #

evalIntBindingT :: Monad m => IntBindingT t m a -> m a Source #

N.B., you should explicitly apply bindings before calling this function, or else the bindings will be lost