packages feed

recursion-schemes 0.2.2 → 0.3.0

raw patch · 2 files changed

+28/−5 lines, 2 files

Files

Data/Functor/Foldable.hs view
@@ -34,6 +34,7 @@   , distZygo   , distZygoT   , distHisto+  , distGHisto   -- * Unfolding   , Unfoldable(..)   -- ** Combinators@@ -57,6 +58,8 @@   -- * Elgot (co)algebras   , elgot   , coelgot+  -- * Zygohistomorphic prepromorphisms+  , zygoHistoPrepro   ) where  import Control.Applicative@@ -378,14 +381,17 @@  -- | Course-of-value iteration histo :: Foldable t => (Base t (Stream (Base t) a) -> a) -> t -> a-histo = gfold (distHisto id)+histo = gcata distHisto  ghisto :: (Foldable t, Functor h) => (forall b. Base t (h b) -> h (Base t b)) -> (Base t (Stream h a) -> a) -> t -> a-ghisto g = gfold (distHisto g)+ghisto g = gcata (distGHisto g) -distHisto :: (Functor f, Functor h) => (forall b. f (h b) -> h (f b)) -> f (Stream h a) -> Stream h (f a)-distHisto k = Stream.unfold (\as -> (Stream.head <$> as, k (Stream.tail <$> as)))+distHisto :: Functor f => f (Stream f a) -> Stream f (f a)+distHisto = distGHisto id +distGHisto :: (Functor f, Functor h) => (forall b. f (h b) -> h (f b)) -> f (Stream h a) -> Stream h (f a)+distGHisto k = Stream.unfold (\as -> (Stream.head <$> as, k (Stream.tail <$> as)))+ -- TODO: futu & chrono, these require Free monads  -- TODO: distGApoT, requires EitherT @@ -404,3 +410,15 @@ -- | Elgot coalgebras: <http://comonad.com/reader/2008/elgot-coalgebras/> coelgot :: Functor f => ((a, f b) -> b) -> (a -> f a) -> a -> b coelgot phi psi = h where h = phi . (id &&& fmap h . psi)++-- | Zygohistomorphic prepromorphisms:+-- +-- A corrected and modernized version of <http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms>+zygoHistoPrepro+  :: (Unfoldable t, Foldable t) +  => (Base t b -> b)+  -> (forall c. Base t c -> Base t c)+  -> (Base t (EnvT b (Stream (Base t)) a) -> a)+  -> t+  -> a+zygoHistoPrepro f = gprepro (distZygoT f distHisto)
recursion-schemes.cabal view
@@ -1,6 +1,6 @@ name:          recursion-schemes category:      Control, Recursion-version:       0.2.2+version:       0.3.0 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -13,6 +13,11 @@ description:      Generalized bananas, lenses and barbed wire   . +  /Changes since 0.2.2/:+  .+  * Split distHisto from distGHisto+  * Added zygohistomorphic prepromorphisms+  .   /Changes since 0.2.1/:   .   * Added (generalized) prepro- and postpro- morphisms