Parsing funny arrows

Csongor Kiss kiss.csongor.kiss at
Fri Aug 28 22:32:32 UTC 2020

Hello devs,

I am trying to modify GHC's parser to allow the following syntax in types:

  a -> @m b

but my naive attempt was unsuccessful:

type :: { LHsType GhcPs }
        : btype                        { $1 }
        | btype '->' PREFIX_AT btype ctype  ...

For example when I try to parse the following code (and turn on the lexer debug log):
  test :: a -> @m b
  test = undefined

I get the following 

token: ITvarid "test"
token: ITdcolon NormalSyntax
token: ITvarid "a"
token: ITrarrow NormalSyntax
token: ITtypeApp
token: ITvarid "m"
token: ITvarid "b"
token: ITsemi

Parse.hs:2:1: error:
    parse error (possibly incorrect indentation or mismatched brackets)
2 | test = undefined

I don't have much experience with hacking on the parser so I'm likely missing something obvious.
Could someone please point at what I might be doing wrong?

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list