Rlp2Core: pattern let binds
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user