[GHC] #9291: Don't reconstruct sum types if the type subtly changes

GHC ghc-devs at haskell.org
Fri Dec 2 21:29:56 UTC 2016


#9291: Don't reconstruct sum types if the type subtly changes
-------------------------------------+-------------------------------------
        Reporter:  schyler           |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.8.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by nomeata):

 I was considering this problem a bit more today, and my best shot at this
 so far turned out to be quite similar to what  [comment:6 rwbarton]
 already suggested above. Richard thinks this might be interesting to get
 right (with type safety proofs and all that).

 Replying to [comment:13 simonpj]:
 > I hate the fact that a type-system question forces us to lose a
 potential optimisation.

 Me too! Although any solution will likely incur some changes to Core, and
 that probably needs to be justified by more than the unhappy feeling I
 have about Core’s type system getting in the way of producing the
 obviously right code.

 Does anyone have a practical example where this bug bytes a lot? Maybe
 something with lenses, or with generic programs?

 It seems to affect, for example, every `Functor` instance for a sum type
 where the type parameter is not used in at least one of the branches.

 Anyways, I started writing down a possible approach with more detail at
 CaseBinderGeneralisation. Comments welcome.

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


More information about the ghc-tickets mailing list