diff options
author | David Feuer <david.feuer@gmail.com> | 2017-03-02 15:01:26 -0500 |
---|---|---|
committer | David Feuer <David.Feuer@gmail.com> | 2017-03-02 15:01:28 -0500 |
commit | bc332b3159613190a4dc33a067c1ab31039a8434 (patch) | |
tree | d8c61a195aba870b4083441dae4f57730b7b09af /docs/users_guide | |
parent | ae67619853d029ea8049a114f44e59f4ca10b990 (diff) | |
download | haskell-bc332b3159613190a4dc33a067c1ab31039a8434.tar.gz |
Prohibit RULES changing constructors
Previously, `RULES` like
```
{-# RULES
"JustNothing" forall x . Just x = Nothing
#-}
```
were allowed. Simon Peyton Jones say this seems to have been a
mistake, that such rules have never been supported intentionally,
and that he doesn't know if they can break in horrible ways.
Furthermore, Ben Gamari and Reid Barton are considering trying to
detect the presence of "static data" that the simplifier doesn't
need to traverse at all. Such rules do not play well with that.
So for now, we ban them altogether. In most cases, it's possible
to work around the ban using hand-written wrapper functions.
Reviewers: austin, simonpj, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3169
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/8.2.1-notes.rst | 10 | ||||
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/docs/users_guide/8.2.1-notes.rst b/docs/users_guide/8.2.1-notes.rst index 9a222e6003..b3dd2de93e 100644 --- a/docs/users_guide/8.2.1-notes.rst +++ b/docs/users_guide/8.2.1-notes.rst @@ -157,6 +157,16 @@ Compiler - The :ghc-flag:`-XExtendedDefaultRules` extension now defaults multi-parameter typeclasses. See :ghc-ticket:`12923`. +- GHC now ignores ``RULES`` for data constructors (:ghc-ticket:`13290`). + Previously, it accepted:: + + "NotAllowed" forall x. Just x = e + + That rule will no longer take effect, and a warning will be issued. ``RULES`` + may still mention data constructors, but not in the outermost position:: + + "StillWorks" forall x. f (Just x) = e + GHCi ~~~~ diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 6ba693547b..205e12a549 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -13268,9 +13268,11 @@ From a syntactic point of view: "wrong1" forall e1 e2. case True of { True -> e1; False -> e2 } = e1 "wrong2" forall f. f True = True + "wrong3" forall x. Just x = Nothing In ``"wrong1"``, the LHS is not an application; in ``"wrong2"``, the - LHS has a pattern variable in the head. + LHS has a pattern variable in the head. In ``"wrong3"``, the LHS consists + of a *constructor*, rather than a *variable*, applied to an argument. - A rule does not need to be in the same module as (any of) the variables it mentions, though of course they need to be in scope. |