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

Philip Matthews philip_matthews at magma.ca
Thu Apr 12 16:07:05 MEST 2007


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

> Hey,
>
>> Does this mean that it is illegal in Clean to use type variables
>> from an outer function definition in an inner function  definition?
>
> No, not really. It's just that all type variables are implicitly
> quantified by a "forall" (just like in Haskell, I might add). So, for
> example, the following code is perfectly fine, albeit a bit contrived:
>
> module t
>
> f :: [a] -> [a]
> f xs = ys
>     where
>         ys :: [a]
>         ys = []
>
> Start = f [1,2,3]
>
> Again, the type annotation on "ys" says that "ys" has type "[a]"  
> for all a (and
> it does, because the empty list has that type).

Would I be correct in saying that type variable "a" in "f:[a]->{a]"  
is completely distinct
from type variable "a" in "ys::[a]", even though they have the same  
name?

- Philip




More information about the clean-list mailing list