select and selectSplit
conor at strictlypositive.org
Fri Feb 15 07:32:55 EST 2008
On 15 Feb 2008, at 12:07, Chris Kuklewicz wrote:
> Johannes Waldmann wrote:
>> Chris Kuklewicz wrote:
>>> As mentioned in another reply, the select treats the source list
>>> like an
>>> unordered (perhaps multi) set.
>> See - the proposed function is in the "wrong" module;
>> it uses a concrete data type (List)
>> which normally represents an abstract Sequence type
>> but here some abstract data type (Bag) is intended.
> Lists are the right thing for any small collection (scrabble hands
> only have 7 tiles at most).
I'm inclined to agree with you if by "thing" you
mean "representation", but disagree if by "thing"
you mean "type".
If lists are being used to represent finite
multisets, it's probably a good thing to pack
them in a newtype, whether or not it's being
treated as an abstract datatype. We should use
types as signs of structure, not just as
descriptions of data layout. For example, we
should expect to have
instance Eq x => Eq (Bag x)
but not with the same semantics as equality on
What morals one can afford in terms of enforcing
representation hiding is a trickier question,
but it is at least relatively cheap to make type
distinctions which are healthily suggestive.
All the best
More information about the Libraries