]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ExistentialData.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / ExistentialData.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ExistentialData.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ExistentialData.scl
new file mode 100644 (file)
index 0000000..62130b4
--- /dev/null
@@ -0,0 +1,23 @@
+import "JavaBuiltin" as Java\r
+\r
+(+) = Java.iadd\r
+\r
+data Thunk a = /* forall s. */ Thunk s (s -> a)\r
+\r
+id :: a -> a\r
+id x = x\r
+\r
+runThunk :: Thunk a -> a\r
+runThunk (Thunk s f) = f s\r
+\r
+makeThunk :: a -> Thunk a\r
+makeThunk x = Thunk x id\r
+\r
+mapThunk :: (a -> b) -> Thunk a -> Thunk b\r
+mapThunk f (Thunk s g) = Thunk s (\x -> f (g x))\r
+\r
+a = makeThunk (13 :: Integer)\r
+b = mapThunk (\x -> x+1) a\r
+main = runThunk b\r
+--\r
+14
\ No newline at end of file