[Haskell-cafe] GADT and instance deriving

Niklas Hambüchen mail at nh2.me
Fri May 24 19:41:53 CEST 2013


On Sat 25 May 2013 00:37:59 SGT, TP wrote:
> Is this the right way to go? Is there any other solution?

I believe whether it's right or just depends on what you want to express.

> Do you confirm that tilde in s~s1 means "s has the same type as s1"?

It means: Both your s and s1 are "Eq"s but not necessarily the same one.

Your first example allows that, so you could have one with an Int and
one with a String inside (both are Eqs).

    a = Box 1
    b = Box "hello"

Now if that first code compiled, your code

    (Box s1) == (Box s2) = s1 == s2

would effectively perform

    ... = 1 == "hello"

which is not possible.



More information about the Haskell-Cafe mailing list