module Data.Functor.Foldable.Monadic (cataM) where

import Data.Functor.Foldable
import PlutusPrelude

cataM :: (Recursive t, Traversable (Base t), Monad m) => (Base t a -> m a) -> t -> m a
cataM :: forall t (m :: * -> *) a.
(Recursive t, Traversable (Base t), Monad m) =>
(Base t a -> m a) -> t -> m a
cataM Base t a -> m a
f = t -> m a
c where c :: t -> m a
c = Base t a -> m a
f (Base t a -> m a) -> (t -> m (Base t a)) -> t -> m a
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< ((t -> m a) -> Base t t -> m (Base t a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Base t a -> f (Base t b)
traverse t -> m a
c (Base t t -> m (Base t a)) -> (t -> Base t t) -> t -> m (Base t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> Base t t
forall t. Recursive t => t -> Base t t
project)