Typo
[packages/base.git] / tests / stableptr001.hs
1
2 module Main where
3
4 import Foreign
5
6 -- simple test for building/dereferencing stable ptrs
7
8 main
9 = do l <- mapM newStablePtr [1..100000]
10 sum <- stable_sum l
11 print sum
12
13 stable_sum :: [StablePtr Integer] -> IO Integer
14 stable_sum [] = return 0
15 stable_sum (x:xs)
16 = do x' <- deRefStablePtr x
17 freeStablePtr x
18 xs' <- stable_sum xs
19 return (x' + xs')