<div dir="ltr"><div>huh, this is a pretty neat little api for resource pools, i'll have to take some time to dig into it when i get the chance!<br></div>thanks for sharing.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 14, 2015 at 4:36 PM, Yuras Shumovich <span dir="ltr"><<a href="mailto:shumovichy@gmail.com" target="_blank">shumovichy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello,<br>
<br>
I'm asking for code and design review for `io-region` library. It is<br>
already on Hackage for convenience and easy access to haddock:<br>
<a href="https://hackage.haskell.org/package/io-region" target="_blank">https://hackage.haskell.org/package/io-region</a><br>
<br>
Manual exception handling in Haskell almost never is a good idea, except<br>
probably trivial cases where `bracket` is enough. A number of special<br>
libraries where created to help with exception handling. `io-regions` is<br>
one of them.<br>
<br>
Initially it was an attempt to solve the double-throw issue, but I found<br>
it unsolvable in library without changes in language itself. So now it<br>
is an attempt to design easy to use API with a bit different set of<br>
trade-offs.<br>
<br>
The library is based on idea of regions that own resources. The<br>
resources are released when the region is closed. Early releasing and<br>
ownership transferring are supported. Types are *not* used to prevent<br>
use-after-free errors.<br>
<br>
The API is not monadic, and it is the biggest difference from other<br>
libraries. Regions are first-class citizens, so you can manipulate them,<br>
pass as arguments to functions, send to other thread, store in data<br>
types. Such flexibility has its cost -- a bit more manual management.<br>
<br>
The implementation is based on STM and is thread safe, that allows e.g.<br>
atomic ownership transferring between threads.<br>
<br>
The nearest competitor I think is `resourset` package, and I still<br>
recommend it by default. Though I convinced myself that `io-region` is<br>
good enough, and I'm using it in productions (for two weeks already :) )<br>
<br>
Thanks,<br>
Yuras<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>