[project @ 2000-05-10 12:17:35 by rrt]
[ghc-hetmet.git] / ghc / tests / io / stable001 / Main.hs
1 -- This is a rather exciting experiment in using the new call
2 -- makeStablePtr# and performIO. It doesn't do much but it took an
3 -- incredible effort to get it to do it.
4
5 import Stable
6 import GlaExts
7 import CString
8
9 -- module Main(main) where
10
11 main =  makeStablePtr test      >>= \ stablePtr ->
12         ((_casm_GC_ ``SaveAllStgRegs(); test1(%0); RestoreAllStgRegs();'' stablePtr)
13                                                 :: PrimIO ())
14                                 >>= \ _ ->
15         return ()
16
17 test :: IO Int
18 test =
19         let f x = sum [1..x]
20             f :: Int -> Int
21         in 
22         _ccall_ printf
23               (packString "The stable pointer has just been used to print this number %d\n") (f 100)
24                                 >>= \ _ ->
25         return 5
26