| 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
This is something I worked on a bit in GHC.
Here's the error you get from the above program,
which I think you might find a bit more informative:
Foo.hs:6:
Inferred type is less polymorphic than expected
Quantified type variable `t' escapes
It unifies with `t1', which is mentioned in the environment
The following variables in the environment mention `t1'
x :: t1
Signature type: forall t. (Eq t) => t -> Bool
Type to generalise: t1 -> Bool
When checking the type signature for `g'
In an equation for function `f':
f x = g x
where
g :: forall t. (Eq t) => t -> Bool
g y = x == y
Simon
| -----Original Message-----
| From: Scott Turner [mailto:[EMAIL PROTECTED]]
| Sent: 15 June 2000 12:44
| To: [EMAIL PROTECTED]
| Subject: misleading "not general enough" in Hugs
|
|
| 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
|