MicroHs-0.17.4.0 / tests / Callback.hs
module Callback whereforeign export ccall "hsexp" cb :: Int -> IO Intforeign import ccall "hsimp.h hsimp" imp :: Int -> IO Intfac :: Int -> Intfac 0 = 1fac n = n * fac(n-1)--pp :: Int -> IO ()--pp = _primitive "IO.pp"cb :: Int -> IO Intcb n = do let r = fac n putStrLn $ "cb: " ++ show r return rdoit :: Int -> IO ()doit n = do r <- imp n putStrLn $ "doit: " ++ show rmain :: IO ()main = do mapM_ doit [1..5]