15 lines
441 B
Haskell
15 lines
441 B
Haskell
module Misc.MonadicRecursionSchemes
|
|
where
|
|
--------------------------------------------------------------------------------
|
|
import Control.Monad
|
|
import Data.Functor.Foldable
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | catamorphism
|
|
cataM :: (Monad m, Traversable (Base t), Recursive t)
|
|
=> (Base t a -> m a) -- ^ algebra
|
|
-> t -> m a
|
|
cataM phi = h
|
|
where h = phi <=< mapM h . project
|
|
|