• Ryan Scott's avatar
    Refactor derived Generic instances to reduce allocations · 9649fc0a
    Ryan Scott authored
    Previously, derived implementations of `to`/`from` in `Generic`
    instances were wastefully putting extra `M1`s in every case, which led
    to an O(n) increase in the number of coercions, resulting in a slowdown
    during the typechecker phase.
    
    This factors out the common `M1` in every case of a `to`/`from`
    definition so that the typechecker has far fewer coercions to deal with.
    For a datatype with 300 constructors, this change has been observed to
    save almost 3 seconds of compilation time.
    
    This is one step towards coming up with a solution for #5642.
    
    Test Plan: ./validate
    
    Reviewers: hvr, austin, simonpj, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: basvandijk, carter, thomie, osa1
    
    Differential Revision: https://phabricator.haskell.org/D2304
    
    GHC Trac Issues: #5642
    9649fc0a
GenDerivOutput.stderr 16 KB