On Mon, Jan 23, 2006 at 09:55:39PM +0100, Twan van Laarhoven wrote:
> Is there any reason why IO should not be defined as:
>  > type IO a = ST RealWorld a
> in implementations that support ST?
>
> This way IORef/STRef and IOArray/STArray can be merged. I know under the
> hood they already share code, but this way they can also share an interface.


ST doesn't have exceptions which IO does. It would be no good to make ST
pay for the cost of exception handling. GHC handles them behind the
scenes (I think?) but in jhc they are explicit and IO is defined as
follows:

> data World__
>
> data IOResult a = FailIO World__ IOError | JustIO World__ a
> newtype IO a = IO (World__ -> IOResult a)

I belive other implementations have used continuations for IO as well.

        John


--
John Meacham - ⑆repetae.net⑆john⑈
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to