Hello David, On Wed, Oct 17, 2012 at 6:02 PM, David Mazieres expires 2013-01-15 PST <mazieres-sebg4mvthwuzk9r27pqmr8j...@temporary-address.scs.stanford.edu> wrote: > Can you elaborate on how this can be used to break the data structure > invariant? If in safe Haskell you import two modules that have > overlapping instances, you will not be able to use the two instances. > Modules that import only one instance will be able to use that > instance.
Please take a look at the code example I provided: https://gist.github.com/3854294 I don't use overlapping instances or any other extensions besides Safe Haskell. By defining two orphan Ord instances for U I'm able to construct a value of type Set U that contains two equal elements: > test fromList [X,Y,X] This is what I meant by "breaking the data structure invariant". This shouldn't normally be possible: the documentation for Data.Set.insert says: "If the set already contains an element equal to the given value, it is replaced with the new value." Regarding your Monoid example, it will still be possible to make it work even if instance coherence is enforced by using a newtype wrapper (in fact, Data.Monoid already includes Sum and Product newtype wrappers that provide this functionality). -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe