XTypeApplication and @spaces

Gracjan Polak gracjanpolak at gmail.com
Tue Feb 21 20:40:59 UTC 2017


2017-02-21 19:55 GMT+01:00 Richard Eisenberg <rae at cs.brynmawr.edu>:

> As I understand pattern and expression contexts are always separate in
> Haskell so the part just after 'of course' is not clear to me.
>
>
> Sadly, this is not true. We don’t always know whether we’re parsing an
> expression or a pattern. Specifically, imagine this prefix of a Haskell
> definition:
>
> foo = do
>   Just x
>

Ah yes, partial parses. I did not think about this.


> With -XTypeApplications, GHC lexes ‘ @‘ and ‘@‘ separately.
>

For the record:

GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> :set -XTypeApplications
Prelude> let f x at Nothing = print x in f Nothing
Nothing
Prelude> let f x @Nothing = print x in f Nothing
<interactive>:3:5: error: Parse error in pattern: f x @Nothing
Prelude> let f x@ Nothing = print x in f Nothing
Nothing
Prelude> let f x @ Nothing = print x in f Nothing
<interactive>:11:5: error: Parse error in pattern: f x @Nothing
Prelude> :set -XNoTypeApplications
Prelude> let f x at Nothing = print x in f Nothing
Nothing
Prelude> let f x@ Nothing = print x in f Nothing
Nothing
Prelude> let f x @Nothing = print x in f Nothing
Nothing
Prelude> let f x @ Nothing = print x in f Nothing
Nothing


> Perhaps the ghc-proposals process will bring such problems to light
> sooner. I’m sorry our design decisions here have caused trouble!
>

As I understand keeping Language Report full up to date is a lot of work,
but keeping just the sections about Lexing and Parsing up to date should be
a part of ghc-proposals in my opinion, so that independent tools have
information to rely on.

-- 
Gracjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20170221/5f4125ab/attachment.html>


More information about the ghc-devs mailing list