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=03eabb66fb8ecd2ff7218fa5191db648350ee280;hp=751294a11bb44ea03df62391d7120c83bf9a1a0c;hb=77e4291d372e7b4b40ee868ad61cc07c51de8c6b;hpb=6e64e280f5eb25df3d2de751913bd20269f7ebcc diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index 751294a11..03eabb66f 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1290,8 +1290,12 @@ 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`." +maybe :: b -> (a -> b) -> Maybe a -> 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