Bug? Or at least a better error message?

Brian Hulley brianh at metamilk.com
Mon Jun 5 12:57:44 EDT 2006


Geoffrey Alan Washburn wrote:
> Brian Hulley wrote:
> 
>> I must admit I can't understand where the ambiguity actually is.
>> bar has been defined as a -> Int, so surely anything on the rhs of an
>> equation for an instance of the bar method in Foo is therefore an Int
>> also, so having to explicitly write 1::Int seems superfluous.
>> 
>>       bar([x]) = 1    -- why is ::Int needed when we know that bar::
>> a->Int ???
> 
> I haven't tested the combination where I omit the annotation on
> "bar([x]) = 1", but I believe that the annotation is only actualyl
> necessary for the "bar [] = bar [1]" case where ghc cannot determine
> the type at which it needs to be calling bar recursively.
> 

Oh I see now - I was looking at the wrong "1" ! :-)
Thanks, Brian.


More information about the Glasgow-haskell-users mailing list