]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Added effectful Kleisli composition to Prelude."
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sun, 24 Mar 2019 22:13:54 +0000 (22:13 +0000)
committerGerrit Code Review <gerrit2@simantics>
Sun, 24 Mar 2019 22:13:54 +0000 (22:13 +0000)
bundles/org.simantics.scl.runtime/scl/Prelude.md
bundles/org.simantics.scl.runtime/scl/Prelude.scl

index df91f29d1fae13da2e0aa7e46964fc5294979037..531a63587ac2635f6859d6ff84e2d7433ebf7102 100644 (file)
 ## Monads
 
 ::class[Monad]
-::value[>>]
+::value[>>, >=>]
 ::class[FunctorM]
 ::value[repeatForever]
 ::class[MonadZero]
 ::value[guard]
 ::class[MonadPlus, MonadOr]
 ::value[ignoreM]
+::class[MonadE]
+::value[compE]
+::class[MonadZeroE]
 
 # Side-effects 
 
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