RE: [Haskell] strictness of putChar: report incomplete?
On 05 October 2005 15:46, Ross Paterson wrote:
On Wed, Oct 05, 2005 at 03:22:29PM +0100, Simon Marlow wrote:
Also, GHC's optimiser currently treats (_|_ :: IO a) and (do _|_; return ()) as interchangeable, which is naughty, and people have occasionally noticed, but the benefits can sometimes be huge.
What's wrong with identifying them? You're not expecting the monad laws to hold, are you?
No, of course I don't expect the monad laws to hold :) But the intended meaning of (do _|_; return () :: IO ()) `seq` True is True, not _|_, right? This isn't made explicit in the report, but it's how we all understand the IO monad to work, and perhaps derives from the well-known implementation of (IO a) as (World -> (a,World)). Cheers, Simon
On Wed, Oct 05, 2005 at 04:01:09PM +0100, Simon Marlow wrote:
No, of course I don't expect the monad laws to hold :)
But the intended meaning of
(do _|_; return () :: IO ()) `seq` True
is True, not _|_, right? This isn't made explicit in the report, but it's how we all understand the IO monad to work, and perhaps derives from the well-known implementation of (IO a) as (World -> (a,World)).
Actually, from a resumption-based semantics of IO, I was expecting _|_, but I see all the implementations get it wrong.
Am Mittwoch, 5. Oktober 2005 17:01 schrieb Simon Marlow:
On 05 October 2005 15:46, Ross Paterson wrote:
On Wed, Oct 05, 2005 at 03:22:29PM +0100, Simon Marlow wrote:
Also, GHC's optimiser currently treats (_|_ :: IO a) and (do _|_; return ()) as interchangeable, which is naughty, and people have occasionally noticed, but the benefits can sometimes be huge.
What's wrong with identifying them? You're not expecting the monad laws to hold, are you?
No, of course I don't expect the monad laws to hold :)
It's terrible that the monad laws don't hold for the IO *monad*. I suppose, it all has to do with the type of seq being too general. In my opinion, this is a very serious problem since Haskell is a language which is expected to have a sound theoretical foundation. So I think that this problem should be addressed in the future under all circumstances.
[...]
Best wishes, Wolfgang
participants (3)
-
Ross Paterson -
Simon Marlow -
Wolfgang Jeltsch