Re: [Haskell] RFC: DData in hierarchical libraries

Hi Daan,
Set.toAscList is not really necessary as it is the same as Set.toList.
Not necessarily: the lists from Set.toList will be equal for equal Set's, but may be unordered. Use "toAscList" or "toDescList" if you want an ordered variant.
That really surprises me. I think that toList must return a sorted list (to properly abstract the Set data type), and anything unsorted should only be for debugging purposes.
The functions Set.fromAscList and Set.fromAscDistinctList should be marked as "unsafe"
I think so too, although I like "unchecked" better?
Good, I agree.
Map.keySet = Set.fromDistinctAscList . Map.keys
Yes, we could do that -- but the circular dependency is terrible, and a wrapper module would need to look at the internal representation of Map/Set :-(
I don't see the circular dependency. Map imports Set (but not vice versa?). In any case, I would prefer a wrapper (possible revealing some more "unchecked" functions). Christian

Set.toAscList is not really necessary as it is the same as Set.toList.
Not necessarily: the lists from Set.toList will be equal for equal Set's, but may be unordered. Use "toAscList" or "toDescList" if you want an ordered variant.
That really surprises me. I think that toList must return a sorted list (to properly abstract the Set data type), and anything unsorted should only be for debugging purposes.
You are right! Indeed, for a proper abstraction, we should specify the order... hmm, that means we need to reconsider either the naming scheme (that is, remove toAscList and call it toList) or specify explicitly the order that is returned right now. -- Daan.

Daan Leijen
You are right! Indeed, for a proper abstraction, we should specify the order... hmm, that means we need to reconsider either the naming scheme (that is, remove toAscList and call it toList) or specify explicitly the order that is returned right now.
I think ascending is the most intuitive order, so how about something like: toList (ascending) and toListReversed (descending) ? -kzm -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde wrote:
I think ascending is the most intuitive order, so how about something like: toList (ascending)
Yes.
and toListReversed (descending)
No, the next one then wants fromDescList and fromDistinctDescList (or fromReversedList). Let users reverse their lists. Maybe even (the current) "fromAscList" is not really necessary, because toList only produces proper distinct ascending lists.(Thus fromDistinctAscList can be renamed to fromAscList.) Christian
participants (3)
-
Christian Maeder
-
Daan Leijen
-
Ketil Malde