RE: Re[2]: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-10 Thread Simon Marlow
On 09 March 2006 16:39, Bulat Ziganshin wrote: Hello Simon, Thursday, March 9, 2006, 5:08:09 PM, you wrote: for small home projects you can even use Int and int which would work in most of Haskell implementations Yes, and to give a concrete example: HsInt and int are different types

Re[2]: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-09 Thread Bulat Ziganshin
Hello Marcin, Thursday, March 9, 2006, 2:20:00 AM, you wrote: foreign import ccall duma_init :: Int - IO Int MQK HsInt duma_init(HsInt arg); MQK Or use int on the C side and CInt on the Haskell side. MQK fromIntegral can be used for converting integers in Haskell. for small home projects

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-09 Thread Sven Panne
Am Donnerstag, 9. März 2006 08:46 schrieb Bulat Ziganshin: Thursday, March 9, 2006, 2:20:00 AM, you wrote: foreign import ccall duma_init :: Int - IO Int MQK HsInt duma_init(HsInt arg); MQK Or use int on the C side and CInt on the Haskell side. MQK fromIntegral can be used for converting

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-09 Thread Simon Marlow
Sven Panne wrote: Am Donnerstag, 9. März 2006 08:46 schrieb Bulat Ziganshin: Thursday, March 9, 2006, 2:20:00 AM, you wrote: foreign import ccall duma_init :: Int - IO Int MQK HsInt duma_init(HsInt arg); MQK Or use int on the C side and CInt on the Haskell side. MQK fromIntegral can be

Re[2]: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-08 Thread Bulat Ziganshin
Hello Brian, Wednesday, March 8, 2006, 12:03:27 AM, you wrote: BH mycallback :: GUIMonad m = EventInfo - m EventResult BH 'm' will have to combine a state monad with the IO monad (so I can use IORef BH etc if needed). as Ian Lynagh wrote, it's no problem if your monad is IO-based. if FFI by

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-08 Thread Marcin 'Qrczak' Kowalczyk
Brian Hulley [EMAIL PROTECTED] writes: I've got a Haskell module with the following ffi import: foreign import ccall duma_init :: Int - IO Int However my problem is that I've got no idea what the type signature for the corresponding C function should be, HsInt duma_init(HsInt arg); Or use

How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-07 Thread Brian Hulley
Hi - I've got a Haskell module with the following ffi import: foreign import ccall duma_init :: Int - IO Int However my problem is that I've got no idea what the type signature for the corresponding C function should be, and when I compile the above module with ghc -fglasgow-exts -fffi --make

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-07 Thread Bulat Ziganshin
Hello Brian, Tuesday, March 7, 2006, 7:35:27 PM, you wrote: BH foreign import ccall duma_init :: Int - IO Int int duma_init(int); BH I've tried looking at the wiki but that only seems to give specific BH examples. I'm trying to find what the mapping is between Haskell function BH signatures

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-07 Thread Tomasz Zielonka
On Tue, Mar 07, 2006 at 04:35:27PM -, Brian Hulley wrote: A third point is, how would I pass an arbitrary monad instead of just using IO? What for? IO is the monad that most closely matches the imperative, C semantics. That's why FFI only supports the IO monad (and pure functions). Other

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-07 Thread Ian Lynagh
On Tue, Mar 07, 2006 at 07:57:50PM +0100, Tomasz Zielonka wrote: On Tue, Mar 07, 2006 at 04:35:27PM -, Brian Hulley wrote: A third point is, how would I pass an arbitrary monad instead of just using IO? What for? IO is the monad that most closely matches the imperative, C semantics.

Re: How to find out the C type signature corresponding to a Haskell function type in FFI?

2006-03-07 Thread Brian Hulley
Bulat Ziganshin wrote: Hello Brian, Tuesday, March 7, 2006, 7:35:27 PM, you wrote: foreign import ccall duma_init :: Int - IO Int int duma_init(int); Also, I really wanted to be able to use () - IO () but () doesn't seem to be allowed in FFI... void f(void); foreign import ccall f :: IO