[commit: ghc] master: Refactor default methods (Trac #11105) (924f851)

git at git.haskell.org git at git.haskell.org
Wed Nov 25 16:30:36 UTC 2015


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

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

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

commit 924f851700ca9ba7e0e7483b7ca4de62a4a74e15
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Nov 25 16:26:23 2015 +0000

    Refactor default methods (Trac #11105)
    
    This patch does some signficant refactoring to the treatment
    of default methods in class declarations, and more generally
    to the type checking of type/class decls.
    
    Highlights:
    
    * When the class has a generic-default method, such as
         class C a where
           op :: a -> a -> Bool
           default op :: Ord a => a -> a -> a
      the ClassOpItem records the type of the generic-default,
      in this case the type (Ord a => a -> a -> a)
    
    * I killed off Class.DefMeth in favour of the very-similar
      BasicTypes.DefMethSpec.  However it turned out to be better
      to use a Maybe, thus
          Maybe (DefMethSpec Type)
      with Nothing meaning "no default method".
    
    * In TcTyClsDecls.tcTyClGroup, we used to accumulate a [TyThing],
      but I found a way to make it much simpler, accumulating only
      a [TyCon].  Much less wrapping and unwrapping.
    
    * On the way I also fixed Trac #10896 in a better way. Instead
      of killing off all ambiguity checks whenever there are any type
      errors (the fix in commit 8e8b9ed), I instead recover in
      TcTyClsDecls.checkValidTyCl.
    
    There was a lot of associated simplification all round


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

924f851700ca9ba7e0e7483b7ca4de62a4a74e15
 compiler/basicTypes/BasicTypes.hs                  |  16 +-
 compiler/hsSyn/HsDecls.hs                          |   7 +-
 compiler/iface/BuildTyCl.hs                        |  14 +-
 compiler/iface/IfaceSyn.hs                         |  36 ++--
 compiler/iface/IfaceType.hs                        |  13 +-
 compiler/iface/MkIface.hs                          |   9 +-
 compiler/iface/TcIface.hs                          |  18 +-
 compiler/main/HscTypes.hs                          |   3 +-
 compiler/typecheck/TcClassDcl.hs                   |  64 +++---
 compiler/typecheck/TcDeriv.hs                      |   6 +-
 compiler/typecheck/TcEnv.hs                        |  19 +-
 compiler/typecheck/TcInstDcls.hs                   |  28 +--
 compiler/typecheck/TcRnDriver.hs                   |   6 +-
 compiler/typecheck/TcSplice.hs                     |   7 +-
 compiler/typecheck/TcTyClsDecls.hs                 | 220 ++++++++++-----------
 compiler/typecheck/TcTyDecls.hs                    |  55 +++---
 compiler/typecheck/TcTypeable.hs                   |   4 +-
 compiler/typecheck/TcValidity.hs                   |   6 +-
 compiler/types/Class.hs                            |  35 ++--
 compiler/types/TyCon.hs                            |  25 ++-
 compiler/utils/Binary.hs                           |  11 --
 compiler/vectorise/Vectorise/Type/TyConDecl.hs     |   6 +-
 testsuite/tests/th/T9064.stderr                    |   5 +-
 testsuite/tests/typecheck/should_fail/T5300.stderr |  45 +++--
 testsuite/tests/typecheck/should_fail/T8030.stderr |  31 ++-
 25 files changed, 386 insertions(+), 303 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 924f851700ca9ba7e0e7483b7ca4de62a4a74e15


More information about the ghc-commits mailing list