]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Prelude.scl
Function printingToLogging redirecting print commands to logging
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Prelude.scl
index 751294a11bb44ea03df62391d7120c83bf9a1a0c..80b4d0ad794d8eca76d5210c5783fca6cba9a933 100644 (file)
@@ -1290,8 +1290,13 @@ fromMaybe :: a -> Maybe a -> a
 fromMaybe default maybeValue = match maybeValue with
     Just v -> v
     _ -> default
-    
-    
+
+"`maybe def f v` returns `def` if `v=Nothing` and `f x` if `v=Just x`."
+@inline
+maybe :: b -> (a -> <e> b) -> Maybe a -> <e> b
+maybe n _ Nothing  = n
+maybe _ f (Just x) = f x
+
 """
 Provides a default value if the first parameter is Nothing.
 The default value is evaluated only if needed. The function