<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Note that this rule is documented, in brief, in the manual:<div class=""><br class=""></div><div class="">> A visible type application is preceded with an <tt class="literal docutils">@</tt>
sign. (To disambiguate the syntax, the <tt class="literal docutils">@</tt> must be
preceded with a non-identifier letter, usually a space. For example,
<tt class="literal docutils"><span class="pre">read@Int</span> <span class="pre">5</span></tt> would not parse.)<div><br class=""><blockquote type="cite" class=""><div class="">On Aug 17, 2018, at 12:16 PM, Richard Eisenberg <<a href="mailto:rae@cs.brynmawr.edu" class="">rae@cs.brynmawr.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">The rule is this, implemented in the lexer:<br class=""><br class="">With -XTypeApplications on, the character immediately before an @ determines how it is lexed.<br class="">1. If the character is a legal end-of-identifier character (respecting the state of the -XMagicHash flag), then the @ is an as-pattern.<br class="">2. Otherwise, then the @ is the beginning of a type application.<br class=""><br class="">I abbreviate the rule as talking about whitespace sensitivity, because if the character preceding the @ is, say, a +, then we lex +@ as a user-defined operator.<br class=""><br class="">This rule has been implemented since GHC 8.0 and applies in patterns as well as expressions. I don't think anyone noticed. :) So it works reasonably well. It's a silly rule and I'd be happy to do better, but I don't think it's strictly necessary to aim for better here.<br class=""><br class="">It would be reasonable to warn when a user writes an as-pattern that doesn't conform to this rule (with -XNoTypeApplications).<br class=""><br class="">Richard<br class=""><br class=""><blockquote type="cite" class="">On Aug 17, 2018, at 1:37 AM, Joachim Breitner <<a href="mailto:mail@joachim-breitner.de" class="">mail@joachim-breitner.de</a>> wrote:<br class=""><br class="">Hi Richard,<br class=""><br class="">Am Donnerstag, den 16.08.2018, 22:28 -0400 schrieb Richard Eisenberg:<br class=""><blockquote type="cite" class="">Considering this future of relaxed ordering requirements on data<br class="">constructors isn't compulsory, but I do think it's better if we don't<br class="">paint ourselves into a corner around this.<br class=""></blockquote><br class="">I agree.<br class=""><br class="">But so what do we do? Already now require that there is no space<br class="">between @ and the following token when the user wants to use type<br class="">applications in the pattern?<br class=""><br class="">And would we also require the user to add a space after an at-pattern?<br class="">In which case we should probably start a deprecation cycle for the<br class="">currently legal<br class=""><br class="">  foo (a @b) = …<br class=""><br class=""><br class="">Cheers,<br class="">Joachim<br class=""><br class="">-- <br class="">Joachim Breitner<br class=""> <a href="mailto:mail@joachim-breitner.de" class="">mail@joachim-breitner.de</a><br class=""> <a href="http://www.joachim-breitner.de/" class="">http://www.joachim-breitner.de/</a><br class="">_______________________________________________<br class="">ghc-steering-committee mailing list<br class=""><a href="mailto:ghc-steering-committee@haskell.org" class="">ghc-steering-committee@haskell.org</a><br class="">https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee<br class=""></blockquote><br class="">_______________________________________________<br class="">ghc-steering-committee mailing list<br class=""><a href="mailto:ghc-steering-committee@haskell.org" class="">ghc-steering-committee@haskell.org</a><br class="">https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee<br class=""></div></div></blockquote></div><br class=""></div></body></html>