
#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: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9557 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by nomeata): * keywords: newcomer => * related: => #9557 Comment: Ah, so I had that feeling before. I guess it is a duplicate.. or maybe this ticket is now more specific to talk about Ord. Re note `Note [Do not rely on compare]`: Note that we actually do rely on `compare` for all but the last field. So either the note can be ignored (at least in the case of product types), or a similar chain, not using `compare` can be built for the other operators: {{{ (<) a_acXz b_acXA = case a_acXz of { ImportDecl a1_acXB a2_acXC a3_acXD a4_acXE a5_acXF a6_acXG a7_acXH a8_acXI -> case b_acXA of { ImportDecl b1_acXJ b2_acXK b3_acXL b4_acXM b5_acXN b6_acXO b7_acXP b8_acXQ -> (<) a1_acXB b1_acXJ || (<) a2_acXC b2_acXK || (<) a3_acXD b3_acXL || (<) a4_acXE b4_acXM || (<) a5_acXF b5_acXN || (<) a6_acXG b6_acXO || (<) a7_acXH b7_acXP || (<) a8_acXI b8_acXQ }}} This follows the same pattern above, just using the right connective: It should be `||` for `(<)` and `(>)`, `&&` for `(<=)` and `(>=)` and `thenComp` for `compare`. And one should check that this is right- associative, to get the right lazy behavior. Still a nice ticket for new contributors. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10858#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler