[commit: ghc] wip/pattern-synonym-backport: In pattern synonym matchers, support unboxed continuation results (fixes #9783). (a91a2af)
git at git.haskell.org
git at git.haskell.org
Sat Dec 20 02:53:34 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/pattern-synonym-backport
Link : http://ghc.haskell.org/trac/ghc/changeset/a91a2afa3a7e06f2f78ec4d479cc7ed527d305c5/ghc
>---------------------------------------------------------------
commit a91a2afa3a7e06f2f78ec4d479cc7ed527d305c5
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date: Sat Dec 20 10:51:09 2014 +0800
In pattern synonym matchers, support unboxed continuation results (fixes #9783).
This requires ensuring the continuations have arguments by adding a dummy
Void# argument when needed. This is so that matching on a pattern synonym
is lazy even when the result is unboxed, e.g.
pattern P = ()
f P = 0#
In this case, without dummy arguments, the generated matcher's type would be
$mP :: forall (r :: ?). () -> r -> r -> r
which is called in `f` at type `() -> Int# -> Int# -> Int#`,
so it would be strict, in particular, in the failure continuation
of `patError`.
We work around this by making sure both continuations have arguments:
$mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r
Of course, if `P` (and thus, the success continuation) has any arguments,
we are only adding the extra dummy argument to the failure continuation.
(cherry picked from commit 474e535b6b121809a8d75df5a4c37dc574d3d302)
>---------------------------------------------------------------
a91a2afa3a7e06f2f78ec4d479cc7ed527d305c5
compiler/basicTypes/PatSyn.lhs | 29 ++++++++++++++------
compiler/deSugar/DsUtils.lhs | 7 ++++-
compiler/typecheck/TcPatSyn.lhs | 31 +++++++++++-----------
testsuite/tests/patsyn/should_run/.gitignore | 1 +
testsuite/tests/patsyn/should_run/T9783.hs | 15 +++++++++++
.../should_run/T9783.stdout} | 2 +-
testsuite/tests/patsyn/should_run/all.T | 1 +
7 files changed, 61 insertions(+), 25 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 a91a2afa3a7e06f2f78ec4d479cc7ed527d305c5
More information about the ghc-commits
mailing list