hi, I am using the haskell extensions (in Hugs - Nov 2002) and I have some troubles with that. For example: class A a where a :: a -> String a = const "a" class B b where b :: b -> String b = const "b" instance (A b) => B b where b = a instance B () ----------------- In this case, Hugs says: ERROR "Test.hs":12 - Overlapping instances for class "B" *** This instance : B () *** Overlaps with : B a *** Common instance : B () but I don't have an instance "A ()" from which haskell can infer an instance "B ()". can somebody explain me that it is happening here? Thanks in advanced... Diego
Diego Yanivello <diegoy@sol.info.unlp.edu.ar> wrote in article <5.1.0.14.2.20031201003813.0150dbf8@pop.infovia.com.ar> in gmane.comp.lang.haskell.general:
ERROR "Test.hs":12 - Overlapping instances for class "B" *** This instance : B () *** Overlaps with : B a *** Common instance : B ()
but I don't have an instance "A ()" from which haskell can infer an instance "B ()". can somebody explain me that it is happening here?
Unfortunately, contexts in instance definitions are not taken into account when checking for overlapping instances. That is, two instances are regarded as overlapping as long as their heads can be unified. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig International Human Rights Day * 2003-12-10 * http://www.un.org/rights/ What if All Chemists Went on Strike? (science fiction) http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html
Am Montag, 1. Dezember 2003 05:44 schrieb Ken Shan:
[...]
ERROR "Test.hs":12 - Overlapping instances for class "B" *** This instance : B () *** Overlaps with : B a *** Common instance : B ()
but I don't have an instance "A ()" from which haskell can infer an instance "B ()". can somebody explain me that it is happening here?
Unfortunately, contexts in instance definitions are not taken into account when checking for overlapping instances. That is, two instances are regarded as overlapping as long as their heads can be unified.
The reason for this is that Haskell doesn't make the closed world assumption. It is taken into account that one could easily define an instance A () (e.g., in another module importing your module) which would immediately lead to a real overlapping. Wolfgang
participants (3)
-
Diego Yanivello -
Ken Shan -
Wolfgang Jeltsch