You may know about the following completely normal behaviour in javascript from the excellent talk by Gary Bernhardt entitled "wat":
js> {} + []
0
js> {} - []
-0
js> [] - {}
NaN
js> [] + {}
"[object Object]"
Enough about languages that are definitely not haskell[1], let's talk about nix
» nix repl
Welcome to Nix 2.11.0. Type :? for help.
nix-repl> f = a: a
As we know, we can define functions. A slightly less known fact is that they are not equal to each other, but that is generally a reasonable idea because meaningful function equality is undecidable in general:
nix-repl> f == f
false
You can also define attribute sets:
nix-repl> s = { x = 1; }
nix-repl> s == s
true
Equality on attribute sets is value based, based on the values of the attributes:
nix-repl> s' = { x = 1; }
nix-repl> s == s'
true
As we can clearly see, the equality depends on the equality of the attributes themselves and not their identity:
nix-repl> s2 = { check = f; }
nix-repl> s2 == s2
true
nix-repl> s3 = { check = f; }
nix-repl> s2 == s3
true
wat.
This "feature" is "will remove eventually" as of 2010 and is depended on by the nixpkgs initialization code since it compares lib.types.* values containing check lambdas. I somehow don't think "eventually" is happening very soon.
This poast brought to you by @puckipedia.
[1] actual haskell content may vary. conditions apply.