XTypeApplication and @spaces

Gracjan Polak gracjanpolak at gmail.com
Tue Feb 21 17:45:50 UTC 2017


Hi all,

I was thinking about implementing @Type syntax
<https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#visible-type-application>
highlight for haskell-mode <https://github.com/haskell/haskell-mode> and
noticed a rule about spacing required before @-sign.

I do not understand where does this rule come from and what does it buy us.

Experimentation shows that @-patterns do not care about spaces at all:

Prelude> let f a @ Nothing = print a in f Nothing
Nothing

Comment next to implementation says: "This, of course, conflicts with
as-patterns. The conflict arises because expressions and patterns use the
same parser, and also because we want to allow type patterns within
expression patterns."

As I understand pattern and expression contexts are always separate in
Haskell so the part just after 'of course' is not clear to me.

Can I get an example for "we want to allow type patterns within expression
patterns"?

I understand the part "expressions and patterns use the same parser" but
then I'd rather file a bug report about this one.

Rationale: I'd rather limit usage for horizontal space to separate tokens
on the lexer level. This looks like it tries to promote space to separate
things on parser level, which is rather hard to get right in crude parsers
that we have for syntax highligh, indentation, completion and the like.

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


More information about the ghc-devs mailing list