new ForeignPtr without finalizers

2003-06-08 Thread Ashley Yakeley
OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that doesn't have any finalizers? newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a) newSimpleForeignPtr ptr = ?? -- Ashley Yakeley, Seattle WA ___ FFI mailing list [EMAIL PROTECTED]

Re: new ForeignPtr without finalizers

2003-06-09 Thread Malcolm Wallace
Ashley Yakeley <[EMAIL PROTECTED]> writes: > OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that > doesn't have any finalizers? > > newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a) > newSimpleForeignPtr ptr = ?? Why would you want to? A ForeignPtr without any finalizers

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
On Monday 09 June 2003 4:59 am, Ashley Yakeley wrote: > OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that > doesn't have any finalizers? > > newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a) > newSimpleForeignPtr ptr = ?? There is no direct way in the ffi. You could define

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
Ashley: > How do I create a new ForeignPtr that doesn't have any finalizers? Malcolm: > Why would you want to? addForeignPtrFinalizer lets you add them later. I'm guessing that Ashley is making heavy use of this ability. [What we have at the moment is the ability to attach a non-empty list of f

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Alastair Reid <[EMAIL PROTECTED]> wrote: > It looks like you're using an idiom we didn't think of when designing the > library. Can you explain what you're trying to do and whether you think we > shoud provide direct support for newSimpleForeignPtr (which I'd be

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Malcolm Wallace <[EMAIL PROTECTED]> wrote: > Why would you want to? > > A ForeignPtr without any finalizers is semantically just a Ptr, > plain and simple. I need a pointer type for which some values have finalizers, and some don't. -- Ashley Yakeley, Seattle

Re: new ForeignPtr without finalizers

2003-06-09 Thread Malcolm Wallace
Ashley Yakeley <[EMAIL PROTECTED]> writes: > Specifically I want a ForeignPtr of a null Ptr that has no finalizers. Ah, this makes sense. I wonder if we should add the following to the FFI spec module ForeignPtr? nullForeignPtr :: ForeignPtr a -- a null pointer with null finalizer Rega

Re: new ForeignPtr without finalizers

2003-06-09 Thread Axel Simon
On Mon, Jun 09, 2003 at 01:21:38PM +0100, Malcolm Wallace wrote: > Ashley Yakeley <[EMAIL PROTECTED]> writes: > > > Specifically I want a ForeignPtr of a null Ptr that has no finalizers. > > Ah, this makes sense. > I wonder if we should add the following to the FFI spec module ForeignPtr? > >

Re: new ForeignPtr without finalizers

2003-06-09 Thread Manuel M T Chakravarty
Alastair Reid <[EMAIL PROTECTED]> wrote, > Ashley: > > How do I create a new ForeignPtr that doesn't have any finalizers? > > Malcolm: > > Why would you want to? > > addForeignPtrFinalizer lets you add them later. > I'm guessing that Ashley is making heavy use of this ability. > > [What we have

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
On Monday 09 June 2003 3:48 pm, Manuel M T Chakravarty wrote: > Andre proposed to allow `nullFunPtr' as a finalizer argument > to `newForeignPtr' to indicate the lack of a finalizer. > This seems quite C-ish, but has the advantage that it is > easy to parametrise functions that internally use > `ne

Re: new ForeignPtr without finalizers

2003-06-09 Thread Dean Herington
Alastair Reid wrote: > I'm not convinced that merging them into a single function is desirable, but, > if we wanted to, I think a better FPish solution is to use > > Maybe (FinalizerPtr a) As multiple finalizers are allowed, perhaps we should consider: newForeignPtr :: [FinalizerPtr a] -> Ptr

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Alastair Reid <[EMAIL PROTECTED]> wrote: > I'm not convinced that merging them into a single function is desirable, but, > if we wanted to, I think a better FPish solution is to use > > Maybe (FinalizerPtr a) I think the most FPish solution would be this:

Re: new ForeignPtr without finalizers

2003-06-11 Thread Manuel M T Chakravarty
Dean Herington <[EMAIL PROTECTED]> wrote, > Alastair Reid wrote: > > > I'm not convinced that merging them into a single function is desirable, but, > > if we wanted to, I think a better FPish solution is to use > > > > Maybe (FinalizerPtr a) > > As multiple finalizers are allowed, perhaps we

Re: new ForeignPtr without finalizers

2003-06-11 Thread Manuel M T Chakravarty
Alastair Reid <[EMAIL PROTECTED]> wrote, > > I'd propose to > > > > * add `newForeignPtr_', > > * reverse the argument order to `newForeignPtr', and > > * reverse the argument order to `addForeignPointerFinalizer' > > (for consistency). > > I agree with adding newForeignPtr_. (Presumably the r

Re: new ForeignPtr without finalizers

2003-06-12 Thread Alastair Reid
Manuel: > In other words, it seem much more likely that one would > partially apply `newForeignPtr' to a finaliser than to a > pointer that is to be finalised. But this is a minor point. Having written some more ffi code over the last couple of days, I agree that this is much more natural so, ev

Re: new ForeignPtr without finalizers

2003-06-12 Thread Dean Herington
On Thu, 12 Jun 2003, Alastair Reid wrote: > Manuel: > > In other words, it seem much more likely that one would > > partially apply `newForeignPtr' to a finaliser than to a > > pointer that is to be finalised. But this is a minor point. > > Having written some more ffi code over the last couple

Re: new ForeignPtr without finalizers

2003-06-12 Thread Alastair Reid
> Actually, I think I prefer Ashley's idea of separating the creation of a > ForeignPtr from the addition of a FinalizerPtr. So how about: > > newForeignPtr :: Ptr a -> IO (ForeignPtr a) > addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO () You're proposing a diffe

Re: new ForeignPtr without finalizers

2003-06-12 Thread Manuel M T Chakravarty
Dean Herington <[EMAIL PROTECTED]> wrote, > On Thu, 12 Jun 2003, Alastair Reid wrote: > > > Manuel: > > > In other words, it seem much more likely that one would > > > partially apply `newForeignPtr' to a finaliser than to a > > > pointer that is to be finalised. But this is a minor point. > >

Re: new ForeignPtr without finalizers

2003-07-06 Thread Manuel M T Chakravarty
Alastair Reid <[EMAIL PROTECTED]> wrote, > Manuel: > > In other words, it seem much more likely that one would > > partially apply `newForeignPtr' to a finaliser than to a > > pointer that is to be finalised. But this is a minor point. > > Having written some more ffi code over the last couple o

Re: new ForeignPtr without finalizers

2003-07-07 Thread Sven Panne
Manuel M T Chakravarty wrote: > [ newForeignPtr / addForeignPtrFinalizer argument order ] > This is the last outstanding issue. Shall we swap? I am torn. The > swapped argument order seems more appropriate, but it will break > code. Shall we have one more breakage before it's all frozen? I think th