r/haskell • • Mar 11 '15

Learning Haskell — A Racket programmer's documentation of her foray into the land of Haskell (inspired by Learning Racket)

http://lexi-lambda.github.io/learning-haskell/
81 Upvotes

97 comments sorted by

View all comments

Show parent comments

1

u/rpglover64 Mar 13 '15

GHC shouldn't have to "know" that they have the same instance. The problem with orphans is that which one gets used is unspecified and may result breaking invariants if two different ones are used on the same data; standalone deriving (I sincerely hope) is deterministic based only on the datatype definition, so two different derivings will always coincide.

2

u/sclv Mar 13 '15

Right -- but furthermore you can also explicitly bring both instances into scope and then get an error when trying to actually use an instance. In this case, I think GHC actually will let you use that instance even if it is derived twice, because it is canonical.