[commit: ghc] master: Disallow bang/lazy patterns in the RHSes of implicitly bidirectional patsyns (5dd6b13)

git at git.haskell.org git at git.haskell.org
Sat Sep 2 19:34:55 UTC 2017


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

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

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

commit 5dd6b13c6e2942976aa3b5f4906ff7d0f959272d
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sat Sep 2 15:33:11 2017 -0400

    Disallow bang/lazy patterns in the RHSes of implicitly bidirectional patsyns
    
    Summary:
    GHC was allowing implicitly bidirectional pattern synonyms with bang
    patterns and irrefutable patterns in the RHS, like so:
    
    ```lang=haskell
    pattern StrictJust a = Just !a
    ```
    
    This has multiple problems:
    
    1. `Just !a` isn't a valid expression, so it feels strange to allow it in an
       implicitly bidirectional pattern synonym.
    2. `StrictJust` doesn't provide the strictness properties one would expect
       from a strict constructor. (One could imagine a design where the
       `StrictJust` builder infers a bang pattern for its pattern variable, but
       accomplishing this inference in a way that accounts for all possible
       patterns on the RHS, including other pattern synonyms, is somewhat
       awkward, so we do not pursue this design.)
    
    We nip these issues in the bud by simply disallowing bang/irrefutable patterns
    on the RHS.
    
    Test Plan: make test TEST="T14112 unidir"
    
    Reviewers: simonpj, austin, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #14112
    
    Differential Revision: https://phabricator.haskell.org/D3896


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

5dd6b13c6e2942976aa3b5f4906ff7d0f959272d
 compiler/typecheck/TcPatSyn.hs                   | 32 +++++++++++++++++++-----
 docs/users_guide/8.4.1-notes.rst                 | 14 +++++++++++
 docs/users_guide/glasgow_exts.rst                | 15 +++++++++++
 testsuite/tests/patsyn/should_fail/T14112.hs     |  5 ++++
 testsuite/tests/patsyn/should_fail/T14112.stderr |  7 ++++++
 testsuite/tests/patsyn/should_fail/all.T         |  1 +
 testsuite/tests/patsyn/should_fail/unidir.stderr |  4 ++-
 7 files changed, 71 insertions(+), 7 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 5dd6b13c6e2942976aa3b5f4906ff7d0f959272d


More information about the ghc-commits mailing list