How to describe this bug?

roconnor at roconnor at
Tue Jul 10 17:08:15 CEST 2012

On Tue, 10 Jul 2012, Sönke Hahn wrote:

> Hi!
> I've discovered a strange bug that violates simple equational reasoning.
> Basically, something similar to this:
> let a = f x
> in a == f x

While this code as it stands doesn't quite illustrate the referential 
transparency error, since == isn't guarenteed to return True on the same 
floating point value (see NaN), with a small tweek we can turn into an 
example that does illustrate the lack of referential transparency:

(let a = f x in a == f x) == (let a = f x in a == a)

or also perhaps

(let a = f x in a == f x) == (f x == f x)

If either of these return False than it is an error of referential 
transparency since equality on equivalent Bool expressions is always 
supposed to return True or diverge.

Russell O'Connor                                      <>
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''

More information about the Glasgow-haskell-users mailing list