On Oct 8, 2010, at 2:18 PM, Florian Weimer <f...@deneb.enyo.de> wrote:

* Ben Franksen:

You might be interested in Lightweight Monadic Regions

 http://okmij.org/ftp/Haskell/regions.html#light-weight

which solve the problem (IMHO) in a much cleaner way, i.e. w/o explicit
closing and also w/o using finalizers.

Is this approach composeable in the sense that you can combine code
written in this code with code from another library?  I don't think
so.  The other library might provide something like IORef, and then
it's impossible to uphold static guarantees.

IMHO, this rules out such an approach (until it's part of the standard
library and forced upon everyone, which seems unlikely).

If you are worried about a handle being saved in the IORef to keep it outside 
the region, that's precisely what the library prevents. The typed handle itself 
can be carried outside the region, but the types make it impossible to perform 
any operations on it, so the resources can be released on exit from the region 
anyway. It's quite clever.


      
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to