I am not sure if this is a bug or not, but I have found a program where Hugs (Nov 2003) requires adding a redundant constraint to class methods.

Loading this code (it is quite useless, but it is the smallest example I could come up with that gave the same error message as my much larger actual program):


class FromStr a where fromStr :: String -> a

typeError :: FromStr a => a -> a
typeError t = error "type error"

instance FromStr [a] where
    fromStr _ = typeError undefined  -- line 8

instance FromStr [(String,a)] where  -- line 10
    fromStr _ = typeError undefined  -- line 11


with "hugs -98 +o test.hs" gives me:


ERROR "test.hs":8 - Cannot justify constraints in instance member binding
*** Expression    : fromStr
*** Type          : FromStr [a] => String -> [a]
*** Given context : FromStr [a]
*** Constraints   : FromStr [a]


Adding the constraint "FromStr a" to the declaration of fromStr fixes the problem, but that seems like it should be redundant. Removing the second instance (lines 10-11) also fixes the problem, interestingly enough.


/Bjorn Bringert

_______________________________________________
Hugs-Bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/hugs-bugs

Reply via email to