Scratching at the surface of Haskell's type system, ran this:
Prelude> e = [] Prelude> ec = tail "a" Prelude> en = tail [1] Prelude> :t e e :: [a] Prelude> :t ec ec :: [Char] Prelude> :t en en :: Num a => [a] Prelude> en == e True Prelude> ec == e True Somehow, despite en and ec have different types, they both test True on == e. I say "somehow" not because I am surprised (I am not), but because I don't know what is the name of rule/mechanism that allows this. It is as if the type variable "a" in the expression "[] == en" is allowed to take on value of "Num" for the evaluation. And likewise when tested with "[] == ec", it is allowed to become "Char".
The reason I'm not sure my interpretation is correct is this:
Prelude> (en == e) && (ec == e) True , because intuitively this implies that in the same expression e assumes both values of Num and Char "at the same time" (at least that's how I'm used to interpret the semantics of &&). Unless the "assumption" of Char only acts during the evaluation of (ec == e), and (en == e) is evaluated independently, in a separate... reduction? (I'm guessing on a terminology here).
And then comes this:
Prelude> en == es <interactive>:80:1: error: • No instance for (Num Char) arising from a use of ‘en’ • In the first argument of ‘(==)’, namely ‘en’ In the expression: en == es In an equation for ‘it’: it = en == es Prelude> es == en <interactive>:81:7: error: • No instance for (Num Char) arising from a use of ‘en’ • In the second argument of ‘(==)’, namely ‘en’ In the expression: es == en In an equation for ‘it’: it = es == en Not surprise by the exception, but surprised that in both tests, the error message complains about "the use of 'en'" - and doesn't matter if it's the first or second operand.
Perhaps an important lesson needs to be learned about Haskell type system. Thank you for your time!