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

GHC ghc-devs at haskell.org
Mon Feb 1 14:32:28 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):

 An alternative to falling back to an entirely unindexed `TyCon` would be
 to augment it with a type-indexed version,
 {{{#!hs
 -- Metadata describing a type constructor. Same thing we currently have.
 data TyCon = TyCon { module, package, con_name :: String }

 -- A type constructor together with the kinds it was applied to (abstract)
 data TTyCon (a :: k) = TTyCon { tycon :: TyCon, dep_kinds :: [TypeRep],
 kind :: TTypeRep k }

 -- A type representation (abstract)
 data TTypeRep (a :: k) where
     TrTyCon :: Fingerprint -> TyCon a -> TTypeRep a
     TrApp   :: forall k1 k2 (a :: k1 -> k2) (b :: k1).
                Fingerprint -> TTypeRep a -> TTypeRep b -> TTypeRep (a b)

 pattern TRApp :: forall k k1 (a :: k1 -> k) (b :: k1).
                  TTypeRep a -> TTypeRep b -> TTypeRep (a b)

 pattern TRCon :: forall k (a :: k). TTyCon a -> TTypeRep a

 tyConDepKinds :: TTyCon a -> [TypeRep]

 tyConKind :: TTyCon (a :: k) -> TTypeRep k
 }}}

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


More information about the ghc-tickets mailing list