[clean-list] a local function typing question in function
composition
Edsko de Vries
devriese at cs.tcd.ie
Thu Apr 12 13:09:04 MEST 2007
On Thu, Apr 12, 2007 at 11:28:16AM +0100, Jigang Sun wrote:
> What I want to know the type of composition function h.
> Cheers.
> Jigang
You cannot give a type definition for h in your example, because the
type of h wouuld have to refer to type variables in the type of (oo).
For that to work, you need scope type variables, which Clean doesn't
have.
Consider a simpler example:
f :: a -> a
f x = y
where
y :: a
y = x
Start = f 5
The type annotation on "y" really means, y has type "a" for all a. It
*doesn't* mean, y has type "a", where I mean the same "a" as in the type
of "f". Of course, "y" doesn't have type "a" for all "a", so this type
annotation is correct, and the Clean compiler tries to warn you:
Type error [t.icl,6,y]:type variable of type of lifted argument a
appears in the specified type
It's telling you that your type annotation appears to be using type
variables from the outer definition, but that that won't work.
Hope that helps,
Edsko
More information about the clean-list
mailing list