psaxton writes:

 > foldll f u nil=u
 > foldll f u (x:xs) =foldll f (f u x) xs
 > 
 > reduce f id []=id
 > reduce f id (x:xs) = f x (reduce f id xs)
 > 
 > cons x xs=x:xs
 > append xs ys = reduce cons ys xs
 > insert x [] = x:[]
 > insert x (y:ys)=if x<=y then x:(y:ys)
 >                 else y:(insert  x ys)
 > 
 > sort=reduce insert nil
 > 
 > for some reason, HUGS is objecting to the final nil.  Even though it has no
 > objections to the occurrence of nil in the foldl function.  Have you any
 > idea what I am doing wrong?  If possible, please could you reply before
 > Monday.

"nil" is written "[]" in Haskell. Hugs doesn't mind the first occurrence of
nil because it interprets it as a variable named nil, rather than a data
constructor. It objects to the nil on the last line because "nil" is not bound
in the enclosing scope.

BTW, constructors are always capitalized in Haskell. So if [] were not an
exception to the rule, it would be written "Nil".

But I see you've already used "[]" in your program anyway, so maybe you know
that.

-- 
Frank Atanassow, Dept. of Computer Science, Utrecht University
Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
Tel +31 (030) 253-1012, Fax +31 (030) 251-3791


Reply via email to