[clean-list] type specification of local functions

Paul de Mast demast.pjf at avans.nl
Tue Nov 16 16:35:52 MET 2004


Hello,

I have a question on adding type specifications to local function
definitions.

Normally one can solve ambiguously internal overloading by adding a
type specification to the involving local definitions. However adding a
type specification is not always possible if the specification refers to
a type variable in the surrounding function.

In the following code:

f  :: [t]  -> Int 
f xs
   = size as 
where
   as = { c \\ c <- xs } 

The compiler complains: internal overloading cannot be solved.
Adding a type specification:

f  :: [t]  -> Int 
f xs
   = size as 
where
   as :: {t} 
   as = { c \\ c <- xs } 

results in: Type error [...,as]:type variable of type of lifted
argument a<24719476> appears in the specified type.

Defining the function as:

f  :: [t]  -> Int 
f xs 
   = size as 
where
   // as :: {t} 
   as = toArray xs 
	
   toArray :: [t] -> {t}
   toArray xs = { c \\ c <- xs }

works.

Questions:
- can this situation be solved without introducing an addition function
toArray?
- are there plans to remove the restriction one referring to a type
variable in the type specification of the surrounding function?  Due to
this restriction it is also not possible to include additional
strictness or uniqueness information (besides the derived information)
for such local definitions.

regards,

Paul de Mast


More information about the clean-list mailing list