[GHC] #15421: Refactor (~) to reduce the superclass stack
#15421: Refactor (~) to reduce the superclass stack -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Currently (see `Note [The equality types story]` in `TysPrim`) we have {{{ -- Hetereogeneous equality class a ~# b => a ~~ b instance a ~# b => a ~~ b -- Homogeneous equality class a ~~ b => (a :: k) ~ (b :: k) instance a ~~ b => a ~ b }}} Note that `(~#)` is a superclass of `(~~)`, and `(~~)` is a superclass of `(~)`. This means that in the common case of using `(~)` we need two superclass selections to get to the `(~#)` we want. Nothing really wrong with that, but it bloats programs, and is confusing to read when debugging. I propose to change this to {{{ -- Homogeneous equality class a ~# b => (a :: k) ~ (b :: k) instance a ~# b => a ~ b }}} That is, implement `(~)` in precisely the same way as `(~~)`. This makes `(~)` a tiny bit more baked-in to the compiler, but in exchange it behaves in the same way as `(~~)`, instead of behaving in a slightly different way. There should be no observable effect for users. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15421> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15421: Refactor (~) to reduce the superclass stack -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"f265008fb6f70830e7e92ce563f6d83833cef071/ghc" f265008f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f265008fb6f70830e7e92ce563f6d83833cef071" Refactor (~) to reduce the suerpclass stack The constraint (~) used to be (effectively): class a ~~ b => (a :: k) ~ (b :: k) but, with this patch, it is now defined uniformly with (~~) and Coercible like this: class a ~# b => (a :: k) ~ (b :: k) Result: * One less superclass selection when goinng from (~) to (~#) Better for compile time and better for debugging with -ddump-simpl * The code for (~), (~~), and Coercible looks uniform, and appears together, e.g. in TysWiredIn and ClsInst.matchGlobalInst. Previously the code for (~) was different, and unique. Not only is this simpler, but it also makes the compiler a bit faster; T12227: 9% less allocation T12545: 7% less allocation This patch fixes Trac #15421 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15421#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15421: Refactor (~) to reduce the superclass stack -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15421#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC