xafizoff
xafizoff

Reputation: 407

Confused with Data.Data.toConstr

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

Answers (1)

Isaac van Bakel
Isaac van Bakel

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

Related Questions