Doing exercises from "Haskell tutorial" ...

Frank Atanassow franka@cs.uu.nl
Tue, 2 Oct 2001 17:47:56 +0200


Dmitry Astapov wrote (on 02-10-01 15:16 +0300):
> 
> It seems like an appropriate page for aske newbie questions, isnt it?
> 
> I was reading through Haskell tutroial
> (http://www.di.uminho.pt/afp98/PAPERS/Tutorial.ps) and trying to do
> exercises from there. I'm stuck in the first exercise for "Classes" chapter
> (page 11). I need to define SetsAsLists as an instance of Set by supplying
> definitions for all Set methods, but definitions I wrote led me to adding
> additional constraints on "union" and "memeber" methods. Is it ok or it's
> possible to define "union" and "member" without using "==" ?

It sure looks like an error to me. You definitely need equality on a
collection A to define a set over A. I think your implementation is fine.

-- 
Frank Atanassow, Information & Computing Sciences, Utrecht University
Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands
Tel +31 (030) 253-3261 Fax +31 (030) 251-379