[Haskell-cafe] Type system madness

Jonathan Cast jcast at ou.edu
Wed Jul 11 17:30:14 EDT 2007


On Wednesday 11 July 2007, you wrote:
> Yes, that's one way to define IO.  But it's not the only way.

Right.

Aren't we saying the same thing?

I mean, sure, the *one true way* to define IO is

data IO alpha
  = ReturnIO alpha
  | JoinAtomically (STM (IO alpha))
  | HOpenBind String (Handle -> IO alpha)
  | HCloseThen Handle (IO alpha)
  | HPutThen Handle Char (IO alpha)
  | HGetBind Handle (Char -> IO alpha)
  | ForkIOBind (IO ()) (ThreadId -> IO alpha)
  | UnsafeInterleaveIO (IO (IO alpha))
  | ...

but it's still reasonable to explain that GHC doesn't do it that way and that 
*in GHC*

newtype IO alpha = IO (State# RealWorld -> (# alpha, State# RealWorld #))
newtype ST s alpha
  = ST (State# (STState s) -> (# alpha, State# (STState s) #))

no?  I don't see your objection to it.  Especially if it causes light bulbs to 
go off over people's heads.

Jonathan Cast
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs


More information about the Haskell-Cafe mailing list