[Haskell-cafe] Does GHC compare pointers when eval'ing (==)

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Wed Aug 20 13:24:50 UTC 2014


On Wed, Aug 20, 2014 at 03:16:03PM +0200, Johan Holmquist wrote:
> This seems the biggest problem sofar to me, that (5,_|_) == (5,_|_) would
> be _|_ if both pairs where at different memory locations and True
> otherwise. But perhaps not a big deal in practice.

This sounds like a big deal.

    f () = (5, undefined)

    -- crashes
    -- (common subexpression elimination optimization my lead to True)
    let x = f ()
        y = f ()
    in x == y

    -- True
    let x = f ()
        y = x
    in x == y

This isn't the sort of behaviour I'd like from my programming language.

Tom


More information about the Haskell-Cafe mailing list