FiniteMap: modifyFM

Ketil Z. Malde
19 Jun 2002 11:49:35 +0200

Alastair Reid <> writes:

> Anyway, isn't there some kind of collection class that FM can be made
> a member of?

Curiously, it seems classes aren't used much in the libraries.  I.e. I
wanted my data structure to be used more or less like an array (it was
basically an array with some extras), but I couldn't just

        instance Indexed Foo where
                a ! i = ...
                bounds a = ...

I can of course always define operations using different names, but
IMHO reusing common ones, like (!) makes the code much more readable. 

Similar for Sets, lists, and FMs, I'd expect something like 

        instance Collection a where
                empty = ...
                cardinality -- or whatever

and so on.

It is quite possible that there are technical difficulties defining
good, generic classes like this, and that I haven't looked deeply
enough into the matter -- I vaguely remember a posting from Chris
Okasaki about classes in the Edison library regarding this.

OTOH, I find I define classes very sparingly in my own programming.
Comong from an OO world I started out with a desire to create classes
for just about anything, but in practice, it rarely seems necessary.
So while it still can be useful or desirable, it just doesn't get

If I haven't seen further, it is by standing in the footprints of giants