-- 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.2 -- | 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 var'Key :: forall m_a6Y1 a_a6Y2. Lens' (Var m_a6Y1 a_a6Y2) (Numbering m_a6Y1) var'Name :: Lens' (Var m a) Text var'mkFree :: Lens' (Var m a) (Var m a -> m a) 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. MonadNumbering m => Text -> (Var m a -> m a) -> 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. Monad m => Box m a -> m a box :: MonadNumbering m => a -> Box m a apBox :: MonadNumbering m => Box m (a -> b) -> Box m a -> Box m b boxApply :: Functor m => (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) boxList :: MonadNumbering m => [Box m a] -> Box m [a] boxJoin :: MonadNumbering m => Box m (m a) -> m (Box m a) -- | Variable binding. Essentially, Binder a m b means a -> -- m b. data Binder a m b binder'Name :: forall a_a8Hl m_a8Hm b_a8Hn. Lens' (Binder a_a8Hl m_a8Hm b_a8Hn) Text binder'mkFree :: forall a_a8Hl m_a8Hm b_a8Hn. Lens' (Binder a_a8Hl m_a8Hm b_a8Hn) (Var m_a8Hm a_a8Hl -> m_a8Hm a_a8Hl) binder'Body :: forall a_a8Hl m_a8Hm b_a8Hn b_a9ts. Lens (Binder a_a8Hl m_a8Hm b_a8Hn) (Binder a_a8Hl m_a8Hm b_a9ts) (a_a8Hl -> m_a8Hm b_a8Hn) (a_a8Hl -> m_a8Hm b_a9ts) -- | Variable substitution. subst :: Binder a m b -> a -> m b -- | Smart constructor for Binder. buildBinder :: Var m a -> (a -> m b) -> Binder a m b -- | binding bind :: MonadNumbering m => Var m a -> Box m b -> Box m (Binder a m b) -- | unbinding unbind :: MonadNumbering m => Binder a m b -> m (Var m a, b) -- | Check if two bindings are equal. eqBinder :: MonadNumbering m => (b -> b -> m Bool) -> Binder a m b -> Binder a m b -> m Bool boxBinder :: MonadNumbering m => (b -> m (Box m b)) -> Binder a m b -> m (Box m (Binder a m b)) bindApply :: MonadNumbering m => Box m (Binder a m b) -> Box m a -> m (Box m b) type VarList m a = [Var m a] varList'Keys :: Getter (VarList m a) [Numbering m] varList'Names :: Getter (VarList m a) [Text] varList'Boxes :: Getter (VarList m a) [Box m a] -- | The names of variables. namesOf :: VarList m a -> [Text] -- | Smart constructor for a list of Box. boxVarList :: VarList m a -> [Box m a] -- | Create new variables with given names. newVarList :: MonadNumbering m => [Text] -> (Var m a -> m a) -> m (VarList m a) -- | Essentially, BinderList a m b means [a] -> m b. data BinderList a m b binderList'Names :: forall a_a9u5 m_a9u6 b_a9u7. Lens' (BinderList a_a9u5 m_a9u6 b_a9u7) [Text] binderList'Body :: forall a_a9u5 m_a9u6 b_a9u7 b_a9Rc. Lens (BinderList a_a9u5 m_a9u6 b_a9u7) (BinderList a_a9u5 m_a9u6 b_a9Rc) ([a_a9u5] -> m_a9u6 b_a9u7) ([a_a9u5] -> m_a9u6 b_a9Rc) binderList'mkFree :: forall a_a9u5 m_a9u6 b_a9u7. Lens' (BinderList a_a9u5 m_a9u6 b_a9u7) (Var m_a9u6 a_a9u5 -> m_a9u6 a_a9u5) binderList'Arity :: Getter (BinderList a m b) Int -- | Variable substitution. substList :: BinderList a m b -> [a] -> m b -- | Check if two bindings are equal. eqBinderList :: MonadNumbering m => (b -> b -> m Bool) -> BinderList a m b -> BinderList a m b -> m Bool -- | binding bindList :: MonadNumbering m => VarList m a -> Box m b -> Box m (BinderList a m b) -- | unbinding unbindList :: MonadNumbering m => BinderList a m b -> m (VarList m a, b) boxBinderList :: MonadNumbering m => (b -> m (Box m b)) -> BinderList a m b -> m (Box m (BinderList a m b)) bindListApply :: MonadNumbering m => Box m (BinderList a m b) -> Box m [a] -> m (Box m 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 m => GHC.Base.Functor (Data.Binder.Box m) instance Data.Binder.MonadNumbering m => GHC.Base.Applicative (Data.Binder.Box 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) instance GHC.Base.Functor m => GHC.Base.Functor (Data.Binder.Closure m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Data.Binder.Closure m)