@@ -65,6 +65,7 @@ printFunctions api registry = do
6565 SI. hPutStrLn h " -- Make the foreign imports happy."
6666 SI. hPutStrLn h " import Foreign.C.Types"
6767 SI. hPutStrLn h " "
68+ SI. hPutStrLn h " import Control.Monad.IO.Class ( MonadIO(..) )"
6869 SI. hPutStrLn h " import Foreign.Marshal.Error ( throwIf )"
6970 SI. hPutStrLn h " import Foreign.Ptr ( Ptr, FunPtr, nullFunPtr )"
7071 SI. hPutStrLn h " import System.IO.Unsafe ( unsafePerformIO )"
@@ -312,8 +313,9 @@ showCommand api c =
312313 showString man .
313314
314315 showString (name ++ " \n " ) .
315- showString (" :: " ++ signature True ) .
316- showString (name ++ " = " ++ dyn_name ++ " " ++ ptr_name ++ " \n\n " ) .
316+ showString (" :: MonadIO m\n " ) .
317+ showString (" => " ++ signature True ) .
318+ showString (name ++ args ++ " = liftIO $ " ++ dyn_name ++ " " ++ ptr_name ++ args ++ " \n\n " ) .
317319
318320 showString (" foreign import CALLCONV \" dynamic\" " ++ dyn_name ++ " \n " ++
319321 " :: FunPtr (" ++ compactSignature ++ " )\n " ++
@@ -341,11 +343,14 @@ showCommand api c =
341343 [_] -> " -- | Manual page for " ++ links
342344 _ -> " -- | Manual pages for " ++ links
343345 renderURL (u, l) = " <" ++ u ++ " " ++ l ++ " >"
346+ args = concat [" v" ++ show i | i <- [1 .. length (paramTypes c)]]
344347
345348showSignatureElement :: Bool -> Bool -> SignatureElement -> String
346349showSignatureElement withComment isResult sigElem = el ++ comment
347- where el | isResult = " IO " ++ showsPrec 11 sigElem " "
350+ where el | isResult = monad ++ " " ++ showsPrec 11 sigElem " "
348351 | otherwise = show sigElem
352+ monad | withComment = " m"
353+ | otherwise = " IO"
349354 comment | withComment = showComment name sigElem
350355 | otherwise = " "
351356 name | isResult = " "
0 commit comments