Files
rlp/src/Misc/MonadicRecursionSchemes.hs
2024-04-15 10:07:21 -06:00

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