]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Maybe4.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / Maybe4.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Maybe4.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Maybe4.scl
new file mode 100644 (file)
index 0000000..53e3ed3
--- /dev/null
@@ -0,0 +1,18 @@
+import "Prelude" hiding (fromMaybe)\r
+import "Random"\r
+\r
+importJava "org.simantics.scl.compiler.tests.imports.Maybe4Imports" where\r
+    toMaybeDouble :: String -> <Random> Maybe a\r
+\r
+fromMaybe :: a -> Maybe a -> a\r
+fromMaybe _ (Just v) = v\r
+fromMaybe def _ = def\r
+\r
+f x = do\r
+    a = fromMaybe (-1.0) (toMaybeDouble x)\r
+    b = fromMaybe (-1.0) (toMaybeDouble ("1" + x))\r
+    a+b\r
+\r
+main = withSeed 123 (f "2.0")\r
+--\r
+14.0
\ No newline at end of file