diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:11 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-09-02 15:33:12 -0400 |
commit | 5dd6b13c6e2942976aa3b5f4906ff7d0f959272d (patch) | |
tree | 233df1050c497f1accc7a3ded00fa4bd9f71ee6e /docs/users_guide/8.4.1-notes.rst | |
parent | 6330b0b0938bc7b27463b3bbfa0df661e4a966b1 (diff) | |
download | haskell-5dd6b13c6e2942976aa3b5f4906ff7d0f959272d.tar.gz |
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
Diffstat (limited to 'docs/users_guide/8.4.1-notes.rst')
-rw-r--r-- | docs/users_guide/8.4.1-notes.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/users_guide/8.4.1-notes.rst b/docs/users_guide/8.4.1-notes.rst index 8a6d4048b4..8f61ef86fe 100644 --- a/docs/users_guide/8.4.1-notes.rst +++ b/docs/users_guide/8.4.1-notes.rst @@ -27,6 +27,20 @@ Language wish to; this is quite like how regular datatypes with a kind signature can omit some type variables. +- Implicitly bidirectional pattern synonyms no longer allow bang patterns + (``!``) or irrefutable patterns (``~``) on the right-hand side. Previously, + this was allowed, although the bang patterns and irrefutable patterns would + be silently ignored when used in an expression context. This is now a proper + error, and explicitly bidirectional pattern synonyms should be used in their + stead. That is, instead of using this (which is an error): :: + + data StrictJust a = Just !a + + Use this: :: + + data StrictJust a <- Just !a where + StrictJust !a = Just a + Compiler ~~~~~~~~ |