[GHC] #7542: GHC doesn't optimize (strict) composition with id

GHC ghc-devs at haskell.org
Mon Feb 10 16:22:21 UTC 2014


#7542: GHC doesn't optimize (strict) composition with id
--------------------------------------------+------------------------------
        Reporter:  shachaf                  |            Owner:  simonpj
            Type:  bug                      |           Status:  new
        Priority:  normal                   |        Milestone:  7.8.1
       Component:  Compiler                 |          Version:  7.6.1
      Resolution:                           |         Keywords:
Operating System:  Unknown/Multiple         |     Architecture:
 Type of failure:  Runtime performance bug  |  Unknown/Multiple
       Test Case:                           |       Difficulty:  Unknown
        Blocking:                           |       Blocked By:
                                            |  Related Tickets:
--------------------------------------------+------------------------------

Comment (by nomeata):

 The simple example from the ticket:
 {{{
 (#) :: (b -> c) -> (a -> b) -> a -> c
 (#) f g = f `seq` g `seq` \x -> f (g x)

 foo :: (a -> b) -> [a] -> [b]
 foo f = map (id # f)
 }}}

 produces
 {{{
 T7542.foo =
   \ (@ a) (@ b) (f :: a -> b) (eta :: [a]) ->
     GHC.Base.map @ a @ b (\ (eta1 :: a) -> f eta1) eta
 }}}
 without `-fpedantic-bottoms` and
 {{{
 T7542.foo = GHC.Base.map
 }}}
 with, which looks fine. The same happens to the more elaborate example in
 comment:2 (middle section), `-fpedantic-bottoms` preserves the semantics
 and with that we get `map2 = map`.

 So it seems that situation has improved and we can close the ticket (which
 should not discourage anyone who finds a situation that needs fixing to
 open it again).

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


More information about the ghc-tickets mailing list