]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ExistentialData.scl
(refs #7307) Added features field to SCL module header
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / ExistentialData.scl
1 import "JavaBuiltin" as Java
2
3 (+) = Java.iadd
4
5 data Thunk a = /* forall s. */ Thunk s (s -> a)
6
7 id :: a -> a
8 id x = x
9
10 runThunk :: Thunk a -> a
11 runThunk (Thunk s f) = f s
12
13 makeThunk :: a -> Thunk a
14 makeThunk x = Thunk x id
15
16 mapThunk :: (a -> b) -> Thunk a -> Thunk b
17 mapThunk f (Thunk s g) = Thunk s (\x -> f (g x))
18
19 a = makeThunk (13 :: Integer)
20 b = mapThunk (\x -> x+1) a
21 main = runThunk b
22 --
23 14