True | False | 1 :: Int | 0 :: Int | -1 :: Int | 1 :: Double | 0 :: Double | -1 :: Double | Infinity | -Infinity | NaN | "True" | "False" | "1" | "0" | "-1" | "" | [] | [[]] | [0 :: Int] | [1 :: Int] | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
True | |||||||||||||||||||||
False | |||||||||||||||||||||
1 :: Int | |||||||||||||||||||||
0 :: Int | |||||||||||||||||||||
-1 :: Int | |||||||||||||||||||||
1 :: Double | |||||||||||||||||||||
0 :: Double | |||||||||||||||||||||
-1 :: Double | |||||||||||||||||||||
Infinity | |||||||||||||||||||||
-Infinity | |||||||||||||||||||||
NaN | |||||||||||||||||||||
"True" | |||||||||||||||||||||
"False" | |||||||||||||||||||||
"1" | |||||||||||||||||||||
"0" | |||||||||||||||||||||
"-1" | |||||||||||||||||||||
"" | |||||||||||||||||||||
[] | |||||||||||||||||||||
[[]] | |||||||||||||||||||||
[0 :: Int] | |||||||||||||||||||||
[1 :: Int] |
x == y ↠ True | |
x == y ↠ False | |
Type error (mismatched types) | |
Type error (ambiguous type, requires explicit type annotation, True once ambiguity is resolved) | |
Type error (ambiguous type, requires explicit type annotation, False once ambiguity is resolved) |
NaN
is unequal to itself according to the floating point standard.""
is identical to [] :: [Char]
, so they are
equal.[]
cannot be compared to itself directly, because the
concrete type of the contained values is unknown, and the right
Eq
instance cannot be found. Adding explicit type
annotations solves this issue, ([] :: [Int]) == []
is
True
. (Note that GHCi has extended default rules, picking
[] :: [()]
to make this sort of ambiguity somewhat easier
to work with in the REPL meant for fast one-liners.)