diff options
Diffstat (limited to 'testsuite/tests/ffi/should_compile/ffi-deriv1.hs')
-rw-r--r-- | testsuite/tests/ffi/should_compile/ffi-deriv1.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_compile/ffi-deriv1.hs b/testsuite/tests/ffi/should_compile/ffi-deriv1.hs new file mode 100644 index 0000000000..94d0df2fa4 --- /dev/null +++ b/testsuite/tests/ffi/should_compile/ffi-deriv1.hs @@ -0,0 +1,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
+
+
+
|