From c895bed4889abaf07e4bd6d7b4268719d8f6aea1 Mon Sep 17 00:00:00 2001 From: Eitan Chatav Date: Mon, 15 Jan 2024 11:37:45 -0800 Subject: [PATCH] foldFreerIx --- src/Control/Monad/Trans/Indexed/Free.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Control/Monad/Trans/Indexed/Free.hs b/src/Control/Monad/Trans/Indexed/Free.hs index 778095f..2d1ea2b 100644 --- a/src/Control/Monad/Trans/Indexed/Free.hs +++ b/src/Control/Monad/Trans/Indexed/Free.hs @@ -12,7 +12,7 @@ The free indexed monad transformer. module Control.Monad.Trans.Indexed.Free ( IxMonadTransFree (liftFreeIx, hoistFreeIx, foldFreeIx), coerceFreeIx - , IxFunctor, IxMap (IxMap), liftFreerIx, hoistFreerIx + , IxFunctor, IxMap (IxMap), liftFreerIx, hoistFreerIx, foldFreerIx ) where import Control.Monad.Free @@ -132,3 +132,9 @@ hoistFreerIx => (forall i j x. f i j x -> g i j x) -> freeIx (IxMap f) i j m x -> freeIx (IxMap g) i j m x hoistFreerIx f = hoistFreeIx (\(IxMap g x) -> IxMap g (f x)) + +foldFreerIx + :: (IxMonadTransFree freeIx, IxMonadTrans t, Monad m) + => (forall i j x. f i j x -> t i j m x) + -> freeIx (IxMap f) i j m x -> t i j m x +foldFreerIx f x = foldFreeIx (\(IxMap g y) -> g <$> f y) x