small hiccup in new GND check

Hi all, The implementation of the new GND check is done and was rather straightforward. But, it brings up a new design issue: With the old check, a writer of a class C could say `type role C nominal` to prevent GND use with that class. Now, all classes have nominal parameters, and there is no (clean) way for a class writer to stop the use of GND. Perhaps this is OK -- classes can't in general be abstract -- but I thought we should pause a moment to reflect on this consequence of the design. For the curious, you can see the code in my github fork at https://raw.github.com/goldfirere/ghc/master/compiler/typecheck/TcDeriv.lhs (search for `role_errs`). An example of the new error message is in https://github.com/goldfirere/testsuite/blob/master/tests/roles/should_fail/... I'm running further tests now, so wibbles to the above may happen. Richard

I think that's ok. It's the situation right now. Simon From: Richard Eisenberg [mailto:eir@cis.upenn.edu] Sent: 21 October 2013 18:08 To: ghc-devs Devs; Simon Peyton-Jones; Edward Kmett Subject: small hiccup in new GND check Hi all, The implementation of the new GND check is done and was rather straightforward. But, it brings up a new design issue: With the old check, a writer of a class C could say `type role C nominal` to prevent GND use with that class. Now, all classes have nominal parameters, and there is no (clean) way for a class writer to stop the use of GND. Perhaps this is OK -- classes can't in general be abstract -- but I thought we should pause a moment to reflect on this consequence of the design. For the curious, you can see the code in my github fork at https://raw.github.com/goldfirere/ghc/master/compiler/typecheck/TcDeriv.lhs (search for `role_errs`). An example of the new error message is in https://github.com/goldfirere/testsuite/blob/master/tests/roles/should_fail/... I'm running further tests now, so wibbles to the above may happen. Richard

Hi, Am Montag, den 21.10.2013, 13:08 -0400 schrieb Richard Eisenberg:
For the curious, you can see the code in my github fork at https://raw.github.com/goldfirere/ghc/master/compiler/typecheck/TcDeriv.lhs (search for `role_errs`). An example of the new error message is in https://github.com/goldfirere/testsuite/blob/master/tests/roles/should_fail/...
you say Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; ‛meth’, specialized to type ‛a -> F a’, cannot be converted safely In the newtype declaration for ‛Age’ but shouldn’t that be either Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; the type of ‛meth’, ‛a -> F a’, cannot be converted safely In the newtype declaration for ‛Age’ or Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; ‛meth’, specialized to type ‛Age -> F Age’, cannot be converted safely In the newtype declaration for ‛Age’ (I’m confused by “specialized to” when the type as printed is not specialized.) Greetings, Joachim -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de

Good point. I will refine.
The reason it says "specialized" is that type variables other than the last one might be specialized. The class in this example has only one type parameter, so "specialized" is specious. I can fine-tune the error message to print "specialized" only when it actually has been.
Thanks,
Richard
On Oct 22, 2013, at 4:50 AM, Joachim Breitner
Hi,
Am Montag, den 21.10.2013, 13:08 -0400 schrieb Richard Eisenberg:
For the curious, you can see the code in my github fork at https://raw.github.com/goldfirere/ghc/master/compiler/typecheck/TcDeriv.lhs (search for `role_errs`). An example of the new error message is in https://github.com/goldfirere/testsuite/blob/master/tests/roles/should_fail/...
you say Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; ‛meth’, specialized to type ‛a -> F a’, cannot be converted safely In the newtype declaration for ‛Age’
but shouldn’t that be either
Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; the type of ‛meth’, ‛a -> F a’, cannot be converted safely In the newtype declaration for ‛Age’
or
Roles10.hs:16:12: Can't make a derived instance of ‛C Age’ (even with cunning newtype deriving): it is not type-safe to use GeneralizedNewtypeDeriving on this class; ‛meth’, specialized to type ‛Age -> F Age’, cannot be converted safely In the newtype declaration for ‛Age’
(I’m confused by “specialized to” when the type as printed is not specialized.)
Greetings, Joachim
-- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs
participants (3)
-
Joachim Breitner
-
Richard Eisenberg
-
Simon Peyton-Jones