-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Generalized bananas, lenses and barbed wire
--   
--   Generalized bananas, lenses and barbed wire
@package recursion-schemes
@version 4.1.2


module Data.Functor.Foldable
newtype Fix f
Fix :: (f (Fix f)) -> Fix f
newtype Mu f
Mu :: (forall a. (f a -> a) -> a) -> Mu f
data Nu f
Nu :: (a -> f a) -> a -> Nu f
class Functor (Base t) => Foldable t where cata f = c where c = f . fmap c . project para t = p where p x = t . fmap ((,) <*> p) $ project x gpara t = gzygo embed t prepro e f = c where c = f . fmap (c . cata (embed . e)) . project gprepro k e f = extract . c where c = fmap f . k . fmap (duplicate . c . cata (embed . e)) . project
project :: Foldable t => t -> Base t t
cata :: Foldable t => (Base t a -> a) -> t -> a
para :: Foldable t => (Base t (t, a) -> a) -> t -> a
gpara :: (Foldable t, Unfoldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> (Base t (EnvT t w a) -> a) -> t -> a

-- | Fokkinga's prepromorphism
prepro :: (Foldable t, Unfoldable t) => (forall b. Base t b -> Base t b) -> (Base t a -> a) -> t -> a
gprepro :: (Foldable t, Unfoldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> (forall c. Base t c -> Base t c) -> (Base t (w a) -> a) -> t -> a
gapo :: Unfoldable t => (b -> Base t b) -> (a -> Base t (Either b a)) -> a -> t

-- | A generalized catamorphism
gcata :: (Foldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> (Base t (w a) -> a) -> t -> a
zygo :: Foldable t => (Base t b -> b) -> (Base t (b, a) -> a) -> t -> a
gzygo :: (Foldable t, Comonad w) => (Base t b -> b) -> (forall c. Base t (w c) -> w (Base t c)) -> (Base t (EnvT b w a) -> a) -> t -> a

-- | Course-of-value iteration
histo :: Foldable t => (Base t (Cofree (Base t) a) -> a) -> t -> a
ghisto :: (Foldable t, Functor h) => (forall b. Base t (h b) -> h (Base t b)) -> (Base t (Cofree h a) -> a) -> t -> a
futu :: Unfoldable t => (a -> Base t (Free (Base t) a)) -> a -> t
distCata :: Functor f => f (Identity a) -> Identity (f a)
distPara :: Unfoldable t => Base t (t, a) -> (t, Base t a)
distParaT :: (Unfoldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> Base t (EnvT t w a) -> EnvT t w (Base t a)
distZygo :: Functor f => (f b -> b) -> (f (b, a) -> (b, f a))
distZygoT :: (Functor f, Comonad w) => (f b -> b) -> (forall c. f (w c) -> w (f c)) -> f (EnvT b w a) -> EnvT b w (f a)
distHisto :: Functor f => f (Cofree f a) -> Cofree f (f a)
distGHisto :: (Functor f, Functor h) => (forall b. f (h b) -> h (f b)) -> f (Cofree h a) -> Cofree h (f a)
distFutu :: Functor f => Free f (f a) -> f (Free f a)
distGFutu :: (Functor f, Functor h) => (forall b. h (f b) -> f (h b)) -> Free h (f a) -> f (Free h a)
class Functor (Base t) => Unfoldable t where ana g = a where a = embed . fmap a . g apo g = a where a = embed . (fmap (either id a)) . g postpro e g = a where a = embed . fmap (ana (e . project) . a) . g gpostpro k e g = a . return where a = embed . fmap (ana (e . project) . a . join) . k . liftM g
embed :: Unfoldable t => Base t t -> t
ana :: Unfoldable t => (a -> Base t a) -> a -> t
apo :: (Unfoldable t, Foldable t) => (a -> Base t (Either t a)) -> a -> t

-- | Fokkinga's postpromorphism
postpro :: (Unfoldable t, Foldable t) => (forall b. Base t b -> Base t b) -> (a -> Base t a) -> a -> t

-- | A generalized postpromorphism
gpostpro :: (Unfoldable t, Foldable t, Monad m) => (forall b. m (Base t b) -> Base t (m b)) -> (forall c. Base t c -> Base t c) -> (a -> Base t (m a)) -> a -> t

-- | A generalized anamorphism
gana :: (Unfoldable t, Monad m) => (forall b. m (Base t b) -> Base t (m b)) -> (a -> Base t (m a)) -> a -> t
distAna :: Functor f => Identity (f a) -> f (Identity a)
distApo :: Foldable t => Either t (Base t a) -> Base t (Either t a)
distGApo :: Functor f => (b -> f b) -> Either b (f a) -> f (Either b a)
hylo :: Functor f => (f b -> b) -> (a -> f a) -> a -> b

-- | A generalized hylomorphism
ghylo :: (Comonad w, Functor f, Monad m) => (forall c. f (w c) -> w (f c)) -> (forall d. m (f d) -> f (m d)) -> (f (w b) -> b) -> (a -> f (m a)) -> a -> b
refix :: (Foldable s, Unfoldable t, Base s ~ Base t) => s -> t
fold :: Foldable t => (Base t a -> a) -> t -> a

-- | A generalized catamorphism
gfold :: (Foldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> (Base t (w a) -> a) -> t -> a
unfold :: Unfoldable t => (a -> Base t a) -> a -> t

-- | A generalized anamorphism
gunfold :: (Unfoldable t, Monad m) => (forall b. m (Base t b) -> Base t (m b)) -> (a -> Base t (m a)) -> a -> t
refold :: Functor f => (f b -> b) -> (a -> f a) -> a -> b

-- | A generalized hylomorphism
grefold :: (Comonad w, Functor f, Monad m) => (forall c. f (w c) -> w (f c)) -> (forall d. m (f d) -> f (m d)) -> (f (w b) -> b) -> (a -> f (m a)) -> a -> b

-- | Mendler-style iteration
mcata :: (forall y. (y -> c) -> f y -> c) -> Fix f -> c

-- | Mendler-style course-of-value iteration
mhisto :: (forall y. (y -> c) -> (y -> f y) -> f y -> c) -> Fix f -> c

-- | Elgot algebras
elgot :: Functor f => (f a -> a) -> (b -> Either a (f b)) -> b -> a

-- | Elgot coalgebras:
--   <a>http://comonad.com/reader/2008/elgot-coalgebras/</a>
coelgot :: Functor f => ((a, f b) -> b) -> (a -> f a) -> a -> b

-- | Zygohistomorphic prepromorphisms:
--   
--   A corrected and modernized version of
--   <a>http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms</a>
zygoHistoPrepro :: (Unfoldable t, Foldable t) => (Base t b -> b) -> (forall c. Base t c -> Base t c) -> (Base t (EnvT b (Cofree (Base t)) a) -> a) -> t -> a
instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Data.Functor.Foldable.Prim [a] b)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Functor.Foldable.Prim [a] b)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Data.Functor.Foldable.Prim [a] b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Functor.Foldable.Prim [a] b)
instance GHC.Classes.Eq (f (Data.Functor.Foldable.Fix f)) => GHC.Classes.Eq (Data.Functor.Foldable.Fix f)
instance GHC.Classes.Ord (f (Data.Functor.Foldable.Fix f)) => GHC.Classes.Ord (Data.Functor.Foldable.Fix f)
instance GHC.Show.Show (f (Data.Functor.Foldable.Fix f)) => GHC.Show.Show (Data.Functor.Foldable.Fix f)
instance GHC.Read.Read (f (Data.Functor.Foldable.Fix f)) => GHC.Read.Read (Data.Functor.Foldable.Fix f)
instance GHC.Base.Functor (Data.Functor.Foldable.Prim [a])
instance Data.Functor.Foldable.Foldable [a]
instance Data.Functor.Foldable.Unfoldable [a]
instance Data.Functor.Foldable.Foldable (GHC.Base.Maybe a)
instance Data.Functor.Foldable.Unfoldable (GHC.Base.Maybe a)
instance Data.Functor.Foldable.Foldable (Data.Either.Either a b)
instance Data.Functor.Foldable.Unfoldable (Data.Either.Either a b)
instance GHC.Base.Functor f => Data.Functor.Foldable.Foldable (Data.Functor.Foldable.Fix f)
instance GHC.Base.Functor f => Data.Functor.Foldable.Unfoldable (Data.Functor.Foldable.Fix f)
instance GHC.Base.Functor f => Data.Functor.Foldable.Foldable (Data.Functor.Foldable.Mu f)
instance GHC.Base.Functor f => Data.Functor.Foldable.Unfoldable (Data.Functor.Foldable.Mu f)
instance (GHC.Base.Functor f, GHC.Classes.Eq (f (Data.Functor.Foldable.Fix f)), GHC.Classes.Eq (Data.Functor.Foldable.Fix f)) => GHC.Classes.Eq (Data.Functor.Foldable.Mu f)
instance (GHC.Base.Functor f, GHC.Classes.Ord (f (Data.Functor.Foldable.Fix f)), GHC.Classes.Ord (Data.Functor.Foldable.Fix f)) => GHC.Classes.Ord (Data.Functor.Foldable.Mu f)
instance (GHC.Base.Functor f, GHC.Show.Show (f (Data.Functor.Foldable.Fix f)), GHC.Show.Show (Data.Functor.Foldable.Fix f)) => GHC.Show.Show (Data.Functor.Foldable.Mu f)
instance (GHC.Base.Functor f, GHC.Read.Read (f (Data.Functor.Foldable.Fix f)), GHC.Read.Read (Data.Functor.Foldable.Fix f)) => GHC.Read.Read (Data.Functor.Foldable.Mu f)
instance GHC.Base.Functor f => Data.Functor.Foldable.Unfoldable (Data.Functor.Foldable.Nu f)
instance GHC.Base.Functor f => Data.Functor.Foldable.Foldable (Data.Functor.Foldable.Nu f)
instance (GHC.Base.Functor f, GHC.Classes.Eq (f (Data.Functor.Foldable.Fix f)), GHC.Classes.Eq (Data.Functor.Foldable.Fix f)) => GHC.Classes.Eq (Data.Functor.Foldable.Nu f)
instance (GHC.Base.Functor f, GHC.Classes.Ord (f (Data.Functor.Foldable.Fix f)), GHC.Classes.Ord (Data.Functor.Foldable.Fix f)) => GHC.Classes.Ord (Data.Functor.Foldable.Nu f)
instance (GHC.Base.Functor f, GHC.Show.Show (f (Data.Functor.Foldable.Fix f)), GHC.Show.Show (Data.Functor.Foldable.Fix f)) => GHC.Show.Show (Data.Functor.Foldable.Nu f)
instance (GHC.Base.Functor f, GHC.Read.Read (f (Data.Functor.Foldable.Fix f)), GHC.Read.Read (Data.Functor.Foldable.Fix f)) => GHC.Read.Read (Data.Functor.Foldable.Nu f)
