Cheap ForeignPtr allocation

Simon Marlow simonmar at
Mon Sep 2 12:20:51 EDT 2002

> Can you achieve the same performance gain by adding some 
> rewrite rules?

Perhaps you could try to spot

	(>>=) malloc (\p -> newForeignPtr p free)

Hmmm.  Actually I'd like to do both: add the functions, because they
encapsulate a common case and guarantee a speed improvement if you use
them, and add the rewrite rule because it might catch some cases in
existing code.  The problem with relying on rewrite rules exclusively is
that they tend to be a bit fragile and can fail to trigger without you


More information about the FFI mailing list