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

Edsko de Vries devriese at cs.tcd.ie
Thu Apr 12 15:57:36 MEST 2007


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

Edsko


More information about the clean-list mailing list