[GHC] #14112: bang patterns on pattern synonyms? (left vs right hand sides)
GHC
ghc-devs at haskell.org
Sat Sep 2 19:34:45 UTC 2017
#14112: bang patterns on pattern synonyms? (left vs right hand sides)
-------------------------------------+-------------------------------------
Reporter: carter | Owner: RyanGlScott
Type: bug | Status: patch
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3896
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott <ryan.gl.scott@…>):
In [changeset:"5dd6b13c6e2942976aa3b5f4906ff7d0f959272d/ghc"
5dd6b13c/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="5dd6b13c6e2942976aa3b5f4906ff7d0f959272d"
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
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14112#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list