Proposal #2560 again: add newtype Down/ReverseOrd to Data.Ord

Twan van Laarhoven twanvl at gmail.com
Wed Jan 7 13:48:07 EST 2009


roconnor at theorem.ca wrote:
> On Wed, 7 Jan 2009, Stefan Holdermans wrote:
> 
>> Twan,
>>
>>> How about:
>>>
>>> -- intended for |qualified| import |as Ord|:
>>> newtype Dual a = Dual { unDual :: a } deriving Eq
>>
>>
>> +1 for Dual.
> 
> 
> +1 for Dual.  The term seems common in lattice theory.  I use it myself.
> 

Dual does seem to be the right term, but I suggest using DualOrd or DualOrdering 
instead. The fact that it can be imported qualified is no reason to confuse 
people, in many cases the function will not be imported qualified, since 
conflicts are very unlikely. To me just "dual" does not immediatly suggest a 
reverse ordering. Consider also:
    sortBy (comparing `on` Dual . fst) stuff
vs.
    sortBy (comparing `on` DualOrd . fst) stuff
In the first version it is not immediatly clear that dual has something to do 
with the ordering, and not just taking some kind of dual of something in some 
other way.


Also, the record selector should be called getDual{Ord}, in accordance with the 
monoid wrappers and mtl types.


In summary, I like: DualOrd{ering}, ReverseOrd{ering} and am okay with Desc{ending}.


Twan


More information about the Libraries mailing list