On Thu, Oct 10, 2013 at 10:09 PM, Edward Kmett <ekm...@gmail.com> wrote:
> Wait, that sounds like it induces bad semantics. > > Can't we use that as yet another way to attack the sanctity of Set? > > class Ord a => Foo a where > badInsert :: a -> Set a -> Set a > > instance Foo Int where > badInsert = insert > > newtype Bar = Bar Int deriving (Eq,Foo) > > instance Ord Bar where > compare (Bar x) (Bar y) = compare y x > > Now you can badInsert into a Set. > > If that is still in play then even with all the roles machinery then GND > doesn't pass the restrictions of "SafeHaskell". =( > It seems like doing GND for an instance is okay as long as it's done for all the superclasses as well. Alternately, what about keeping non-specialized versions of the instance code around? Like, if we have (in pseudocode): ordint :: OrdInstance Int fooint :: FooInstance Int ordbar :: OrdInstance Bar instead of saying foobar = coerce fooint, we could use fooint_ordint :: OrdInstance Int -> FooInstance Int and set foobar = coerce (foointordint (coerce ordbar) That seems like it would be correct, albeit less efficient. We can still use coerce fooint for newtype of Int that also use GND for the Ord instance. -- Dave Menendez <d...@zednenem.com> <http://www.eyrie.org/~zednenem/>
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users