]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Prelude.scl
Merge "Added effectful Kleisli composition to Prelude."
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Prelude.scl
index e92603becb8e4300db875532c2b87ba090b742e8..f983251093272d2168cb9eacc05db4542660afa0 100644 (file)
@@ -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 -> <e> m b) -> <e> 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 -> <e> m b) -> (b -> <f> m c) -> a -> <e,f> m c
+compE f g x = (f x) `bindE` g
+
 /// MZeroE ///
 
 class (MonadE m, MonadZero m) => MonadZeroE m where