[Haskell-cafe] Re: Wikipedia on first-class object
barsoap at web.de
Thu Dec 27 11:44:10 EST 2007
Wolfgang Jeltsch <g9ks157k at acme.softbase.org> wrote:
> Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi:
>> I'll have to trust you, because I cannot test it.
>> let x=(1:x); y=(1:y) in x==y .
>> I also cannot test this:
>> let x=(1:x); y=1:1:y in x==y
> In these examples, x and y denote the same value but the result of x
> == y is _|_ (undefined) in both cases. So (==) is not really
> equality in Haskell but a kind of weak equality: If x doesn’t equal
> y, x == y is False, but if x equals y, x == y might be True or
[1..] == [1..] certainly isn't undefined, it always evaluates to True,
just like [2..] == [2..]. It just takes ghci eternity to prove, as its
runtime system doesn't even think of trying to put the axiom
forall n: if x == y then x + n == y + n
together with its knowledge about the equal stepping of the lists and
short-circuit to True.
More information about the Haskell-Cafe