I'm using Hugs98, 000328-pre-rel. It was taxing to deal with an error
message that arises from this program:
f :: (Eq t) => t -> Bool
f x = g x
where
g :: (Eq t) => t -> Bool
g y = x == y
ERROR "ugly3.hs" (line 5): Inferred type is not general enough
*** Expression : g
*** Expected type : Eq a => a -> Bool
*** Inferred type : Eq _6 => _6 -> Bool
The actual program in which this gave me a hard time was more complex, and
my experience-based instinct for solving problems by _adding_ type
annotations prevented me from directly finding the easy solution of
removing the annotation on g. The presence of a constraint was a red
herring which made it more difficult to understand "not general enough".
At last I referred back to last month's message from Mark Jones which
mentions the shortcomings of Haskell's type notation and the Hugs extension
of scoped type names. When the following variant type-checked, all became
clear.
f :: (Eq t) => t -> Bool
f (x::t) = g x
where
g :: t -> Bool
g y = x == y
The use of _6 in the diagnostic is wrong.
It looks like an ordinary type variable.
In fact, I can change the declaration of g to
g:: Eq _6 => _6 -> Bool
and the diagnostic will still say that the inferred type doesn't
match it. It would help a lot to state the scope of _6.
--
Scott Turner
[EMAIL PROTECTED] http://www.ma.ultranet.com/~pkturner