[GHC] #12791: Superclass methods could be more aggressively specialised.

GHC ghc-devs at haskell.org
Tue Nov 1 01:28:10 UTC 2016


#12791: Superclass methods could be more aggressively specialised.
-------------------------------------+-------------------------------------
        Reporter:  mpickering        |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      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 rwbarton):

 I found that explanation slightly more complicated than necessary.
 Consider this example:
 {{{#!hs
 {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}
 module G where

 class Num a => C a b where m :: a -> b

 f :: C Int b => b -> Int -> Int
 f _ x = x + 1
 }}}

 In `f`, there is a `Num Int` instance available from the passed-in `C Int
 b` instance. So, GHC generates this code for `f`:
 {{{
 G.f =
   \ (@ b_aLy)
     ($dC_aLz :: G.C GHC.Types.Int b_aLy)
     _ [Occ=Dead]
     (eta1_B1 :: GHC.Types.Int) ->
     GHC.Num.+
       @ GHC.Types.Int
       (G.$p1C @ GHC.Types.Int @ b_aLy $dC_aLz)
       eta1_B1
       G.f1
 }}}
 which is obviously terrible.

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


More information about the ghc-tickets mailing list