X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;h=907d6e00d74084dfc12dddedd205448624ecc2a8;hp=05b5f2785675c6da8738e28287a465b6f8c22d4f;hb=82a87b8535628d47d9c381e1a3a2296fb67c7fd0;hpb=b4ad5dec5012b96765e6bb85f990500d2b376a96 diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index 05b5f2785..907d6e00d 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1088,6 +1088,22 @@ class (Functor f) => FunctorM f where sequence :: Monad m => f (m a) -> m (f a) mapM f l = sequence (fmap f l) +/// MonadE /// + +class (FunctorE m, Monad m) => MonadE m where + bindE :: m a -> (a -> m b) -> m b + +instance MonadE Maybe where + bindE Nothing _ = Nothing + bindE (Just v) f = f v + +instance MonadE (Either a) where + bindE (Left v) _ = Left v + bindE (Right v) f = f v + +instance MonadE [] where + bindE l f = concatMap f l + /// Category /// "Identity function."