]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/FoldlBuild1.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / FoldlBuild1.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/FoldlBuild1.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/FoldlBuild1.scl
new file mode 100644 (file)
index 0000000..21dfdea
--- /dev/null
@@ -0,0 +1,18 @@
+import "Prelude"\r
+\r
+inc :: Ref Integer -> <Proc> Integer\r
+inc r = do \r
+    v = getRef r\r
+    newV = v+1\r
+    r := newV\r
+    newV\r
+\r
+main = do\r
+    r = ref 0\r
+    // Because both map and for get side-effectful functions\r
+    // as parameters, the fusion is not allowed.\r
+    l = map (\_ -> inc r) [1..4]    \r
+    for l (\i -> r := i+1)\r
+    getRef r\r
+--\r
+5\r