summaryrefslogtreecommitdiff
path: root/testsuite/tests/ffi/should_run/ffi011.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/ffi/should_run/ffi011.hs')
-rw-r--r--testsuite/tests/ffi/should_run/ffi011.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/ffi/should_run/ffi011.hs b/testsuite/tests/ffi/should_run/ffi011.hs
new file mode 100644
index 0000000000..cfb0ae62a9
--- /dev/null
+++ b/testsuite/tests/ffi/should_run/ffi011.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+-- !!! returning a Bool from a foreign export confused GHCi 6.0.1.
+
+import Foreign
+
+foreign import ccall "wrapper"
+ mkFoo :: (Int -> IO Bool) -> IO (FunPtr (Int -> IO Bool))
+
+foo :: Int -> IO Bool
+foo x = return (x == 42)
+
+foreign import ccall "dynamic"
+ call_foo :: FunPtr (Int -> IO Bool) -> Int -> IO Bool
+
+main = do
+ foo_fun <- mkFoo foo
+ call_foo foo_fun 3 >>= print
+ call_foo foo_fun 42 >>= print