monadic-recursion-schemes 0.1.9.0 → 0.1.9.1
raw patch · 3 files changed
+38/−26 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- monadic-recursion-schemes.cabal +2/−1
- src/Data/Functor/Foldable/Monadic.hs +32/−25
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for monadic-recursion-schemes +## 0.1.9.1 -- 2020-05-17++* no warning at build time.+ ## 0.1.9.0 -- 2020-05-16 * add iterateM (as dual of cascadeM)
monadic-recursion-schemes.cabal view
@@ -4,7 +4,7 @@ -- http://haskell.org/cabal/users-guide/ name: monadic-recursion-schemes-version: 0.1.9.0+version: 0.1.9.1 synopsis: Recursion Schemes for Monadic version. description: Yet another recursion schemes for monadic style, depends on recursion-schemes. homepage: https://github.com/cutsea110/monadic-recursion-schemes.git@@ -37,6 +37,7 @@ free >=5.1.3 hs-source-dirs: src default-language: Haskell2010+ ghc-options: -Wall test-suite monadic-recursion-schemes-test default-language: Haskell2010
src/Data/Functor/Foldable/Monadic.hs view
@@ -1,40 +1,47 @@-{-# LANGUAGE GADTs #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DeriveFoldable #-}+{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} module Data.Functor.Foldable.Monadic- ( cataM, anaM- , paraM, apoM- , histoM, futuM- , histoM', futuM'- , zygoM, cozygoM+ ( -- * Folding+ cataM+ , preproM+ , paraM+ , zygoM+ , histoM, histoM'+ , dynaM, dynaM', dynaM''++ -- * Unfolding+ , anaM+ , postproM+ , apoM+ , cozygoM+ , futuM, futuM'+ , codynaM, codynaM', codynaM''++ -- * Refolding , hyloM, metaM , hyloM', metaM' , chronoM, cochronoM , chronoM' -- cochronoM'- , dynaM, codynaM- , dynaM', codynaM'- , dynaM'', codynaM''++ -- * Others , mutuM, comutuM , mutuM', comutuM'- , preproM, postproM , cascadeM, iterateM ) where import Control.Comonad (Comonad (..)) import Control.Comonad.Cofree (Cofree (..))-import qualified Control.Comonad.Trans.Cofree as Cf (CofreeF (..))+import qualified Control.Comonad.Trans.Cofree as CF (CofreeF (..)) import Control.Monad ((<=<), liftM2) import Control.Monad.Free (Free (..))-import qualified Control.Monad.Trans.Free as Fr (FreeF (..))-import Control.Monad.Trans.Class (lift)-import Control.Monad.Trans.Reader (ReaderT, ask, runReaderT)-import Data.Functor.Foldable (Recursive (..), Corecursive (..), Base, Fix (..))-+import qualified Control.Monad.Trans.Free as FR (FreeF (..))+import Data.Functor.Foldable (Recursive (..), Corecursive (..), Base) -- | catamorphism cataM :: (Monad m, Traversable (Base t), Recursive t)@@ -70,7 +77,7 @@ -> t -> m a histoM phi = h where h = phi <=< mapM f . project- f = anaM (liftM2 (Cf.:<) <$> h <*> return . project)+ f = anaM (liftM2 (CF.:<) <$> h <*> return . project) -- | histomorphism on catamorphism variant histoM' :: (Monad m, Traversable (Base t), Recursive t)@@ -86,8 +93,8 @@ futuM psi = h where h = return . embed <=< mapM f <=< psi f = cataM $ \case- Fr.Pure a -> h a- Fr.Free fb -> return (embed fb)+ FR.Pure a -> h a+ FR.Free fb -> return (embed fb) -- | futumorphism on anamorphism variant futuM' :: (Monad m, Traversable (Base t), Corecursive t)@@ -133,7 +140,7 @@ => (Base t t -> m t) -- ^ algebra -> (s -> m (Base s s)) -- ^ coalgebra -> s -> m t-metaM phi psi = h+metaM _phi _psi = h where h = return . embed <=< mapM h . project -- | metamorphism on combination variant of cata to ana@@ -217,7 +224,7 @@ => (Base t (a, b) -> m b) -- ^ algebra -> (Base t (a, b) -> m a) -- ^ algebra -> t -> m b-mutuM g f = v g f+mutuM q p = v q p where u f g = f <=< mapM (liftM2 (,) <$> u f g <*> v g f) . project v g f = g <=< mapM (liftM2 (,) <$> u f g <*> v g f) . project @@ -233,7 +240,7 @@ => (b -> m (Base t (Either a b))) -- ^ coalgebra -> (a -> m (Base t (Either a b))) -- ^ coalgebra -> b -> m t-comutuM g f = v g f+comutuM q p = v q p where u f g = fmap embed . mapM (either (u f g) (v g f)) <=< f v g f = fmap embed . mapM (either (u f g) (v g f)) <=< g