<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>



<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<h3>
Vladislav Zavialov pushed to branch wip/pat-builder-tagless
at <a href="https://gitlab.haskell.org/ghc/ghc">Glasgow Haskell Compiler / GHC</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.haskell.org/ghc/ghc/commit/0a18bd64ce54ea1c787366e3d38fc2f1a333f58c">0a18bd64</a></strong>
<div>
<span>by Vladislav Zavialov</span>
<i>at 2019-04-29T13:37:00Z</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">Pattern/expression ambiguity resolution

This patch removes 'EWildPat', 'EAsPat', 'EViewPat', and 'ELazyPat'
from 'HsExpr' by using the ambiguity resolution system introduced
earlier for the command/expression ambiguity.

Problem: there are places in the grammar where we do not know whether we
are parsing an expression or a pattern, for example:

        do { Con a b <- x } -- 'Con a b' is a pattern
        do { Con a b }      -- 'Con a b' is an expression

Until we encounter binding syntax (<-) we don't know whether to parse
'Con a b' as an expression or a pattern.

The old solution was to parse as HsExpr always, and rejig later:

        checkPattern :: LHsExpr GhcPs -> P (LPat GhcPs)

This meant polluting 'HsExpr' with pattern-related constructors. In
other words, limitations of the parser were affecting the AST, and all
other code (the renamer, the typechecker) had to deal with these extra
constructors.

We fix this abstraction leak by parsing into an overloaded
representation:

        class DisambECP b where ...
        newtype ECP = ECP { runECP_PV :: forall b. DisambECP b => PV (Located b) }

See Note [Ambiguous syntactic categories] for details.

Now the intricacies of parsing have no effect on the hsSyn AST when it
comes to the expression/pattern ambiguity.
</pre>
</li>
</ul>
<h4>30 changed files:</h4>
<ul>
<li class="file-stats">
<a href="#4cebcede53127700de963abffccad9d336d74889">
compiler/deSugar/DsExpr.hs
</a>
</li>
<li class="file-stats">
<a href="#7f924eb82ea52b493e50fc467c301adb6a0eaf32">
compiler/hieFile/HieAst.hs
</a>
</li>
<li class="file-stats">
<a href="#cd87eb0344087ad60213d14d7abe8bf5ed82b93f">
compiler/hsSyn/HsExpr.hs
</a>
</li>
<li class="file-stats">
<a href="#3ec3774412294d7ceaaa0572f116dc7c911d3f6d">
compiler/hsSyn/HsExtension.hs
</a>
</li>
<li class="file-stats">
<a href="#092e98c57072740713901cf146f61fc634f8a065">
compiler/parser/Lexer.x
</a>
</li>
<li class="file-stats">
<a href="#a9d23eb447426d7f3469127262985af461dfad78">
compiler/parser/Parser.y
</a>
</li>
<li class="file-stats">
<a href="#f68eb03961d8e370e8d3f41bd51ea01fd168779e">
compiler/parser/RdrHsSyn.hs
</a>
</li>
<li class="file-stats">
<a href="#f39c3af3fb50116eacfc5f437ab61dbe27ab59ac">
compiler/rename/RnExpr.hs
</a>
</li>
<li class="file-stats">
<a href="#d2ddf5ce2d076f8584d9825af8ea0d7ea0a38813">
compiler/typecheck/TcRnTypes.hs
</a>
</li>
<li class="file-stats">
<a href="#e8f7c9332028bfa8080629e1ed0fcb2cddb94ee5">
testsuite/tests/parser/should_fail/InfixAppPatErr.stderr
</a>
</li>
<li class="file-stats">
<a href="#4c7163a31074ede26fdddfdd4bedcc1d188d59bb">
testsuite/tests/parser/should_fail/T984.stderr
</a>
</li>
<li class="file-stats">
<a href="#3577fc796b73fe1f96c77f05fcdd73a8d4bc6f66">
testsuite/tests/parser/should_fail/all.T
</a>
</li>
<li class="file-stats">
<a href="#780e435d22277094983e9e8bd7ad54973f2b3ae9">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail001.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#47fb5cbb937e365b95854567196f2c5cd5b95f84">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail001.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#673654a5c9f2ab25d768289c4571bb0ae9c5feb5">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail002.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#2e554edef403d068d97b9c704f6256239a6c94a6">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail002.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#6d98d5de0e5a7bffdc889c5b13e0e894acb93bb2">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail003.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#bf8b136cc1ff6501d21bcf2a08350683f72ec7d6">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail003.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#50d8e5a3ff1a2c61a33d29db5883e90f23d6ce18">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail004.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#ea16e47f7355faeff89ef81cd22776a50893b0bf">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail004.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#d2fe954fde263e4abdce421386626f380dd015c9">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail005.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#a5456a668676210c4fccf547170597e597a86af9">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail005.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#7927a841ed038171ce7b99a1dfab57168a38bf20">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail006.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#461b086cefc4b4a0569fb5c057499810b3b08ca0">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail006.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#b330788ccf1eae1ec695301394aa79c119949345">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail007.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#40e778eae7f3d324b6876a3a6ae794a255ea7fef">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail007.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#6e827d6fa34d128716094dc8b688d7eedb561b83">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail008.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#30b30311e61652534393fdcf29c51c5a954232f6">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail008.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#304f4f114b214a99815b46a5e585905d366695fe">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail009.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#93153635ed84385fd0a867353f46d477a5920f94">
<span class="new-file">
+
testsuite/tests/parser/should_fail/cmdFail009.stderr
</span>
</a>
</li>
</ul>
<h5>The diff was not included because it is too large.</h5>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
<a href="https://gitlab.haskell.org/ghc/ghc/commit/0a18bd64ce54ea1c787366e3d38fc2f1a333f58c">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.haskell.org.
If you'd like to receive fewer emails, you can
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.haskell.org/ghc/ghc/commit/0a18bd64ce54ea1c787366e3d38fc2f1a333f58c"}}</script>

</p>
</div>
</body>
</html>