RFC: Collection Framework, reprise.

Udo Stenzel u.stenzel at web.de
Thu Feb 23 11:50:49 EST 2006

Jean-Philippe Bernardy wrote:
> > -- The 'isSingleton' method seems unnecessary.  Are singleton
> > collections interesting enough to supply a special test for them?
> This is based on Christan Maeder idea. We are planning to move to AVL
> trees for A. Hey, which do not provide a O(1) size function. A
> singleton test thus becomes valuable, and since costs next to nothing
> to add to the class I decided to to it.

Here's a more general suggestion: move the method 'front' up into class
'Collection'.  It is always meaningful in some way: it would get the
leftmost item from a sequence, the least key from a set, the least
priority from a priority queue and so on.  Sure, the naming is not the
most fortunate.  What would be appropriate for a method that extracts a
somewhat unspecified element?  'split', 'extract', 'view', 'decompose',
'item' or something else?

Alternatively, 'front' could be left where it is, extracting the
leftmost element.  A similar method, which extracts an unspecified
element, should be added to 'Collection'.

Once you have 'front' you can implement 'isSingleton' and 'null' outside
the class.  The same is true for 'fold' and a strict 'foldl' which is
currently missing.

"Being abstract is something profoundly different from being vague."
	-- E. W. Dijkstra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/libraries/attachments/20060223/4af3ac3a/attachment.bin

More information about the Libraries mailing list