
Ah oops, tried to remove the Either as an optimization, forgot that IO isn't strict in the value ;-) It should probably be something like newtype IO a = IO (World -> _E a) where _E is just a box to prevent evaluation (it's used in primitive handling already). data _E a = _E a Then the IO monad would be instance Monad IO where (IO x) >>= yf = IO $ \ w -> let xe = x w in case xe of _E xv -> case yf xv of IO y -> y w (IO x) >> (IO y) = IO $ \ w -> case x w of _E _ -> y w return a = IO $ \ w -> _E a
Maybe an artificial "dependingOn", like seq but that doesn't even evaluate its argument to WHNF, is needed? (inspired by jhc's primitive dependingOn :: a -> b -> a, which is the OPPOSITE argument order (like const, rather than seq) and I'm not sure if it has the semantics I'm suggesting, but, whatever...)
Unfortunately the problem isn't (>>), it's return. return a = IO $ \ w -> a -- necessarily evaluates a = wrong Thus 'return undefined' as soon as you apply it to World (i.e. deIO it) it goes bang. The amuzing thing is that none of the conformance tests (and some of them are serious programs) rely on the laziness of IO values. Otherwise I'm sure I would have spotted my braino ;-) Tom

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 shackell@cs.york.ac.uk wrote:
Ah oops, tried to remove the Either as an optimization, forgot that IO isn't strict in the value ;-)
It should probably be something like
newtype IO a = IO (World -> _E a)
where _E is just a box to prevent evaluation (it's used in primitive handling already).
data _E a = _E a
Yes, that seems about right. BTW, why is it called "_E"? Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF9FOpHgcxvIWYTTURAgPvAJ95fYpcaDFHdQso7MOyW16rAuIeeACdEmWB 16/xsEet2b4cBtLX8DQ3Btc= =kRM4 -----END PGP SIGNATURE-----

data _E a = _E a
Yes, that seems about right. BTW, why is it called "_E"?
The 1 element tuple (which is what this is) has no syntax in Haskell. It has many names all over the place
And more specifically, (a) the leading underscore in _E means it is not a legal Haskell'98 type or data constructor, so cannot clash with any user-defined constructor; (b) the E stands for "evaluate", which is rather unintuitive since the constructor means _don't_ evaluate, but you can blame me for that thinko. Regards, Malcolm
participants (4)
-
Isaac Dupree
-
Malcolm Wallace
-
Neil Mitchell
-
shackell@cs.york.ac.uk