Map, Set libraries

Jens Fisseler jens.fisseler at
Thu Jun 2 06:00:09 EDT 2005

> I meant the description in the ghc-6.4 documentation.
> Data.Set.html  says
> "
>   elems :: Set a -> [a]
>   O(n). The elements of a set.
>   setToList :: Set a -> [a]
>   O(n). Convert the set to a list elements.
> "
> What is the difference? 
> If they are really equivalent, then, it is natural either to
> remove `elems' or to follow the general GHC policy and to move 
> setToList  to the `Obsolete' list section in documentation, like
> it was done with many other functions for Set and FiniteMap.    
> - ?

Well, seems like both of us have messed something up. The ghc-6.4
documentation for 'setToList' says "Obsolete equivalent of elems",
whereas the documentation for 'toList' (that what I was referring to)
says "O(n). Convert the set to a list of elements."

But, by looking at the source code, one can easily see that 'setToList'
if defined in terms of 'elems'

setToList :: Set a -> [a] 
setToList = elems

which in turn is defined as

elems :: Set a -> [a]
elems s
  = toList s

So, both 'setToList' and 'elems' do the same, and 'setToList' is marked as obsolete, so use 'elems'.



More information about the Glasgow-haskell-users mailing list