[clean-list] overloading problem

Richard A. O'Keefe ok@atlas.otago.ac.nz
Wed, 4 Apr 2001 12:17:04 +1200 (NZST)


	> When I do "Start=(intersect [] [])" I get the
	> following Error:
	>      "Start" cannot be overloaded: Set a | ==a"
	> Whereas when I do "Start=(intersect [1,2,3] [2,3,4]"
	> I get the correct
	> answer.
	> What am I doing wrong?


Clean is telling you what you are doing wrong.
It has inferred the type

	Start :: Set a | ==a

and it doesn't like that.  With the other definition of Start,
it infers

	Start :: Set Int

which gives it no trouble.  The value of Start is printed, so it had
better have a specific type.  You don't have to change the definition,
just tell Clean which type you want Start to have:

	:: Set a :== [a]

	intersection :: (Set a) (Set a) -> (Set a) | ==a
	intersection xs ys = [x \\ x <- xs | isMember x ys]

	Start :: Set Int		// crucial line
	Start = intersection [] []

should do the trick.