[Haskell-cafe] IO is not a monad

Yitzchak Gale gale at sefer.org
Wed Feb 7 20:12:24 EST 2007


Aaron McDaid wrote:
> Could seq be changed so that it will not give an
> error if it finds undefined?

The definition of seq is that seq _|_ x = _|_. That is
what it is supposed to do.

Actually, the behavior of seq on undefined is very
tame - it raises an exception which can be caught.
Sometimes seq hangs. Unfortunately, getting around
that would require solving the halting problem.

> Am I right in thinking that seq is supposed to
> theoretically do nothing, but simply give a hint to the
> compiler so to speak?

I see it the other way around. Theoretically, seq does
a lot. In practice, it is up to each compiler to decide
on the implementation details.

> Anyway, as far as I can see it is already true that
>    (>>= f) . return = f
> because 'equality' for Monads simply means they do
> that same thing when 'executed' or whatever.
> The only thing that can currently find a
> difference between the above monads is seq and seq
> is a funny thing.

That does seem to be a pretty widespread view.
I am a relative newcomer to Haskell, so I guess
I am naive. But, so far, I am not convinced.

Haskell is a non-strict language, so non-strict
values are legitimate, and so is seq. I don't
see how seq is any more funny than irrational
numbers are irrational or imaginary numbers
are imaginary.

Regards,
Yitz


More information about the Haskell-Cafe mailing list