[commit: ghc] master: Sequester deriving-related validity check into cond_stdOK (1a911f2)

git at git.haskell.org git at git.haskell.org
Thu Feb 1 04:30:17 UTC 2018


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

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

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

commit 1a911f217a18c8c0362ab2bf2b6ec7f7da015622
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Wed Jan 31 21:36:51 2018 -0500

    Sequester deriving-related validity check into cond_stdOK
    
    Currently, any standalone-derived instance must satisfy the
    property that the tycon of the data type having an instance being
    derived for it must be either a normal ADT tycon or a data family
    tycon. But there are several other primitive tycons—such as `(->)`,
    `Int#`, and others—which cannot have standalone-derived instances
    (via the `anyclass` strategy) as a result of this check! See
    https://ghc.haskell.org/trac/ghc/ticket/13154#comment:8 for an
    example of where this overly conservative restriction bites.
    
    Really, this validity check only makes sense in the context of
    `stock` deriving, where we need the property that the tycon is that
    of a normal ADT or a data family in order to inspect its data
    constructors. Other deriving strategies don't require this validity
    check, so the most sensible way to fix this error is to move the
    logic of this check into `cond_stdOK`, which is specific to
    `stock` deriving.
    
    This makes progress towards fixing (but does not entirely fix)
    
    Test Plan: make test TEST=T13154a
    
    Reviewers: bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #13154
    
    Differential Revision: https://phabricator.haskell.org/D4337


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

1a911f217a18c8c0362ab2bf2b6ec7f7da015622
 compiler/typecheck/TcDeriv.hs                      |  19 ++--
 compiler/typecheck/TcDerivUtils.hs                 | 123 ++++++++++++++-------
 testsuite/tests/deriving/should_compile/T13154a.hs |  14 +++
 testsuite/tests/deriving/should_compile/all.T      |   1 +
 4 files changed, 111 insertions(+), 46 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 1a911f217a18c8c0362ab2bf2b6ec7f7da015622


More information about the ghc-commits mailing list