Thanks!

I have just tried your suggested solution.  Unfortunately it still gives out
an error message, this time HUGS says

Error test.txt :Unresolvable top-level overloading
****Binding: sort
****Outstanding context: Ord b

I am frantically revising for my Functional Programming exam on Monday.
There is one very important part of the course that I do not understand,
defining types for functions.  The type of the foldl function I defined, is
the same as that defined in the Prelude.hs file.  That is,

foldl            :: (a -> b -> a) -> a -> [b] -> a
foldl f z []      = z
foldl f z (x:xs)  = foldl f (f z x) xs

How does this work?

Cheers

Paul Saxton

-----Original Message-----
From: Keith Wansbrough [mailto:[EMAIL PROTECTED]]
Sent: 26 May 2000 10:00
To: psaxton
Subject: Re: Query


> foldll f u nil=u
> foldll f u (x:xs) =foldll f (f u x) xs

[..]

> 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 a variable, just like `x' or `u'.  I think you mean `[]' instead,
which is the end-of-list marker.

Good luck with your homework.

--KW 8-)
--
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) -------------------:
: PhD Student, Computer Laboratory, University of Cambridge, UK. :
: Native of Antipodean Auckland, New Zealand: 174d47'E, 36d55'S. :
: http://www.cl.cam.ac.uk/users/kw217/ mailto:[EMAIL PROTECTED] :
:----------------------------------------------------------------:



Reply via email to