FiniteMap: modifyFM

Simon Marlow simonmar@microsoft.com
Wed, 19 Jun 2002 12:27:33 +0100


> 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
>=20
>         instance Indexed Foo where
>                 a ! i =3D ...
>                 bounds a =3D ...

Hmm, very true.  Perhaps there ought to be a way to define new instances
of IArray and HasBounds - unfortunately IArray doesn't have the obvious
methods like (!) and 'array' any more, it has methods like 'unsafeArray'
and 'unsafeAt' which are versions of these without bounds checking (for
efficiency - bounds checks are done only when necessary).

> I can of course always define operations using different names, but
> IMHO reusing common ones, like (!) makes the code much more readable.=20
>=20
> Similar for Sets, lists, and FMs, I'd expect something like=20
>=20
>         instance Collection a where
>                 empty =3D ...
>                 (!!)=20
>                 cardinality -- or whatever
>=20
> and so on.

There have been lots of proposals for collection classes over the years,
and no single one stands out as an obvious choice.  However, I don't
think we should stop looking - this is arguably one of the most
important pieces still missing from the libraries, and the longer we go
on without a good framework for collections, the harder it will be to
add one.  So get designing!

Cheers,
	Simon