... | @@ -4,7 +4,7 @@ |
... | @@ -4,7 +4,7 @@ |
|
This page is the main root page for a re-design of the `Typeable` class, to make **type-indexed** type representations.
|
|
This page is the main root page for a re-design of the `Typeable` class, to make **type-indexed** type representations.
|
|
|
|
|
|
|
|
|
|
The main ticket for tracking progress is [\#11011](https://gitlab.haskell.org//ghc/ghc/issues/11011). There is currently an active implementation effort which is being documented at [Typeable/BenGamari](typeable/ben-gamari)
|
|
The main ticket for tracking progress is [\#11011](https://gitlab.haskell.org/ghc/ghc/issues/11011). There is currently an active implementation effort which is being documented at [Typeable/BenGamari](typeable/ben-gamari)
|
|
|
|
|
|
|
|
|
|
Relevant links
|
|
Relevant links
|
... | @@ -31,45 +31,45 @@ Use Keyword = `Typeable` to ensure that a ticket ends up on these lists. |
... | @@ -31,45 +31,45 @@ Use Keyword = `Typeable` to ensure that a ticket ends up on these lists. |
|
|
|
|
|
Open Tickets:
|
|
Open Tickets:
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10770">#10770</a></th>
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10770">#10770</a></th>
|
|
<td>Typeable solver has strange effects</td></tr>
|
|
<td>Typeable solver has strange effects</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11251">#11251</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11251">#11251</a></th>
|
|
<td>isInstance does not work on Typeable with base-4.8 anymore</td></tr>
|
|
<td>isInstance does not work on Typeable with base-4.8 anymore</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11349">#11349</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11349">#11349</a></th>
|
|
<td>[TypeApplications] Create Proxy-free alternatives of functions in base</td></tr>
|
|
<td>[TypeApplications] Create Proxy-free alternatives of functions in base</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11715">#11715</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11715">#11715</a></th>
|
|
<td>Constraint vs *</td></tr>
|
|
<td>Constraint vs *</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12451">#12451</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12451">#12451</a></th>
|
|
<td>TemplateHaskell and Data.Typeable - tcIfaceGlobal (local): not found</td></tr>
|
|
<td>TemplateHaskell and Data.Typeable - tcIfaceGlobal (local): not found</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13261">#13261</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13261">#13261</a></th>
|
|
<td>Consider moving Typeable evidence generation wholly back to solver</td></tr>
|
|
<td>Consider moving Typeable evidence generation wholly back to solver</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13276">#13276</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13276">#13276</a></th>
|
|
<td>Unboxed sums are not Typeable</td></tr>
|
|
<td>Unboxed sums are not Typeable</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13647">#13647</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13647">#13647</a></th>
|
|
<td>Tidy up TcTypeable</td></tr>
|
|
<td>Tidy up TcTypeable</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13933">#13933</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13933">#13933</a></th>
|
|
<td>Support Typeable instances for types with coercions</td></tr>
|
|
<td>Support Typeable instances for types with coercions</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14190">#14190</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14190">#14190</a></th>
|
|
<td>Typeable imposes seemingly redundant constraints on polykinded instances</td></tr>
|
|
<td>Typeable imposes seemingly redundant constraints on polykinded instances</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14255">#14255</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14255">#14255</a></th>
|
|
<td>Type-indexed type fingerprints</td></tr>
|
|
<td>Type-indexed type fingerprints</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14270">#14270</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14270">#14270</a></th>
|
|
<td>GHC HEAD's ghc-stage1 panics on Data.Typeable.Internal</td></tr>
|
|
<td>GHC HEAD's ghc-stage1 panics on Data.Typeable.Internal</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14337">#14337</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14337">#14337</a></th>
|
|
<td>typeRepKind can perform substantial amounts of allocation</td></tr>
|
|
<td>typeRepKind can perform substantial amounts of allocation</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14341">#14341</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14341">#14341</a></th>
|
|
<td>Show instance for TypeReps is a bit broken</td></tr>
|
|
<td>Show instance for TypeReps is a bit broken</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14401">#14401</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14401">#14401</a></th>
|
|
<td>Add a test ensuring that TypeReps can be stored in compact regions</td></tr>
|
|
<td>Add a test ensuring that TypeReps can be stored in compact regions</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14480">#14480</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14480">#14480</a></th>
|
|
<td>Clean up tyConTYPE</td></tr>
|
|
<td>Clean up tyConTYPE</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14582">#14582</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14582">#14582</a></th>
|
|
<td>Review and improve the Typeable API</td></tr>
|
|
<td>Review and improve the Typeable API</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14663">#14663</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14663">#14663</a></th>
|
|
<td>Deriving Typeable for enumerations seems expensive</td></tr>
|
|
<td>Deriving Typeable for enumerations seems expensive</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15322">#15322</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15322">#15322</a></th>
|
|
<td>`KnownNat` does not imply `Typeable` any more when used with plugin</td></tr>
|
|
<td>`KnownNat` does not imply `Typeable` any more when used with plugin</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15862">#15862</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15862">#15862</a></th>
|
|
<td>Panic with promoted types that Typeable doesn't support</td></tr></table>
|
|
<td>Panic with promoted types that Typeable doesn't support</td></tr></table>
|
|
|
|
|
|
|
|
|
... | @@ -77,55 +77,55 @@ Open Tickets: |
... | @@ -77,55 +77,55 @@ Open Tickets: |
|
|
|
|
|
Closed Tickets:
|
|
Closed Tickets:
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/3480">#3480</a></th>
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/3480">#3480</a></th>
|
|
<td>Easily make Typeable keys pure, so that Typeable can be handled efficiently across communications</td></tr>
|
|
<td>Easily make Typeable keys pure, so that Typeable can be handled efficiently across communications</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8931">#8931</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8931">#8931</a></th>
|
|
<td>The type defaulting in GHCi with Typeable</td></tr>
|
|
<td>The type defaulting in GHCi with Typeable</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9639">#9639</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9639">#9639</a></th>
|
|
<td>Remove OldTypeable</td></tr>
|
|
<td>Remove OldTypeable</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9707">#9707</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9707">#9707</a></th>
|
|
<td>(Try to) restructure `base` to allow more use of `AutoDeriveTypeable`</td></tr>
|
|
<td>(Try to) restructure `base` to allow more use of `AutoDeriveTypeable`</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10163">#10163</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10163">#10163</a></th>
|
|
<td>Export typeRepKinds in Data.Typeable</td></tr>
|
|
<td>Export typeRepKinds in Data.Typeable</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10343">#10343</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10343">#10343</a></th>
|
|
<td>Make Typeable track kind information better</td></tr>
|
|
<td>Make Typeable track kind information better</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11011">#11011</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11011">#11011</a></th>
|
|
<td>Add type-indexed type representations (`TypeRep a`)</td></tr>
|
|
<td>Add type-indexed type representations (`TypeRep a`)</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11120">#11120</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11120">#11120</a></th>
|
|
<td>Missing type representations</td></tr>
|
|
<td>Missing type representations</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11714">#11714</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11714">#11714</a></th>
|
|
<td>Kind of (->) type constructor is overly constrained</td></tr>
|
|
<td>Kind of (->) type constructor is overly constrained</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11722">#11722</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11722">#11722</a></th>
|
|
<td>No TypeRep for unboxed tuples</td></tr>
|
|
<td>No TypeRep for unboxed tuples</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11736">#11736</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11736">#11736</a></th>
|
|
<td>Allow unsaturated uses of unlifted types in Core</td></tr>
|
|
<td>Allow unsaturated uses of unlifted types in Core</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12082">#12082</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12082">#12082</a></th>
|
|
<td>Typeable on RealWorld fails</td></tr>
|
|
<td>Typeable on RealWorld fails</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12123">#12123</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12123">#12123</a></th>
|
|
<td>GHC crashes when calling typeRep on a promoted tuple</td></tr>
|
|
<td>GHC crashes when calling typeRep on a promoted tuple</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12409">#12409</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12409">#12409</a></th>
|
|
<td>Unboxed tuples have no type representations</td></tr>
|
|
<td>Unboxed tuples have no type representations</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12670">#12670</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12670">#12670</a></th>
|
|
<td>Representation polymorphism validity check is too strict</td></tr>
|
|
<td>Representation polymorphism validity check is too strict</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12905">#12905</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12905">#12905</a></th>
|
|
<td>Core lint failure with pattern synonym and levity polymorphism</td></tr>
|
|
<td>Core lint failure with pattern synonym and levity polymorphism</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13197">#13197</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13197">#13197</a></th>
|
|
<td>Perplexing levity polymorphism issue</td></tr>
|
|
<td>Perplexing levity polymorphism issue</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13333">#13333</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13333">#13333</a></th>
|
|
<td>Typeable regression in GHC HEAD</td></tr>
|
|
<td>Typeable regression in GHC HEAD</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13871">#13871</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13871">#13871</a></th>
|
|
<td>GHC panic in 8.2 only: typeIsTypeable(Coercion)</td></tr>
|
|
<td>GHC panic in 8.2 only: typeIsTypeable(Coercion)</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13872">#13872</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13872">#13872</a></th>
|
|
<td>Strange Typeable error message involving TypeInType</td></tr>
|
|
<td>Strange Typeable error message involving TypeInType</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13915">#13915</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13915">#13915</a></th>
|
|
<td>GHC 8.2 regression: "Can't find interface-file declaration" for promoted data family instance</td></tr>
|
|
<td>GHC 8.2 regression: "Can't find interface-file declaration" for promoted data family instance</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14199">#14199</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14199">#14199</a></th>
|
|
<td>Document Type.Reflection better (Fun and Con')</td></tr>
|
|
<td>Document Type.Reflection better (Fun and Con')</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14254">#14254</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14254">#14254</a></th>
|
|
<td>The Binary instance for TypeRep smells a bit expensive</td></tr>
|
|
<td>The Binary instance for TypeRep smells a bit expensive</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/14925">#14925</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/14925">#14925</a></th>
|
|
<td>Non-ASCII type names get garbled when their `TypeRep` is shown</td></tr>
|
|
<td>Non-ASCII type names get garbled when their `TypeRep` is shown</td></tr>
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15067">#15067</a></th>
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15067">#15067</a></th>
|
|
<td>When Typeable and unboxed sums collide, GHC panics</td></tr></table>
|
|
<td>When Typeable and unboxed sums collide, GHC panics</td></tr></table>
|
|
|
|
|
|
|
|
|
... | @@ -341,7 +341,7 @@ kindRep :: TTypeRep (a :: k) -> TTypeRep k |
... | @@ -341,7 +341,7 @@ kindRep :: TTypeRep (a :: k) -> TTypeRep k |
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
in the API. I (Richard) conjecture that this is all possible without kind equalities, but would be rather awkward due to GHC's insistence that kind parameters be implicit. See [\#10343](https://gitlab.haskell.org//ghc/ghc/issues/10343), which inspired this bit.
|
|
in the API. I (Richard) conjecture that this is all possible without kind equalities, but would be rather awkward due to GHC's insistence that kind parameters be implicit. See [\#10343](https://gitlab.haskell.org/ghc/ghc/issues/10343), which inspired this bit.
|
|
|
|
|
|
---
|
|
---
|
|
|
|
|
... | @@ -614,7 +614,7 @@ The class declaration for `Typeable` is highly suspect, as it is manifestly cycl |
... | @@ -614,7 +614,7 @@ The class declaration for `Typeable` is highly suspect, as it is manifestly cycl |
|
### `unsafeCoerce` can be written
|
|
### `unsafeCoerce` can be written
|
|
|
|
|
|
|
|
|
|
As painfully demonstrated (painful in the conclusion, not the demonstration!) in [comment:16:ticket:9858](https://gitlab.haskell.org//ghc/ghc/issues/9858), `Typeable` can now (7.10.1 RC1) be abused to write `unsafeCoerce`. The problem is that today's `TypeRep`s ignore kind parameters.
|
|
As painfully demonstrated (painful in the conclusion, not the demonstration!) in [comment:16:ticket:9858](https://gitlab.haskell.org/ghc/ghc/issues/9858), `Typeable` can now (7.10.1 RC1) be abused to write `unsafeCoerce`. The problem is that today's `TypeRep`s ignore kind parameters.
|
|
|
|
|
|
|
|
|
|
|
|
|
... | @@ -658,7 +658,7 @@ we actually supply a kind parameter `k0`. GHC tries to find a value for `k0`, fa |
... | @@ -658,7 +658,7 @@ we actually supply a kind parameter `k0`. GHC tries to find a value for `k0`, fa |
|
|
|
|
|
**NB:** This was not implemented. The "medium-term solution" below was, as of 7.10.1.
|
|
**NB:** This was not implemented. The "medium-term solution" below was, as of 7.10.1.
|
|
|
|
|
|
[comment:16:ticket:9858](https://gitlab.haskell.org//ghc/ghc/issues/9858) is a demonstration that the boat is taking on water! Fix the leak, fast!
|
|
[comment:16:ticket:9858](https://gitlab.haskell.org/ghc/ghc/issues/9858) is a demonstration that the boat is taking on water! Fix the leak, fast!
|
|
|
|
|
|
|
|
|
|
The "obvious" answer -- don't supply the `k` here -- doesn't work. The instance for `PK` would become `Typeable <forall k. k -> *> PK`, where a normally-implicit kind parameter is supplied in angle brackets. This is an **impredicative kind**, certainly beyond GHC's type system's abilities at the moment, especially in a type-class argument.
|
|
The "obvious" answer -- don't supply the `k` here -- doesn't work. The instance for `PK` would become `Typeable <forall k. k -> *> PK`, where a normally-implicit kind parameter is supplied in angle brackets. This is an **impredicative kind**, certainly beyond GHC's type system's abilities at the moment, especially in a type-class argument.
|
... | @@ -686,7 +686,7 @@ That, then, is the current plan of attack. (**No, it's not.**) `Typeable` instan |
... | @@ -686,7 +686,7 @@ That, then, is the current plan of attack. (**No, it's not.**) `Typeable` instan |
|
**This is implemented in 7.10.**
|
|
**This is implemented in 7.10.**
|
|
|
|
|
|
|
|
|
|
Although it is impossible to create all necessary `Typeable` instances for poly-kinded constructors at the definition site (there's an infinite number), it *is* possible to create `Typeable` "instances" on demand at use sites. The idea (originally proposed in [comment:20:ticket:9858](https://gitlab.haskell.org//ghc/ghc/issues/9858)) is to add some custom logic to the solver to invent `Typeable` evidence on demand. Then, whenever the solver needs to satisfy a `Typeable` constraint, it will just recur down to the type's leaves and invent evidence there.
|
|
Although it is impossible to create all necessary `Typeable` instances for poly-kinded constructors at the definition site (there's an infinite number), it *is* possible to create `Typeable` "instances" on demand at use sites. The idea (originally proposed in [comment:20:ticket:9858](https://gitlab.haskell.org/ghc/ghc/issues/9858)) is to add some custom logic to the solver to invent `Typeable` evidence on demand. Then, whenever the solver needs to satisfy a `Typeable` constraint, it will just recur down to the type's leaves and invent evidence there.
|
|
|
|
|
|
|
|
|
|
For poly-kinded type constructors, we still need to worry about kind parameters. This is easy, actually: we just come up with some mechanism with which to incoporate kind parameters into a `TypeRep`s fingerprint. One such mechanism would be to use the current fingerprint-generation algorithm (used on types) and just apply it to the kinds. Of course, kinds are different from types, but there's no reason we can't use the same algorithm. Problem solved.
|
|
For poly-kinded type constructors, we still need to worry about kind parameters. This is easy, actually: we just come up with some mechanism with which to incoporate kind parameters into a `TypeRep`s fingerprint. One such mechanism would be to use the current fingerprint-generation algorithm (used on types) and just apply it to the kinds. Of course, kinds are different from types, but there's no reason we can't use the same algorithm. Problem solved.
|
... | | ... | |