Opened 9 years ago
Closed 9 years ago
#1351 closed bug (fixed)
mistake in Data.Set description
Reported by: | guest | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Documentation | Version: | 6.6.1 |
Keywords: | Cc: | ||
Operating System: | Windows | Architecture: | x86 |
Type of failure: | Test Case: | ||
Blocked By: | Blocking: | ||
Related Tickets: | Differential Rev(s): | ||
Wiki Page: |
Description
Data.set description in HTML documentation contains the following text
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.
I think that phrase "Elements of the result come from the first set" relates to difference function, not to intersection
Change History (2)
comment:1 Changed 9 years ago by Isaac Dupree
comment:2 Changed 9 years ago by igloo
- Resolution set to fixed
- Status changed from new to closed
The example below shows why this can make a difference; I've addded it to the docs in the HEAD.
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)
prints (fromList [A],fromList [B]).
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)