[commit: ghc] master: Eliminate so-called "silent superclass parameters" (a6f0f5a)

git at git.haskell.org git at git.haskell.org
Tue Dec 23 16:29:32 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a6f0f5ab45b2643b561e0a0a54a4f14745ab2152/ghc

>---------------------------------------------------------------

commit a6f0f5ab45b2643b561e0a0a54a4f14745ab2152
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Dec 23 15:39:50 2014 +0000

    Eliminate so-called "silent superclass parameters"
    
    The purpose of silent superclass parameters was to solve the
    awkward problem of superclass dictinaries being bound to bottom.
    See THE PROBLEM in Note [Recursive superclasses] in TcInstDcls
    
    Although the silent-superclass idea worked,
    
      * It had non-local consequences, and had effects even in Haddock,
        where we had to discard silent parameters before displaying
        instance declarations
    
      * It had unexpected peformance costs, shown up by Trac #3064 and its
        test case.  In monad-transformer code, when constructing a Monad
        dictionary you had to pass an Applicative dictionary; and to
        construct that you neede a Functor dictionary. Yet these extra
        dictionaries were often never used.  (All this got much worse when
        we added Applicative as a superclass of Monad.) Test T3064
        compiled *far* faster after silent superclasses were eliminated.
    
      * It introduced new bugs.  For example SilentParametersOverlapping,
        T5051, and T7862, all failed to compile because of instance overlap
        directly because of the silent-superclass trick.
    
    So this patch takes a new approach, which I worked out with Dimitrios
    in the closing hours before Christmas.  It is described in detail
    in THE PROBLEM in Note [Recursive superclasses] in TcInstDcls.
    
    Seems to work great!
    
    Quite a bit of knock-on effect
    
     * The main implementation work is in tcSuperClasses in TcInstDcls
       Everything else is fall-out
    
     * IdInfo.DFunId no longer needs its n-silent argument
       * Ditto IDFunId in IfaceSyn
       * Hence interface file format changes
    
     * Now that DFunIds do not have silent superclass parameters, printing
       out instance declarations is simpler. There is tiny knock-on effect
       in Haddock, so that submodule is updated
    
     * I realised that when computing the "size of a dictionary type"
       in TcValidity.sizePred, we should be rather conservative about
       type functions, which can arbitrarily increase the size of a type.
       Hence the new datatype TypeSize, which has a TSBig constructor for
       "arbitrarily big".
    
     * instDFunType moves from TcSMonad to Inst
    
     * Interestingly, CmmNode and CmmExpr both now need a non-silent
       (Ord r) in a couple of instance declarations. These were previously
       silent but must now be explicit.
    
     * Quite a bit of wibbling in error messages


>---------------------------------------------------------------

a6f0f5ab45b2643b561e0a0a54a4f14745ab2152
 compiler/basicTypes/Id.hs                          |   7 +-
 compiler/basicTypes/IdInfo.hs                      |  13 +-
 compiler/basicTypes/MkId.hs                        |  20 +-
 compiler/basicTypes/OccName.hs                     |   7 +-
 compiler/cmm/CmmExpr.hs                            |   4 +-
 compiler/cmm/CmmNode.hs                            |   4 +-
 compiler/coreSyn/CoreUtils.hs                      |   2 +-
 compiler/deSugar/DsBinds.hs                        |   2 +-
 compiler/iface/IfaceSyn.hs                         |   8 +-
 compiler/iface/MkIface.hs                          |   2 +-
 compiler/iface/TcIface.hs                          |   4 +-
 compiler/typecheck/Inst.hs                         |  23 +-
 compiler/typecheck/TcInstDcls.hs                   | 282 +++++++++++++++++----
 compiler/typecheck/TcInteract.hs                   |  14 +-
 compiler/typecheck/TcMType.hs                      |   2 +-
 compiler/typecheck/TcSMonad.hs                     |  30 +--
 compiler/typecheck/TcSplice.hs                     |   5 +-
 compiler/typecheck/TcUnify.hs                      |  37 ++-
 compiler/typecheck/TcValidity.hs                   | 137 ++++++----
 compiler/types/InstEnv.hs                          |  12 +-
 .../tests/deriving/should_fail/drvfail002.stderr   |   2 +-
 .../should_compile/InstContextNorm.hs              |   2 +-
 testsuite/tests/indexed-types/should_fail/T7862.hs |   5 +-
 .../tests/indexed-types/should_fail/T7862.stderr   |  22 +-
 testsuite/tests/indexed-types/should_fail/all.T    |   2 +-
 testsuite/tests/perf/compiler/all.T                |   7 +-
 .../tests/simplCore/should_compile/Simpl020_A.hs   |   3 +-
 .../tests/simplCore/should_compile/T8848.stderr    |  45 +++-
 testsuite/tests/simplCore/should_compile/all.T     |   2 +-
 .../tests/simplCore/should_compile/simpl020.stderr |   2 +-
 .../should_fail/SilentParametersOverlapping.stderr |  13 -
 testsuite/tests/typecheck/should_fail/T5051.hs     |   2 +
 testsuite/tests/typecheck/should_fail/T5051.stderr |  14 +-
 testsuite/tests/typecheck/should_fail/T5691.stderr |  10 +
 testsuite/tests/typecheck/should_fail/T6161.hs     |  19 ++
 testsuite/tests/typecheck/should_fail/T6161.stderr |   8 +-
 testsuite/tests/typecheck/should_fail/T8603.stderr |   5 +
 testsuite/tests/typecheck/should_fail/all.T        |   4 +-
 .../tests/typecheck/should_fail/tcfail017.stderr   |   4 +-
 .../tests/typecheck/should_fail/tcfail019.stderr   |   5 +
 .../tests/typecheck/should_fail/tcfail020.stderr   |   4 +-
 .../tests/typecheck/should_fail/tcfail042.stderr   |  15 ++
 .../tests/typecheck/should_fail/tcfail106.stderr   |   5 +
 utils/haddock                                      |   2 +-
 44 files changed, 542 insertions(+), 275 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a6f0f5ab45b2643b561e0a0a54a4f14745ab2152


More information about the ghc-commits mailing list