blob: 2b317d8e09227b60010fcdffba6393b0ca5eb820 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
-- Test for #1648
import Foreign
import Data.Int
import Data.Word
f :: Int64 -> IO Int64
f x = return $ x + 1
g :: Word64 -> IO Word64
g x = return $ x + 2
type WCall = Word64 -> IO Word64
foreign import ccall "wrapper" mkWCall :: WCall -> IO (FunPtr WCall)
foreign import ccall "dynamic" call_w :: FunPtr WCall -> WCall
type ICall = Int64 -> IO Int64
foreign import ccall "wrapper" mkICall :: ICall -> IO (FunPtr ICall)
foreign import ccall "dynamic" call_i :: FunPtr ICall -> ICall
main = do
fp <- mkICall f
call_i fp 3 >>= print
fp <- mkWCall g
call_w fp 4 >>= print
|