On Thursday 29 May 2003 13:56, Malcolm Wallace wrote: > In order to make this work with your definition of <+, you needed to > change the types. But perhaps that was because your definition of <+ > was not exactly what you needed.
Nope. <+ as defined is exactly what I need, the only problem with it is it seems to be broken :-) > How about the following alternative: > > g s n f = g' <$ withCString s <+ allocaBytes n <+ withForeignPtr f > > infixl 3 <$ > a <$ b = b a > > infixr 4 <+ > f <+ g = \h-> f $ \a-> > g $ \b-> > h a b > > which preserves all the types exactly as they are in the FFI standard? That's very neat, though I think a type sig would help users (well me:-) figure out what to do with this definition of <+ Here's the most appropriate for our purposes I think (not most general).. (<+) :: ((a -> IO z) -> IO z) -> (( b -> c) -> IO z) -> ((a -> b -> c) -> IO z) I don't think this is quite what I wanted, it seems hard to do the "partial application" trick with this. But even disregarding the issues regarding allocation lifetime, the partial application trick seems unsafe outside the IO monad because of the potential mutability of things that are pointed to. So maybe that's not really a valid gripe re. your definition of <+. To be honest I still find the whole idea of things that are pointed to disappearing at the most awkward times quite unsettling. I guess for the purposes of FFI programming I need to forget my "bad" FP habits and start thinking like C programmer :-) Regards -- Adrian Hey _______________________________________________ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi