[GHC] #2850: GeneralizedNewtypeDeriving + TypeFamilies doesn't work

GHC ghc-devs at haskell.org
Thu Nov 21 14:09:51 UTC 2013


#2850: GeneralizedNewtypeDeriving + TypeFamilies doesn't work
-------------------------------------------------+-------------------------
        Reporter:  ajd                           |            Owner:
            Type:  feature request               |           Status:
        Priority:  normal                        |  closed
       Component:  Compiler                      |        Milestone:  6.12
      Resolution:  fixed                         |  branch
Operating System:  Unknown/Multiple              |          Version:
 Type of failure:  None/Unknown                  |  6.10.1
       Test Case:                                |         Keywords:
  indexed_types/should_compile/T2850             |     Architecture:
        Blocking:                                |  Unknown/Multiple
                                                 |       Difficulty:
                                                 |  Unknown
                                                 |       Blocked By:
                                                 |  Related Tickets:
-------------------------------------------------+-------------------------

Comment (by goldfire):

 Interesting corner case.

 Answer: perhaps, but it would take a little more engineering. The problem
 is that `B`'s role is very rightly nominal. It's perfectly conceivable for
 `B Age` and `B Int` to be unrelated. But, we still want `B Bool ~R B Int`.
 The way this might be possible is by using the ''representation'' tycons
 for data families before doing the `Coercible` stuff. And, it means that
 these representation tycons would also need to be given appropriate roles.
 Currently, they're all nominal (see
 [http://git.haskell.org/ghc.git/blob/HEAD:/compiler/typecheck/TcInstDcls.lhs#l700
 the source code]).

 This all seems quite possible, but as I said, somewhat more engineering to
 make work. I can take a look at inferring roles for data/newtype
 instances. (I suppose these means also making role signatures for these
 forms. Grrrr.....) Do you think it's possible for the `Coercible` stuff to
 work over representation tycons for data/newtype instances?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2850#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list