Tidy up withDict and friends
We are considering (not decided!) to abandon newtype classes: see #20897.
However the reflection
library (important in practice) relies on the current
(undocumented) choice that single method classes are implemented by newtypes.
But that reliance is no longer necessary. This ticket collects the strands
of what we need to do to lift that dependency.
-
Re-implement withDict
: #19915. Status: done in !8249 (merged). This ticket describes a much, much nicer way to handlewithDict
, andtagToEnum
. -
Adapt API for GHC.TypeLits
andGHC.TypeNats
: #15183 (closed). Status: done in !9064 (merged). ExportssymbolSing
,SSymbol
, and related functionality to allow implementing the API in thereflection
library without needingunsafeCoerce
. This implements Core Libraries Committee proposal #85. -
Update reflection
library: this reflection ticket. Make thereflection
library usewithDict
, and remove all its uses ofunsafeCoerce
. There is a reflection ticket about this here.This step depends on:
- Step (2), in order to be able to implement
reflection
's API withoutunsafeCoerce
- Step (5), in order to be able to run
reflection
's test suite without miscompilations
- Step (2), in order to be able to implement
-
Add warnings to trigger in other libraries. Add a warning, which complains if you use unsafeCoerce
in a way that suggests you are relying on on newtype classes. (Asreflection
does now.) -
Fix withDict
interaction with the Specialiser: #21575, especially this comment. Status: partially done by !8241 (closed) and !8594 (merged), but one new issue has surfaced and the ticket remains open. -
runExists: #19675. The internals of GHC.TypeLits
is a bit of a mess too. #19675 suggests a way to clean it up. Mentioned here for completeness.