From: Tuukka Lehtonen Date: Sun, 24 Mar 2019 22:13:54 +0000 (+0000) Subject: Merge "Added effectful Kleisli composition to Prelude." X-Git-Tag: v1.43.0~136^2~171 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=9d780ffc68dbcb27bd90b5f80f4288de62d149fd;hp=67918d39fd9a67b659dcb118412fe0313a8fc0e8 Merge "Added effectful Kleisli composition to Prelude." --- diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.md b/bundles/org.simantics.scl.runtime/scl/Prelude.md index df91f29d1..531a63587 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.md +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.md @@ -81,13 +81,16 @@ ## 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 diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index e92603bec..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