<div dir="ltr"><div dir="ltr">I'd like to propose adding a bunch of instances for TestEquality and TestCoercion to base and primitive types such as: IORef, STRef s, MVar as well as MutVar and any appropriately uncoercible array types we have in primitive.</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">With these you can learn about the equality of the types of elements of an STRef when you go to</div><div dir="ltr"><br></div><div dir="ltr">     testEquality :: STRef s a -> STRef s b -> Maybe (a :~: b)<br><div><br></div><div>I've been using an ad hoc versions of this on my own for some time, across a wide array of packages, based on Atze van der Ploeg's paper: <a href="https://dl.acm.org/citation.cfm?id=2976008">https://dl.acm.org/citation.cfm?id=2976008</a> and currently I get by by unsafeCoercing reallyUnsafePointerEquality# and unsafeCoercing the witness that I get back in turn. =/</div><div><br></div><div>With this the notion of a "Key" introduced there can be safely modeled with an STRef s (Proxy a).</div><div><br></div><div>This would make it {-# LANGUAGE Safe #-} for users to construct heterogeneous container types that don't need Typeable information about the values.</div></div></div><div dir="ltr"><br></div><div dir="ltr">Implementation wise, these can either use the value equality of those underlying primitive types and then produce a witness either by unsafeCoerce, or by adding new stronger primitives in ghc-prim to produce the witness in a type-safe manner, giving us well typed core all the way down.</div><div dir="ltr"><br></div><div>-Edward</div><div dir="ltr"><div></div></div></div>