Serge D. Mechveliani mechvel at
Fri Sep 16 05:20:06 EDT 2005

On Thu, Sep 15, 2005 at 02:40:25PM +0200, Christian Maeder wrote:
> Serge D. Mechveliani wrote:
> >How do you think, maybe,  Data.Set  also needs to provide
> >`lookup' ?
> Admittingly, using 'Set.filter (==e) s' to find the matching element may 
> be a bit slower.
> When trying to use 'Set.intersection s $ singleton e' I just noticed 
> that intersection is not left-biased (see below)!
> I'm not sure if Data.Set should be extended to better support elements 
> with an equivalence relation and a corresponding order. I've such sets 
> too, but never really cared about the additional component.
> Do you also want functions 'insertWith', 'unionWith', 'splitLookup' (and 
> what not)?
> I'ld rather suggest to use Data.Map instead and use a proper total order 
> for the keys (although that may also be awkward).

Thank you for the help.

Set.filter (==e) s   looks like similar to
                                        find (== e) . Set.toList s,
which is slow.
Set.intersection s $ singleton e
has a chance to be near as fast as `member'.

But to have `lookup' looks most natural, to my mind.

Generally: I do not know. I would rely on the opinion of developers. 
If they decide anything about this, then all right.   

Serge Mechveliani
mechvel at

More information about the Glasgow-haskell-users mailing list