seq#: do we actually need it as a primitive?

Roman Cheplyaka roma at
Thu Jan 8 13:42:11 UTC 2015

On 08/01/15 10:00, Edward Z. Yang wrote:
> For posterity, the answer is no, and it is explained in this comment:

Thanks, this is helpful.

So we have three potential implementations for evaluate:

(1) \x -> return $! x
(2) \x -> (return $! x) >>= return
(3) implemented using seq#

(1) and (2) are supposed to be equivalent (by the monad law), but are
not in reality, since in (2) evaluate x is always a value.

The documentation for 'evaluate' talks about the difference between (1)
and (2). Furthermore, it suggests that (2) is a valid implementation.

(1) is buggy, as explained in #5129 linked above. However, it doesn't
say anything about (2).

Would (2) still suffer from #5129? In that case, the docs should be fixed.

Also, where can I find the 'instance Monad IO' as understood by GHC?
grep didn't find one.


More information about the ghc-devs mailing list