Re: RFC: DData in hierarchical libraries
--- Christian Maeder <maeder@tzi.de> wrote:
Simon Marlow wrote:
Why are there IntBags but no Bags?
As I've said before, rename MultiSet to Bag.
Daan's remark about the difference between bags and multisets is: " A multi set differs from a /bag/ in the sense that it is represented as a map from elements to occurrence counts instead of retaining all elements. This means that equality on elements should be defined as a /structural/ equality instead of an equivalence relation. If this is not the case, operations that observe the elements, like 'filter' and 'fold', should be used with care. " Yet it can be argued that Eq is (nearly) always assumed to be defined by structural equality, so "Bag" would be just as good as "MultiSet". Since a true "Bag" type may be added later, I did not bother to change the name.
Internal functions like DData.Set.valid should not be visible.
"valid" may be useful for debugging purposes if certain (for efficiency reasons unsafe) functions like "fromDistinctAscList" may produce invalid representations (if the argument is not strictly ascending). But I don't know if this is the case.
Indeed. Maybe the best is just to rename the function to a name less likely to clash. Cheers, JP. __________________________________ Do you Yahoo!? Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com
A few comments on the DData.Map proposal: * nice work. I might start using it (instead of Data.FiniteMap) just because the function names look better :-) * argument ordering: the existing Data.FiniteMap mostly has f :: FiniteMap -> ... -> FiniteMap while the proposal uses f :: ... -> FiniteMap -> FiniteMap I think the Edison guidelines are quite nice: http://www.haskell.org/ghc/docs/edison/users004.html#toc10 Did you follow them? What exceptions? * types: some functions are not declared at their most general type (I checked by commenting out the decl. and asking ghci) difference :: forall a1 k a. (Ord k) => Map k a1 -> Map k a -> Map k a1 differenceWithKey :: forall a1 k a. (Ord k) => (k -> a1 -> a -> Maybe a1) -> Map k a1 -> Map k a -> Map k a1 intersection :: forall a k a1. (Ord k) => Map k a -> Map k a1 -> Map k a intersectionWith :: forall a k a2 a1. (Ord k) => (a1 -> a2 -> a) -> Map k a1 -> Map k a2 -> Map k a intersectionWithKey :: forall a k a1 a2. (Ord k) => (k -> a2 -> a1 -> a) -> Map k a2 -> Map k a1 -> Map k a isSubsetOfBy :: forall a1 k a. (Ord k) => (a -> a1 -> Bool) -> Map k a -> Map k a1 -> Bool -- -- Johannes Waldmann, Tel/Fax: (0341) 3076 6479 / 6480 -- ------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------
participants (2)
-
Johannes Waldmann -
JP Bernardy