hoistWithKey :: (forall x. Typeable x => f x -> g x) -> TypeRepMap f -> TypeRepMap g
Adding this function will require adding another vector that will store TypeReps:
data TypeRepMap (f :: k -> Type) =
TypeRepMap
{ fingerprintAs :: {-# UNPACK #-} !(PrimArray Word64) -- ^ first components of key fingerprints
, fingerprintBs :: {-# UNPACK #-} !(PrimArray Word64) -- ^ second components of key fingerprints
, anys :: {-# UNPACK #-} !(Array Any) -- ^ values stored in the map
, keys :: {-# UNPACK #-} !(Array Any) -- ^ typerep keys
}
In hoistWithKey we can access a corresponding element in keys, cast it to TypeRep a and then apply https://hackage.haskell.org/package/base-4.11.1.0/docs/Type-Reflection.html#v:withTypeable to get the Typeable instance.
I'm hoping it won't affect the performance of lookups: the cachedBinarySearch function will stay unchanged.
Implementation plan:
- add the
keys field, check that the benchmarks show no change
- implement
hoistWithKey. it should be probably available only on 8.2+ because it relies on the new TypeRep for withTypeable
Adding this function will require adding another vector that will store
TypeReps:In
hoistWithKeywe can access a corresponding element inkeys, cast it toTypeRep aand then apply https://hackage.haskell.org/package/base-4.11.1.0/docs/Type-Reflection.html#v:withTypeable to get theTypeableinstance.I'm hoping it won't affect the performance of lookups: the
cachedBinarySearchfunction will stay unchanged.Implementation plan:
keysfield, check that the benchmarks show no changehoistWithKey. it should be probably available only on 8.2+ because it relies on the newTypeRepforwithTypeable