[Haskell] Re: IO Regions in Haskell98

Brandon Moore brandonm at yahoo-inc.com
Wed Jan 25 10:57:35 EST 2006

Hi Oleg

  This approach has the same flaw as your "Simple IO Regions" code. The 
typing prevents you from constructing actions involving a handle outside 
the region of the handle, but not from constructing actions in the 
region and using them outside. Without the rank-2 types we can use 
runIOM, and should to take advantage of the Typeable1 IO instance.

--saving this message as IORegionsTest98Fail.lhs

 >module IORegions98TestFail where
 >import IORegions98
 >import Monad

 >testMinus1 = join $ runIOM $ withFile "/etc/motd" $
 >                               return . runIOM . qGetChar

Which fails like this:
    ___         ___ _
   / _ \ /\  /\/ __(_)
  / /_\// /_/ / /  | |      GHC Interactive, version 6.4, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base-1.0 ... linking ... done.
Compiling IORegions98      ( ./IORegions98.hs, interpreted )
Compiling IORegions98TestFail ( IORegions98TestFail.lhs, interpreted )
Ok, modules loaded: IORegions98TestFail, IORegions98.
*IORegions98TestFail> testMinus1
Loading package haskell98-1.0 ... linking ... done.
*** Exception: /etc/motd: hGetChar: illegal operation (handle is closed)

I think something like the Simple IO Regions code can be made to work 
with a more complicated representation of the marks set. I'll see if I 
can post a system of my own in a few days, rather than just test cases 
for yours.


More information about the Haskell mailing list