[clean-list] a local function typing question in function composition

Philip Matthews philip_matthews at magma.ca
Thu Apr 12 15:23:40 MEST 2007


On 12-Apr-07, at 07:09 , Edsko de Vries wrote:

> 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.
>

Does this mean that it is illegal in Clean to use type variables
from an outer function definition in an inner function  definition?

If so, could the error message be changed to something like:
	"Cannot reuse type variables from an outer function definition in an  
inner function definition" ?

- Philip





More information about the clean-list mailing list