Hello,this is clearly a bug in GHC: where `B` and `C` are imported, there should have been an error, saying that there is a duplicate instance of `Foo Int`. If there is no ticket for this already, could you please add one?-Iavor_______________________________________________On Mon, Aug 11, 2014 at 12:35 PM, Dan Doel <dan.doel@gmail.com> wrote:
On Mon, Aug 11, 2014 at 11:36 AM, Twan van Laarhoven <twanvl@gmail.com> wrote:
To me, perhaps naively, IncoherentInstances is way more scary than OverlappingInstances.
It might be a bit naive. Most things that incoherent instances would allow are allowed with overlapping instances so long as you partition your code into two modules. So unless such a partitioning is impossible, overlapping instances are almost as scary as incoherent instances (unless the module separation somehow makes it less scary).
And actually, with the way GHC handles instances, you can get more incoherent behavior than incoherent instances allow without enabling any extensions, just using modules:
module A whereclass Foo a where foo :: a
module B whereimport A
instance Foo Int where foo = 5
bar :: Int ; bar = foomodule C whereimport Ainstance Foo Int where foo = 6baz :: Int ; baz = foomodule D whereimport Bimport Cquux = bar + baz -- 11
-- Dan
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users