... | ... | @@ -55,7 +55,7 @@ But until GHC gets kind equalities we offer a variant ("homogeneous case") that |
|
|
### Without kind equalities
|
|
|
|
|
|
```
|
|
|
dataTypeRep(a :: k)-- abstractappR::TypeRep(a :: k -> k')->TypeRep(b :: k)->TypeRep(a b)classTypeable(a :: k)where
|
|
|
dataTypeRep(a :: k)-- abstracttypeRepFingerprint::TypeRep a ->FingerprintappR::TypeRep(a :: k -> k')->TypeRep(b :: k)->TypeRep(a b)classTypeable(a :: k)where
|
|
|
typeRep ::TypeRep a
|
|
|
|
|
|
-- GHC has magic built-in support for Typeable instances-- but the effect is similar to declarations like these:instance(Typeable c,Typeable a)=>Typeable(c a)instanceTypeableBoolinstanceTypeable(->)withTypeable::TypeRep a ->(Typeable a => b)-> b
|
... | ... | @@ -77,6 +77,10 @@ Notes: |
|
|
> We use a consistent naming scheme: put an `R` suffix on variants that take an explicit `TypeRep` parameter, no suffix for `Typeable` constraint versions.
|
|
|
|
|
|
- Note that the type `(:~:)` comes from `Data.Type.Equality`.
|
|
|
And `Fingerprint` is from `GHC.Fingerprint`.
|
|
|
|
|
|
- `typeRepFingerprint` is not used internally (although it could be for `eqRR`), but is provided for users.
|
|
|
e.g. to add consistency checks when using `Control.DistributedClosure` that two nodes agree on their static pointer table (or at least the types agree, if not the values).
|
|
|
|
|
|
- Note also `eqRR` is not hugely useful as (if it returns True) we know that types and kinds are the same, but GHC doesn't, so `unsafeCoerce` is often needed.
|
|
|
|
... | ... | @@ -120,6 +124,11 @@ In the kind-heterogeneous case, `getR1` and `getR2` come out of the TCB. |
|
|
|
|
|
- How many `getR1`, `getR2` etc should we provide?
|
|
|
|
|
|
- Currently, equality checks for `TypeRep`s are done recursively rather than using fingerprints, and once no-kinds is merged, it will actually build equality evidence out of smaller equality evidince.
|
|
|
However, using fingerprints and one `unsafeCoerce` may be more efficient (especially if fingerprints are cached in the datatype), but is argueably less principled, and certainly brings more code into the TCB.
|
|
|
Which method do we want to use?
|
|
|
Or perhaps provide both `eqRR` with fingerprints and `eqRRParanoid` recursively?
|
|
|
|
|
|
- Do we want explicit names for some type representations?
|
|
|
Perhaps `typeRepBool` etc., and just for Prelude defined types.
|
|
|
(It is nice to avoid writing `typeRep :: TypeRep Bool`)
|
... | ... | |