[GHC] #11011: Add type-indexed type representations (`TypeRep a`)

GHC ghc-devs at haskell.org
Sun Jan 31 18:38:59 UTC 2016


#11011: Add type-indexed type representations (`TypeRep a`)
-------------------------------------+-------------------------------------
        Reporter:  bjmprice          |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:
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 bgamari):

 Also, Richard pointed out in IRC that the TyCon representations that I
 produce in my current implementation are too weakly typed and would mean
 that we #10000 (also #9858) would remain (at least if we allowed something
 like `TyCon -> TypeRep`, which the current `Typeable` does not).

 To fix this, we need to make the user provide type representations for the
 concrete kinds he wishes to instantiate at before giving him a
 representation. For instance, `Proxy`'s representation would look like,
 {{{#!hs
 data TyCon a

 proxyTyCon :: TypeRep k -> TyCon (Proxy :: k -> *)
 proxyTyCon = ...
 }}}

 However, this makes an already complex story even more complex. Even
 worse, it will make all module with type definitions pay even more in both
 compilation time and code size due to the lambdas. `TyCon`s are currently
 nice pure records with quite efficient representations. It would be nice
 to retain this property.

 In light of this, perhaps it would be reasonable to consider an
 alternative:

 == An alternative: TyCon entirely ==

 An appealing alternative here would be to remove `TyCon` from the user-
 facing interface entirely. This would mean that it can remain unindexed,
 `TyCon` is already more-or-less an implementation detail and I can't think
 of any reason why a `TypeRep` wouldn't do.

 Removing `TyCon` from the interface would be a substantial simplification
 to the scheme and neither Richard nor I could think of any reason why it
 is strictly necessary.

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


More information about the ghc-tickets mailing list