[jhc] Monad.ST

John Meacham john at repetae.net
Sat Nov 14 19:54:14 EST 2009

On Sat, Nov 14, 2009 at 04:15:40PM -0800, John Meacham wrote:
> In jhc, we would use something similar to what ghc does. the current IO
> definition is:
> newtype IO a = IO (World__ -> (# World__, a #))
> So, the only difference would be ST takes any state, not just the world,
> or
> newtype ST s a = ST (s -> (# s, a #))

It occurs to me that something like this would be closer to the ghc

> data State s :: #
> newtype ST s a = ST (State s -> (# State s, a #))

then making IO

> newtype IO a = ST World__ a

but just the newtype around IO is probably a better first pass as it
won't require mucking with the IO implementation. Plus it will be
portable to other compilers that have unsafePerformIO...


John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/

More information about the jhc mailing list