[Haskell-cafe] Re: [Haskell] Simple IO Regions

Keean Schupke k.schupke at imperial.ac.uk
Tue Jan 17 13:13:14 EST 2006

Hi Oleg,

    Just made a few modifications and thought it might be useful to 
people. I have rewritten the functions as
"liftR" and "bracketR" over a "MonadIO" monad interface (allowing 
monad-transformers to be used). This is now
usable as  Region library, as you can lift any arbitrary IO function 
into a Region. I don't think I have overlooked anything, and I
think it is as safe as the original... but perhaps you would like to 
check for stupid mistakes... The exported interface is intended
to be "liftR", "bracketR" and "runR". See attached "MonadIORegion.hs"...


oleg at pobox.com wrote:

>This message shows a very simple implementation of Monadic Regions
>(for the particular case of IO and reading the file). The technique
>*statically* guarantees that neither a file handle nor any computation
>involving the handle can leak outside of the region that created
>it. Therefore, the handle can be safely closed (and its resources
>disposed of) whenever control leaves the corresponding 'withFile'
>block. Many handles can be open simultaneously, the type system
>enforces the proper nesting of their regions. The technique has no
>run-time overhead and induces no run-time errors. Unlike the previous
>implementation of monadic regions, only the basic extensions
>(higher-ranked types and one two-parameter type class) are used. No
>undecidable instances, no functional dependencies (let alone
>overlapping instances) are required. In fact, the implementation uses
>only one trivial typeclass and one trivial instance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MonadIORegion.hs
Type: text/x-haskell
Size: 1919 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060117/7c431d73/MonadIORegion.bin

More information about the Haskell-Cafe mailing list