-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Variable binding for abstract syntax tree -- -- binder is purely functional implementation of Ocaml's bindlib. -- It follows the style of higher-order abstract syntax, and offers the -- representation of abstract syntax tree. @package binder @version 0.1 -- | binder is purely functional implementation of Ocaml's bindlib. It -- follows the style of higher-order abstract syntax, and offers the -- representation of abstract syntax tree. module Data.Binder -- | Numbering monad. class (Monad m, Ord (Numbering m)) => MonadNumbering m where { type Numbering m :: Type; } numbering :: MonadNumbering m => m (Numbering m) -- | Representation of variable for abstract syntax tree type a -- with base numbering monad m. data Var m a -- | Representation of under-construction things having type a and -- containing variables. data Box m a -- | Typeclass for free variable constructor. class MkFree m a mkFree :: MkFree m a => Var m a -> a var'Key :: forall m_a6Xp a_a6Xq. Lens' (Var m_a6Xp a_a6Xq) (Numbering m_a6Xp) var'Name :: Lens' (Var m a) Text var'Box :: Lens' (Var m a) (Box m a) -- | The name of variable. nameOf :: Var m a -> Text -- | Smart constructor for Box. boxVar :: Var m a -> Box m a -- | Create a new variable with given name. newVar :: forall m a. (MkFree m a, MonadNumbering m) => Text -> m (Var m a) -- | Box is closed if it exposes no free variables. isClosed :: Box m a -> Bool -- | Check if the variable occurs in the box. occur :: MonadNumbering m => Var m a -> Box m b -> Bool -- | Pick out and complete the construction of a. unbox :: forall m a. Box m a -> a box :: MonadNumbering m => a -> Box m a apBox :: MonadNumbering m => Box m (a -> b) -> Box m a -> Box m b boxApply :: (a -> b) -> Box m a -> Box m b boxApply2 :: MonadNumbering m => (a -> b -> c) -> Box m a -> Box m b -> Box m c boxApply3 :: MonadNumbering m => (a -> b -> c -> d) -> Box m a -> Box m b -> Box m c -> Box m d boxApply4 :: MonadNumbering m => (a -> b -> c -> d -> e) -> Box m a -> Box m b -> Box m c -> Box m d -> Box m e boxPair :: MonadNumbering m => Box m a -> Box m b -> Box m (a, b) boxTriple :: MonadNumbering m => Box m a -> Box m b -> Box m c -> Box m (a, b, c) boxT :: (MonadNumbering m, Traversable t) => t (Box m a) -> Box m (t a) -- | Variable binding. Essentially, Binder a b means a -> -- b. data Binder a b binder'Name :: forall a_a8FU b_a8FV. Lens' (Binder a_a8FU b_a8FV) Text binder'Body :: forall a_a8FU b_a8FV a_a9mq b_a9mr. Lens (Binder a_a8FU b_a8FV) (Binder a_a9mq b_a9mr) (a_a8FU -> b_a8FV) (a_a9mq -> b_a9mr) -- | Variable substitution. subst :: Binder a b -> a -> b -- | Smart constructor for Binder. buildBinder :: Var m a -> (a -> b) -> Binder a b -- | binding bind :: (MkFree m a, MonadNumbering m) => Var m a -> Box m b -> Box m (Binder a b) -- | unbinding unbind :: (MkFree m a, MonadNumbering m) => Binder a b -> m (Var m a, b) -- | Check if two bindings are equal. eqBinder :: (MkFree m a, MonadNumbering m) => (b -> b -> m Bool) -> Binder a b -> Binder a b -> m Bool boxBinder :: (MkFree m a, MonadNumbering m) => (b -> m (Box m b)) -> Binder a b -> m (Box m (Binder a b)) instance GHC.Show.Show (Data.Binder.Var m a) instance GHC.Show.Show (Data.Binder.VarBody m a) instance GHC.Show.Show (Data.Binder.AnyVar m) instance GHC.Base.Functor (Data.Binder.Box m) instance Data.Binder.MonadNumbering m => GHC.Base.Applicative (Data.Binder.Box m) instance GHC.Base.Functor (Data.Binder.Closure m) instance GHC.Base.Applicative (Data.Binder.Closure m) instance Data.Binder.MonadNumbering m => GHC.Classes.Eq (Data.Binder.Var m a) instance Data.Binder.MonadNumbering m => GHC.Classes.Ord (Data.Binder.Var m a)