1 May 21:29 2003

## Re: Typing problems with polymorphic recursion and typeclasses

Derek Elkins <ddarius <at> hotpop.com>

2003-05-01 19:29:39 GMT

2003-05-01 19:29:39 GMT

[...] > Let us keep the function h without the explicit type declaration. Let > us apply what I thought as an equivalent transformation: > > > h = \b -> f (g (h b)) > > Hugs now reports > ERROR "/tmp/b.hs":12 - Unresolved top-level overloading >(Continue reading)*** Binding : h >*** Outstanding context : X b > and GHCi reports > /tmp/b.hs:12: > Ambiguous type variable(s) `a' in the constraint `X a' > arising from use of `f' at /tmp/b.hs:12 > In a lambda abstraction: f (g (h b)) > > It is interesting that the error message is exactly the same as when > we used the explicit type declaration for the old "h b=..." > definition. > > Something seems to be going on... Isn't this just the monomorphism restriction. In GHCi, Prelude> let k = (<) <interactive>:1: Ambiguous type variable(s) `a' in the constraint `Ord a' arising from use of `<' at <interactive>:1 In the definition of `k': (<)