unsafeCoerce and type aliases under type applications

Isaac Dupree ml at isaac.cedarswampstudios.org
Sun Dec 4 19:38:41 CET 2011


On 12/04/2011 12:40 PM, Felipe Almeida Lessa wrote:
> On Sun, Dec 4, 2011 at 3:30 PM, Erik Hesselink<hesselink at gmail.com>  wrote:
>> It's not just type families though, right? I mean, a (Map A) cannot be
>> coerced to a (Map B), even if B is a newtype over A, since they might
>> have different Ord instances, and thus a different map structure.
>
> It depends on what you call "safe".  The bug Brent Yorgey was
> referring to allows you to get sefaults and the like.  The bug you're
> describing violates some invariants, but these invariants are not
> expressed in the type system and won't make a hard crash of your
> program.

This problem could be addressed by the hypothetical safe-coercion 
operator requiring any relevant constructors to be in scope.  (Alas, 
then it would have to be magical syntax.)

-Isaac



More information about the Libraries mailing list