[GHC] #9522: SPECIALISE pragmas for derived instances

GHC ghc-devs at haskell.org
Fri Aug 29 08:39:19 UTC 2014


#9522: SPECIALISE pragmas for derived instances
-------------------------------------+-------------------------------------
       Reporter:  simonpj            |                   Owner:
           Type:  bug                |                  Status:  new
       Priority:  normal             |               Milestone:
      Component:  Compiler           |                 Version:  7.8.2
       Keywords:                     |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Unknown            |         Type of failure:
     Blocked By:                     |  None/Unknown
Related Tickets:                     |               Test Case:
                                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 In package `ghc-prim`, in `GHC.Classes` we have
 {{{
 instance (Eq a) => Eq [a] where
     {-# SPECIALISE instance Eq [[Char]] #-}
     {-# SPECIALISE instance Eq [Char] #-}
     {-# SPECIALISE instance Eq [Int] #-}
     []     == []     = True
     (x:xs) == (y:ys) = x == y && xs == ys
     _xs    == _ys    = False
 }}}
 The `SPECIALISE instance` pragmas instantiate the code for these commonly-
 used types.

 But for tuples we use `deriving`:
 {{{
 deriving instance (Eq  a, Eq  b) => Eq  (a, b)
 }}}
 and many more similar.  There is no way to add a `SPECIALISE instance`
 pragma for a derived instance. This is bad, because they are heavily used.

 It should probably be possible to have a top-level
 {{{
 {-# SPECIALISE instance Eq (Int, Bool) #-}
 }}}
 even in another module (as we can now do for functions.  To do this right,
 we'd need to make the code for derived methods `INLINEALBE`.

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


More information about the ghc-tickets mailing list