Hi, Am Freitag, den 06.09.2013, 16:47 +0000 schrieb Simon Peyton-Jones: > So > > * for newtypes > newtype N a = MkN <rep-ty> > the coercion is between (N a) and its representation type <rep_ty>. > The coercion is allowed if the data constructor MkN is in scope > > * for data types (T a), the coercion is between (T a) and (T b), > The coercion is allowed if the roles allow it. > > The two are handled quite differently. > > OK? This is far from obvious (since I was very confused about it), so worth > writing up on the design page. As well as implementing.
Sounds reasonable. Implementation is simple, I just remove the check that I had added: https://github.com/nomeata/ghc/commit/46c6c7 https://github.com/nomeata/ghc-testsuite/commit/d5c13 One question which is left open, which I cannot answer: Are there situations where the library author wants to prevent coercion, but needs a non-Nominal role for some other reasons? But we’ll see. > Roles are in HEAD so you can use them right now. I know, my patch is against head and already makes use of roles: TcCoercibleFail.hs:16:8: No instance for (Coercible (Map Int ()) (Map Age ())) because the first type argument of ‛Map’ has role Nominal, but the arguments ‛Int’ and ‛Age’ differ arising from a use of ‛coerce’ In the expression: coerce In the expression: coerce $ Map one () :: Map Age () In an equation for ‛foo3’: foo3 = coerce $ Map one () :: Map Age () Greetings, Joachim -- Joachim “nomeata” Breitner m...@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nome...@joachim-breitner.de • GPG-Key: 0x4743206C Debian Developer: nome...@debian.org
signature.asc
Description: This is a digitally signed message part
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs