[Haskell-cafe] Bracket around every IO computation monad

Mitar mmitar at gmail.com
Mon Nov 15 18:14:54 EST 2010


Hi!

On Mon, Nov 15, 2010 at 9:07 PM, C. McCann <cam at uptoisomorphism.net> wrote:
> Isn't this mostly a reimplementation of mapM? Given a list of [IO
> Growable], you map over it to put a bracket around each one, then
> sequence the result

No. There is a trick. It stacks up attach and deattach. So if for
third attach something fails then both deattach for second and first
nerve is called. In your example this would not happen.

So the idea is that in a case of an error all computations (which are
of some type class which defines necessary prepare and cleanup
functions) are "unwinded". In a case of success the resulting list is
returned.


Mitar


More information about the Haskell-Cafe mailing list