Reputation: 407
I'm confused why for given data type
import Data.Data
data T a = T1 a | T2 deriving Data
the expression
toConstr (Just ()) == toConstr (T2 :: T Int)
returns True
, while
toConstr (Just ()) == toConstr (T1 ())
returns False
.
Related question
Upvotes: 0
Views: 136
Reputation: 1862
To quote the documentation -
Note that equality on constructors with different types may not work -- i.e. the constructors for False and Nothing may compare equal.
Just ()
is a constructor of Maybe ()
- it won't necessarily compare false to the constructors of T
.
Upvotes: 3