packages feed

recursion-schemes 0.2.1 → 0.2.2

raw patch · 2 files changed

+43/−1 lines, 2 files

Files

Data/Functor/Foldable.hs view
@@ -93,6 +93,25 @@   gpara :: (Unfoldable t, Comonad w) => (forall b. Base t (w b) -> w (Base t b)) -> (Base t (EnvT t w a) -> a) -> t -> a   gpara t = gzygo embed t +  -- | Fokkinga's prepromorphism+  prepro +    :: Unfoldable t +    => (forall b. Base t b -> Base t b) +    -> (Base t a -> a) +    -> t +    -> a+  prepro e f = c where c = f . fmap (c . cata (embed . e)) . project++  --- | A generalized prepromorphism+  gprepro +    :: (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+  gprepro k e f = extract . c where c = fmap f . k . fmap (duplicate . c . cata (embed . e)) . project+ distPara :: Unfoldable t => Base t (t, a) -> (t, Base t a) distPara = distZygo embed @@ -109,6 +128,25 @@    apo :: Foldable t => (a -> Base t (Either t a)) -> a -> t   apo = gapo project++  -- | Fokkinga's postpromorphism+  postpro +    :: Foldable t+    => (forall b. Base t b -> Base t b) -- natural transformation+    -> (a -> Base t a)                  -- a (Base t)-coalgebra+    -> a                                -- seed+    -> t+  postpro e g = a where a = embed . fmap (ana (e . project) . a) . g+  +  -- | A generalized postpromorphism+  gpostpro +    :: (Foldable t, Monad m)+    => (forall b. m (Base t b) -> Base t (m b)) -- distributive law+    -> (forall c. Base t c -> Base t c)         -- natural transformation+    -> (a -> Base t (m a))                      -- a (Base t)-m-coalgebra+    -> a                                        -- seed+    -> t+  gpostpro k e g = a . return where a = embed . fmap (ana (e . project) . a . join) . k . liftM g  hylo :: Functor f => (f b -> b) -> (a -> f a) -> a -> b hylo f g = h where h = f . fmap h . g
recursion-schemes.cabal view
@@ -1,6 +1,6 @@ name:          recursion-schemes category:      Control, Recursion-version:       0.2.1+version:       0.2.2 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -13,6 +13,10 @@ description:      Generalized bananas, lenses and barbed wire   . +  /Changes since 0.2.1/:+  .+  * Added (generalized) prepro- and postpro- morphisms+  .   /Changes since 0.2/:   .   * Added Elgot (co)algebras