[Haskell-cafe] Consequences of newtype deriving implementation w.r.t. base classes

Simon Peyton-Jones simonpj at microsoft.com
Tue Mar 13 12:51:15 EDT 2007

| I just noticed some unexpected consequences of the way newtype deriving
| is implemented in GHC. Because the dictionary of the underlying type is
| reused, so are base classes. This message is a literate Haskell program
| illustrating the problem.

Excellent point.

| As a solution I would suggest that newtype deriving a class instance is
| only allowed if all base classes instances are also derived using
| newtype deriving. This presents problems for Show and Read, because they
| cannot be derived in that way. It will, however, catch problems with
| most other classes.

Yes, I think you are right.  I'll make a Trac bug report for it; but I think I'll fix it in the HEAD only.


More information about the Haskell-Cafe mailing list