[Haskell-cafe] Safe Haskell and instance coherence

Mikhail Glushenkov the.dead.shall.rise at gmail.com
Mon Oct 8 21:11:09 CEST 2012


It's a relatively well-known fact that GHC allows for multiple type
class instances for the same type to coexist in a single program. This
can be used, for example, to construct values of the type Data.Set.Set
that violate the data structure invariant. I was mildly surprised to
find out that this works even when Safe Haskell is turned on:


Note that the warnings tell us that both instances are "[safe]" which
gives a false sense of security.

I couldn't find anything on the interplay between orphan instances and
Safe Haskell both in the Haskell'12 paper and online. Is this
something that the authors of Safe Haskell are aware of/are intending
to fix?

()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

More information about the Haskell-Cafe mailing list