
#10858: Smaller generated Ord instances -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #9557 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata):
But what is stranger to me is this: why don't we just derive the code for compare, and use the default methods for (>), (==) etc?
That’s what I thought at first myself, but then I stumbled over this: {{{ Note [Do not rely on compare] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It's a bad idea to define only 'compare', and build the other binary comparisons on top of it; see Trac #2130, #4019. Reason: we don't want to laboriously make a three-way comparison, only to extract a binary result, something like this: (>) (I# x) (I# y) = case <# x y of True -> False False -> case ==# x y of True -> False False -> True So for sufficiently small types (few constructors, or all nullary) we generate all methods; for large ones we just use 'compare'. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10858#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler