-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A recursion schemes library for GHC.
--
-- A performant recursion schemes library for Haskell with no
-- dependencies
@package recursion
@version 0.1.0.0
module Control.Recursion
class Base t (f :: * -> *)
class (Functor f, Base t f) => Recursive f t
project :: Recursive f t => t -> f t
class (Functor f, Base t f) => Corecursive f t
embed :: Corecursive f t => f t -> t
newtype Fix f
Fix :: f (Fix f) -> Fix f
[unFix] :: Fix f -> f (Fix f)
-- | Catamorphism. Folds a structure. (see here)
cata :: (Recursive f t) => (f a -> a) -> t -> a
-- | Anamorphism, meant to build up a structure recursively.
ana :: (Corecursive f t) => (a -> f a) -> a -> t
-- | Hylomorphism; fold a structure while buildiung it up.
hylo :: Functor f => (f b -> b) -> (a -> f a) -> a -> b
-- | Prepromorphism. Fold a structure while applying a natural
-- transformation at each step.
prepro :: (Recursive f t, Corecursive f t) => (f t -> f t) -> (f a -> a) -> t -> a
-- | Postpromorphism. Build up a structure, applying a natural
-- transformation along the way.
postpro :: (Recursive f t, Corecursive f t) => (f t -> f t) -> (a -> f a) -> a -> t
-- | A mutumorphism.
mutu :: (Recursive f t) => (f (a, a) -> a) -> (f (a, a) -> a) -> t -> a
-- | Zygomorphism (see here for a neat example)
zygo :: (Recursive f t) => (f b -> b) -> (f (b, a) -> a) -> t -> a
-- | Paramorphism
para :: (Recursive f t, Corecursive f t) => (f (t, a) -> a) -> t -> a
-- | Apomorphism
apo :: (Corecursive f t) => (a -> f (Either t a)) -> a -> t
-- | Elgot algebra (see this paper)
elgot :: Functor f => (f a -> a) -> (b -> Either a (f b)) -> b -> a
-- | Elgot coalgebra
coelgot :: Functor f => ((a, f b) -> b) -> (a -> f a) -> a -> b
-- | Anamorphism that allows shortcuts.
micro :: (Corecursive f a) => (b -> Either a (f b)) -> b -> a
-- | Gibbons' metamorphism. Tear down a structure, transform it, and then
-- build up a new structure
meta :: (Corecursive f t', Recursive g t) => (a -> f a) -> (b -> a) -> (g b -> b) -> t -> t'
-- | Erwig's metamorphism. Essentially a hylomorphism with a natural
-- transformation in between. This allows us to use more than one functor
-- in a hylomorphism.
meta' :: (Functor g) => (f a -> a) -> (forall c. g c -> f c) -> (b -> g b) -> b -> a
-- | Mendler's histomorphism
mhisto :: (forall y. ((y -> c) -> (y -> f y) -> f y -> c)) -> Fix f -> c
-- | Mendler's catamorphism
mcata :: (forall y. ((y -> c) -> f y -> c)) -> Fix f -> c
cataM :: (Recursive f t, Traversable f, Monad m) => (f a -> m a) -> t -> m a
anaM :: (Corecursive f t, Traversable f, Monad m) => (a -> m (f a)) -> a -> m t
hyloM :: (Traversable f, Monad m) => (f b -> m b) -> (a -> m (f a)) -> a -> m b
lambek :: (Recursive f t, Corecursive f t) => (t -> f t)
colambek :: (Recursive f t, Corecursive f t) => (f t -> t)
instance GHC.Base.Functor (Control.Recursion.ListF a)
instance Control.Recursion.Base (Control.Recursion.Fix t) f
instance Control.Recursion.Base b (Control.Recursion.ListF a)
instance Control.Recursion.Recursive (Control.Recursion.ListF a) [a]
instance Control.Recursion.Corecursive (Control.Recursion.ListF a) [a]
instance Control.Recursion.Corecursive GHC.Base.Maybe GHC.Natural.Natural
instance Control.Recursion.Recursive GHC.Base.Maybe GHC.Natural.Natural
instance Control.Recursion.Base GHC.Natural.Natural GHC.Base.Maybe