]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Proc2.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 / Proc2.scl
1 import "Prelude"
2
3 data RealWorld = RealWorld
4 data IO a = IO (RealWorld -> (RealWorld, a))
5
6 @inline
7 unIO (IO m) = m 
8
9 instance Functor IO where
10     @inline
11     fmap f x = x >>= (return . f)
12
13 instance Monad IO where
14     @inline
15     return x = IO (\s -> (s, x))
16     
17     @inline
18     (IO m) >>= f = IO (\s -> do
19         (newS, v) = m s
20         unIO (f v) newS 
21     )
22
23 @inline
24 runIO :: IO a -> a
25 runIO m = snd (unIO m RealWorld)
26
27 main = runIO (return (13 :: Integer))
28 --
29 13