[GHC] #11735: Optimize coercionKind

GHC ghc-devs at haskell.org
Thu Jan 25 08:48:16 UTC 2018


#11735: Optimize coercionKind
-------------------------------------+-------------------------------------
        Reporter:  goldfire          |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > I'm afraid to say that coercionRole (NthCo ...) manifestly does require
 coercionKind

 Aha. So it does.

 Very well, yes let's do this

 * Cache the role (of the result of `NthCo i co`) in the `NthCo` data
 constructor

 * Make `mkNth` compute that cached role by calling `coercionKind` and
 `coercionRole` (in the final equation where we build `NthCo`).

 * Possible gloss: in some calls to `mkNthCo` we know the role, and we even
 know that the various short-cuts in `mkNthCo` won't succeed.  So we can
 just use `NthCo` directly -- or define `mkNthCoDirect = NthCo` and call
 `mkNthCoDirect`.  Perhaps not worth it; but when we do know the role it
 seems a bit silly not to use it.

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


More information about the ghc-tickets mailing list