Solved: Typing problems with polymorphic recursion and typeclasses

oleg@pobox.com oleg@pobox.com
Tue, 6 May 2003 19:04:40 -0700 (PDT)


Regarding
 > > f:: (Show fa) => fb -> fa
 > > f = undefined
 > >
 > > g:: (Show ga) => ga -> gb
 > > g = undefined
 > >
 > > -- h:: (Show fa) => t -> fa
 > > h b = f (g (h b))

Simon Peyton-Jones wrote:

> so the recursive call has the same type as the main function; so the
> situation is identical to the case where there is no type signature, and
> the recursive call is at the same type as the function being defined.
> ...
> But giving an explicit type signature for h makes it *more* polymorphic,
> and that in turn leads to ambiguity in this particular case.

I admit I'm confused: can I compose a type expression that describes
the type of h? For example, I plan to document the function h and want
to give its type signature. I don't know what to write. We know that
"(Show fa) => t -> fa" is not it: it's too polymorphic. Is there any
type expression that is polymorphic just enough?

	Thank you!