blob: 94d0df2fa4220a899fa49ce2d5c1c8c80d71163f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- Tests newtype unwrapping for the IO monad itself
-- Notice the RenderM monad, which is used in the
-- type of the callback function
module ShouldCompile where
import Foreign.Ptr
newtype RenderM a = RenderM (IO a) deriving (Functor, Monad)
type RenderCallback = Int -> Int -> RenderM ()
foreign import ccall duma_onRender :: FunPtr RenderCallback -> RenderM ()
foreign import ccall "wrapper" mkRenderCallback
:: RenderCallback -> RenderM (FunPtr RenderCallback)
onRender :: RenderCallback -> RenderM ()
onRender f = mkRenderCallback f >>= duma_onRender
|