
#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): Another question that I stumbled upon is whether we should provide something akin to `Data.Typeable.splitPolyTyConApp`, which provides access to the kind arguments which a type constructor was applied to. In some cases there may be no way to extract these kinds otherwise. Consider the following, {{{#!hs data Proxy (a :: k) = Proxy proxyIntRep :: TypeRep (Proxy Int) proxyIntRep = typeRepKind proxyIntRep data Compose (f :: k1 -> *) (g :: k2 -> k1) (x :: k2) = Compose (f (g a)) data Id a = Id a composeIdIdRep :: TypeRep (Compose Id Id) composeIdIdRep = typeRep -- The plan currently allows data AppResult (t :: k) where App :: TypeRep a → TypeRep b → AppResult (a b) splitApp :: TypeRep a → Maybe (AppResult a) typeRepKind :: TypeRep (a :: k) -> TypeRep k -- Allowing one to get concrete kind of Proxy proxyIntKind :: TypeRep (* -> *) proxyIntKind = typeRepKind proxyIntRep -- In the case of `Proxy Int` we can extract the first kind argument, -- `k ~ *`, trivially via function decomposition as it is the -- kind of the first type. pattern TRFun :: fun ~ (arg -> res) => TTypeRep arg -> TTypeRep res -> TTypeRep fun -- In contrast, determining the instantiation of `k1` in the case of -- `Compose Id Id` is not possible since it is not exposed in -- the resulting kind. composeIdIdKind :: TypeRep (* -> *) composeIdIdKind = kindRep composeIdIdRep }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11011#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler