Rlp2Core: pattern let binds

This commit is contained in:
crumbtoo
2024-02-09 17:04:33 -07:00
parent 2492660da4
commit c37e8bdf15
2 changed files with 37 additions and 15 deletions

View File

@@ -1,10 +1,13 @@
module Control.Monad.Utils
( mapAccumLM
, Kendo(..)
)
where
----------------------------------------------------------------------------------
import Data.Tuple (swap)
import Data.Coerce
import Control.Monad.State
import Control.Monad
----------------------------------------------------------------------------------
-- | Monadic variant of @mapAccumL@
@@ -19,3 +22,11 @@ mapAccumLM k s t = swap <$> runStateT (traverse k' t) s
k' :: a -> StateT s m b
k' a = StateT $ fmap swap <$> flip k a
newtype Kendo m a = Kendo { appKendo :: a -> m a }
instance (Monad m) => Semigroup (Kendo m a) where
Kendo f <> Kendo g = Kendo (f <=< g)
instance (Monad m) => Monoid (Kendo m a) where
mempty = Kendo pure