I’m writing a binding for a C library and am wondering when I should be using ForeignPtr
instead of, say, withResource $ \resource -> ...
style resource allocation and deallocation?
It seems that ForeignPtr
is a handy thing to have, but it does move resource management to the GC. Couldn’t that lead to unintended resource exhaustion?
Are there guidelines on when to use it, and when not to?