[GHC] #10858: Smaller generated Ord instances

GHC ghc-devs at haskell.org
Wed Aug 31 21:47:34 UTC 2016


#10858: Smaller generated Ord instances
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      Resolution:                    |             Keywords:  deriving-perf
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #9557             |  Differential Rev(s):  D2502
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by prokhorenkov):

 * differential:   => D2502


Comment:

 May I interest you all with a really ''newcomer-grade'' change?

 We can just generate "compare" and "<" as usual and express other
 relations through "<".
 Like
 {{{
 a > b = b < a
 a <= b = not $ b < a
 a >= b = not $ a < b
 }}}
 This saves us code for 3 methods out of 5 for a small added cost of extra
 negation. When the code for "<" is short enough the inliner would make the
 code as good as can be. Otherwise added negation would be insignificant.

 Adding new differential rev with the proposed changes.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10858#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list