X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;h=f983251093272d2168cb9eacc05db4542660afa0;hb=6c99e980d250fb9201aba93be7dcb1f55564dccd;hp=c175f95a30d01bd7a15c0c6e9d8d4fd1dc36ef1d;hpb=e1b1c30f512d3c196c86c4a1f0eaf8b7dd461a9a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index c175f95a3..f98325109 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1096,6 +1096,7 @@ class (FunctorE f) => FunctorM f where /// MonadE /// class (FunctorE m, Monad m) => MonadE m where + "An effectful version of the bind operator `(>>=)`" bindE :: m a -> (a -> m b) -> m b instance MonadE Maybe where @@ -1109,6 +1110,11 @@ instance MonadE (Either a) where instance MonadE [] where bindE l f = concatMap f l +@inline +"An effectful version of the Kleisli composition operator `(>=>)`" +compE :: MonadE m => (a -> m b) -> (b -> m c) -> a -> m c +compE f g x = (f x) `bindE` g + /// MZeroE /// class (MonadE m, MonadZero m) => MonadZeroE m where @@ -1521,11 +1527,11 @@ snd :: (a,b) -> b snd (x,y) = y @inline -mapFst :: (a -> b) -> (a,c) -> (b,c) +mapFst :: (a -> b) -> (a,c) -> (b,c) mapFst f (x,y) = (f x, y) @inline -mapSnd :: (a -> b) -> (c,a) -> (c,b) +mapSnd :: (a -> b) -> (c,a) -> (c,b) mapSnd f (x,y) = (x, f y) instance (Ord a, Ord b) => Ord (a, b) where