[commit: ghc] master: Introduce DerivingVia (8ed8b03)

git at git.haskell.org git at git.haskell.org
Tue Jun 5 02:53:07 UTC 2018


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

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

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

commit 8ed8b037fee9611b1c4ef49adb6cf50bbd929a27
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Mon Jun 4 21:20:02 2018 -0400

    Introduce DerivingVia
    
    This implements the `DerivingVia` proposal put forth in
    https://github.com/ghc-proposals/ghc-proposals/pull/120.
    
    This introduces the `DerivingVia` deriving strategy. This is a
    generalization of `GeneralizedNewtypeDeriving` that permits the user
    to specify the type to `coerce` from.
    
    The major change in this patch is the introduction of the
    `ViaStrategy` constructor to `DerivStrategy`, which takes a type
    as a field. As a result, `DerivStrategy` is no longer a simple
    enumeration type, but rather something that must be renamed and
    typechecked. The process by which this is done is explained more
    thoroughly in section 3 of this paper
    ( https://www.kosmikus.org/DerivingVia/deriving-via-paper.pdf ),
    although I have inlined the relevant parts into Notes where possible.
    
    There are some knock-on changes as well. I took the opportunity to
    do some refactoring of code in `TcDeriv`, especially the
    `mkNewTypeEqn` function, since it was bundling all of the logic for
    (1) deriving instances for newtypes and
    (2) `GeneralizedNewtypeDeriving`
    into one huge broth. `DerivingVia` reuses much of part (2), so that
    was factored out as much as possible.
    
    Bumps the Haddock submodule.
    
    Test Plan: ./validate
    
    Reviewers: simonpj, bgamari, goldfire, alanz
    
    Subscribers: alanz, goldfire, rwbarton, thomie, mpickering, carter
    
    GHC Trac Issues: #15178
    
    Differential Revision: https://phabricator.haskell.org/D4684


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

8ed8b037fee9611b1c4ef49adb6cf50bbd929a27
 compiler/basicTypes/BasicTypes.hs                  |  27 -
 compiler/deSugar/DsMeta.hs                         |  31 +-
 compiler/hsSyn/Convert.hs                          |  18 +-
 compiler/hsSyn/HsDecls.hs                          |  66 ++-
 compiler/hsSyn/HsExtension.hs                      |   8 +
 compiler/hsSyn/HsInstances.hs                      |   5 +
 compiler/main/DynFlags.hs                          |   3 +
 compiler/parser/ApiAnnotation.hs                   |   1 +
 compiler/parser/Lexer.x                            |   2 +
 compiler/parser/Parser.y                           |  89 ++--
 compiler/prelude/THNames.hs                        |  47 +-
 compiler/rename/RnSource.hs                        | 158 +++++-
 compiler/typecheck/TcDeriv.hs                      | 572 ++++++++++++++-------
 compiler/typecheck/TcDerivUtils.hs                 |  97 ++--
 compiler/typecheck/TcHsType.hs                     |  53 +-
 docs/users_guide/8.6.1-notes.rst                   |   8 +
 docs/users_guide/glasgow_exts.rst                  | 128 ++++-
 .../ghc-boot-th/GHC/LanguageExtensions/Type.hs     |   1 +
 .../template-haskell/Language/Haskell/TH/Lib.hs    |  23 +-
 .../Language/Haskell/TH/Lib/Internal.hs            |  27 +-
 .../template-haskell/Language/Haskell/TH/Ppr.hs    |  19 +-
 .../template-haskell/Language/Haskell/TH/Syntax.hs |   1 +
 libraries/template-haskell/changelog.md            |   2 +
 testsuite/tests/deriving/should_compile/all.T      |   2 +
 .../should_compile/deriving-via-compile.hs         | 459 +++++++++++++++++
 .../should_compile/deriving-via-standalone.hs      |  41 ++
 testsuite/tests/deriving/should_fail/all.T         |   4 +
 .../deriving/should_fail/deriving-via-fail.hs      |  19 +
 .../deriving/should_fail/deriving-via-fail.stderr  |  16 +
 .../deriving/should_fail/deriving-via-fail2.hs     |   7 +
 .../deriving/should_fail/deriving-via-fail2.stderr |   6 +
 .../deriving/should_fail/deriving-via-fail3.hs     |   3 +
 .../deriving/should_fail/deriving-via-fail3.stderr |   4 +
 .../deriving/should_fail/deriving-via-fail4.hs     |  17 +
 .../deriving/should_fail/deriving-via-fail4.stderr |  18 +
 testsuite/tests/driver/T4437.hs                    |   1 +
 testsuite/tests/ghc-api/annotations/T10312.stdout  |   4 +-
 utils/haddock                                      |   2 +-
 38 files changed, 1608 insertions(+), 381 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 8ed8b037fee9611b1c4ef49adb6cf50bbd929a27


More information about the ghc-commits mailing list