]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Maybe4.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / Maybe4.scl
1 import "Prelude" hiding (fromMaybe)
2 import "Random"
3
4 importJava "org.simantics.scl.compiler.tests.imports.Maybe4Imports" where
5     toMaybeDouble :: String -> <Random> Maybe a
6
7 fromMaybe :: a -> Maybe a -> a
8 fromMaybe _ (Just v) = v
9 fromMaybe def _ = def
10
11 f x = do
12     a = fromMaybe (-1.0) (toMaybeDouble x)
13     b = fromMaybe (-1.0) (toMaybeDouble ("1" + x))
14     a+b
15
16 main = withSeed 123 (f "2.0")
17 --
18 14.0