Re: ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-19 Thread Sven Panne
Am Mittwoch, 15. März 2006 18:16 schrieb Duncan Coutts: On Wed, 2006-03-15 at 17:01 +, Brian Hulley wrote: The above two things were what I was expecting the compiler to do for me instead of me having to manually write a wrapper function in Haskell using withForeignPtr for each wrapper

ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-15 Thread Brian Hulley
Hi - I've got the beginnings of an API for a GUI system as follows: data DWindow a data DEdit a type Window = DWindow type Edit a = DWindow (DEdit a) foreign import ccall duma_init :: IO () foreign import ccall duma_run :: IO () foreign import ccall duma_release :: FunPtr (Ptr (Window a) - IO

Re: ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-15 Thread Simon Marlow
Brian Hulley wrote: I've got the beginnings of an API for a GUI system as follows: ... addTop :: ForeignPtr (Window a) - IO () addTop w = withForeignPtr w duma_addTop This works, but it seems a bit of a pain to have to manually convert between ForeignPtr's and Ptr's all the time. In

Re: ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-15 Thread Brian Hulley
Esa Ilari Vuokko wrote: On 3/15/06, Brian Hulley [EMAIL PROTECTED] wrote: [snip] (Not directly related, but maybe useful to know) Stricly speaking, asynchronous exception may occur in between, and this code should in fact be surrounded by block to prevent resource leaks. createEdit = block $

Re: ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-15 Thread Brian Hulley
Simon Marlow wrote: Brian Hulley wrote: I've got the beginnings of an API for a GUI system as follows: ... addTop :: ForeignPtr (Window a) - IO () addTop w = withForeignPtr w duma_addTop This works, but it seems a bit of a pain to have to manually convert between ForeignPtr's and Ptr's all

Re: ForeignPtr's - why can't they be passed directly to foreign functions?

2006-03-15 Thread Duncan Coutts
On Wed, 2006-03-15 at 17:01 +, Brian Hulley wrote: Simon Marlow wrote: This is the way it used to be in GHC before the FFI. In the FFI we moved to withForeignPtr instead. IIRC, the motivation was something along these lines: - allowing ForeignPtr to be passed directly to a