]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Prelude.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Prelude.scl
index c175f95a30d01bd7a15c0c6e9d8d4fd1dc36ef1d..86d13fb6628e77401b7a7fd0be2866834216ffca 100644 (file)
@@ -75,7 +75,7 @@ infixl 6  (+), (-)
 infixl 5  (\\), (<<), (<+)
 infix  4  (!=), (<), (<=), (>=), (>)
 infixr 3  (&&), (&<&)
-infixr 2  (||), orElse, morelse
+infixr 2  (||), orElse, orElseM, morelse
 infixr 1  (>>=), (>>), (:=), (>=>)
 infixr 1  ($)
 infixl 1  catch
@@ -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
@@ -1521,11 +1527,11 @@ snd :: (a,b) -> b
 snd (x,y) = y
 
 @inline
-mapFst :: (a -> b) -> (a,c) -> (b,c)
+mapFst :: (a -> <e> b) -> (a,c) -> <e> (b,c)
 mapFst f (x,y) = (f x, y)
 
 @inline
-mapSnd :: (a -> b) -> (c,a) -> (c,b)
+mapSnd :: (a -> <e> b) -> (c,a) -> <e> (c,b)
 mapSnd f (x,y) = (x, f y)
 
 instance (Ord a, Ord b) => Ord (a, b) where