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
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.
A "mutable" unification variable implemented by an integer.
This provides an entirely pure alternative to truly mutable
STVar), which can make backtracking easier.
N.B., because this implementation is pure, we can use it for both ranked and unranked monads.
Binding state for
|(Unifiable t, Applicative m, Monad m) => BindingMonad t IntVar (IntBindingT t m)|
|MonadTrans (IntBindingT t)|
|Monad m => MonadState (IntBindingState t) (IntBindingT t m)|
|Monad m => Monad (IntBindingT t m)|
|Functor m => Functor (IntBindingT t m)|
|MonadPlus m => MonadPlus (IntBindingT t m)|
|(Functor m, Monad m) => Applicative (IntBindingT t m)|
|(Functor m, MonadPlus m) => Alternative (IntBindingT t m)|
|MonadLogic m => MonadLogic (IntBindingT t m)|
N.B., you should explicitly apply bindings before calling this function, or else the bindings will be lost