Proposal: instance TestEquality IORef

Richard Eisenberg eir at cis.upenn.edu
Sun Jun 1 14:45:52 UTC 2014


This deduction is not true in the presence of `coerce`. Specifically, with

> newtype Age = MkAge Int
> x :: IORef Int

we can say

> y :: IORef Age
> y = coerce x

But, I do think Ashley's idea might work for TestCoercion, instead of TestEquality. I'm not 100% sure without More Thought, but it seems reasonable.

Richard

On Jun 1, 2014, at 2:13 AM, Ashley Yakeley <ashley at semantic.org> wrote:

> The base package includes the class Data.Type.Equality.TestEquality, for types from which type equality can be deduced from values.
> 
> Given values ra rb of types "IORef a" and "IORef b", if they are the same value (i.e. ra == unsafeCoerce rb), then one can deduce "a ~ b". Therefore, IORef can be made an instance of TestEquality. The same is true for various other reference types.
> 
> I propose these instances in base:
> 
>  instance TestEquality IORef
>  instance TestEquality (STRef s)
> 
> -- Ashley Yakeley
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list