[GHC] #2660: Add Down newtype wrapper for reversing orderings

GHC trac at galois.com
Sun Oct 5 11:37:16 EDT 2008


#2660: Add Down newtype wrapper for reversing orderings
---------------------------------+------------------------------------------
    Reporter:  twanvl            |       Owner:                  
        Type:  proposal          |      Status:  new             
    Priority:  normal            |   Component:  libraries/base  
     Version:  6.8.3             |    Severity:  normal          
    Keywords:                    |    Testcase:                  
Architecture:  Unknown/Multiple  |          Os:  Unknown/Multiple
---------------------------------+------------------------------------------
 In the same spirit as the newtypes in Data.Monoid, we can also add a
 newtype for reversing the ordering of a type:
 {{{
 newtype Down a = Down { getDown :: a }

 instance Ord a => Ord (Down a) where
     Down x < Down y  =  y < x
     -- etc.
 }}}
 This newtype is especially useful in combination with `sortOn` (ticket
 #2629).

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2660>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list