unsafeCoerce and type aliases under type applications

Erik Hesselink hesselink at gmail.com
Sun Dec 4 20:39:55 CET 2011


On Sun, Dec 4, 2011 at 18:40, Felipe Almeida Lessa
<felipe.lessa at gmail.com> 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.

Ah, you are right of course. The Ord case is the same as having a
hidden constructor, and a partial construction function which verifies
some invariant. As you mention, the type family case is substantially
different.

Erik



More information about the Libraries mailing list