<br><div class="gmail_quote">On Tue, Aug 28, 2012 at 12:08 PM, Nicolas Frisby <span dir="ltr"><<a href="mailto:nicolas.frisby@gmail.com" target="_blank">nicolas.frisby@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Aug 28, 2012 at 3:34 AM, Simon Marlow <<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>> wrote:<br>
>>>> On 24/08/2012 07:39, Emil Axelsson wrote:<br>
>>>>><br>
</div><div class="im">>>>>> Are there any dangers in comparing two StableNames of different type?<br>
>>>>><br>
>>>>> stEq :: StableName a -> StableName b -> Bool<br>
>>>>> stEq a b = a == (unsafeCoerce b)<br>
>>>><br>
</div><div class="im">> Ok, I've added it. It will be in GHC 7.8.1.<br>
><br>
> Cheers,<br>
> Simon<br>
<br>
</div>Might we benefit from having a variant that returns Maybe (a :=: b)?<br>
Is that safe? I have limited experience with StableNames, but that<br>
intuitively seems safe. But polymorphism and references deserve more<br>
thought than I've given this yet.<br>
<br>
I'm referring to "data (:=:) :: * -> * -> * where Refl :: (a :=: a)",<br>
just to be clear.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div>No.</div><div class="gmail_quote"><br></div><div class="gmail_quote">You can't safely determine that a ~ b given that two stablenames are equal.<div>
<br></div><div>If you give Nothing a stableName, it'll have one stable name, regardless of if you use it as a Maybe Int or a Maybe Bool. Maybe Int and Maybe Bool are clearly not equal. This is admittedly an implementation detail. GHC would be perfectly within its rights (if somewhat silly) to construct a fresh Nothing every time, but it doesn't.</div>
<div><br></div><div>The reasoning you applied only works for fully monomorphic types.</div><div><br></div><div> -Edward</div></div>