[GHC] #11732: Deriving Generic1 interacts poorly with TypeInType

GHC ghc-devs at haskell.org
Mon Mar 21 16:38:30 UTC 2016


#11732: Deriving Generic1 interacts poorly with TypeInType
-------------------------------------+-------------------------------------
        Reporter:  goldfire          |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:  TypeInType,
                                     |  Generics
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Replying to [comment:2 goldfire]:
 > I claim that
 >
 > {{{
 > data Proxy k (a :: k) = ProxyCon deriving Generic1
 > }}}
 >
 > should fail outright. I don't think GHC should be in the business of
 inferring values for visible parameters like `k`, even when it could.

 Agreed.

 > Instead, it should be this:
 >
 > {{{
 > deriving instance Generic1 (Proxy *)
 > }}}

 I'm OK with this idea, but we'd need to be able to teach
 `gen_Generic_binds` about substituting type variables for user-supplied
 types somehow, since they are reflected in the generated `Rep`/`Rep1`
 associated type instance. I have no idea how challenging that would be to
 implement.

 > Note that this applies to `Functor` as much as it does to `Generic1`.

 So you'd propose applying an instantiation check to every class in a
 `deriving` clause, then?

 > As for the `partitionInvisibles` piece: yes, that is all suspicious. I
 conjecture that we should never call `partitionInvisibles` on a data
 ''instance'' tycon, but only on the data ''family'' tycon.

 That's what we're doing at the moment, no? We're calling
 `filterOutInvisibleTypes` in `canDoGenerics`
 [http://git.haskell.org/ghc.git/blob/c37a583fb9059053f83f1ab0c3cb7eb7047b1a31:/compiler/typecheck/TcGenGenerics.hs#l155
 here] (which indirectly invokes `partitionInvisibles`), and your
 [https://git.haskell.org/ghc.git/commitdiff/1eefedf7371778d1721d9af9247c2eff12ae7417
 earlier patch] changed the `TyCon` being passed to
 `filterOutInvisibleTypes` to the data family tycon.

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


More information about the ghc-tickets mailing list