GHC: Ticket #1351: mistake in Data.Set description
http://ghc.haskell.org/trac/ghc/ticket/1351
<p>
Data.set description in HTML documentation contains the following text
</p>
<p>
difference :: Ord a => Set a -> Set a -> Set a
O(n+m). Difference of two sets. The implementation uses an efficient hedge algorithm comparable with hedge-union.
intersection :: Ord a => Set a -> Set a -> Set a
O(n+m). The intersection of two sets. Elements of the result come from the first set.
</p>
<p>
I think that phrase "Elements of the result come from the first set" relates to difference function, not to intersection
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/1351
Trac 1.0.7Isaac DupreeSat, 12 May 2007 15:41:52 GMT
http://ghc.haskell.org/trac/ghc/ticket/1351#comment:1
http://ghc.haskell.org/trac/ghc/ticket/1351#comment:1
<p>
That phrase is _true_ for both functions; however it would be expected anyway for non-symmetric difference, which is probably why it's not said in regards to that function. It is significant for intersection, where there is no particular reason to take the shared elements from the first versus the second argument (they must be in both, and intersection is essentially symmetric)
</p>
TicketiglooSat, 12 May 2007 16:04:33 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/1351#comment:2
http://ghc.haskell.org/trac/ghc/ticket/1351#comment:2
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
The example below shows why this can make a difference; I've addded it to the docs in the HEAD.
</p>
<pre class="wiki">import qualified Data.Set as S
data AB = A | B deriving Show
instance Ord AB where compare _ _ = EQ
instance Eq AB where _ == _ = True
main = print (S.singleton A `S.intersection` S.singleton B,
S.singleton B `S.intersection` S.singleton A)
</pre><p>
prints <tt></tt><tt>(fromList [A],fromList [B])</tt><tt></tt>.
</p>
Ticket