When parsing the below function:
putStrLn $ 1 `foo` 2
-ddump-parsed-ast
shows the following AST (after cleaning it up), tested with both GHC 9.6.6 and 9.10.1:
OpApp _
( OpApp _
(HsVar "putStrLn")
(HsVar "$")
(HsIntegral 1)
)
(HsVar "foo")
(HsIntegral 2)
I would think that the parse step takes fixity into account, is that not the case?
I’m writing a compiler plugin that basically does a rewrite of some expressions, e.g.
bar 10 `foo` baz
====>
foo (Expr "bar 10" (bar 10)) (Expr "baz" baz)
but the incorrect fixity is giving me weird results here:
putStrLn $ 1 `foo` 2
====>
foo (Expr "putStrLn $ 1" (putStrLn $ 1)) (Expr "2" 2)
I’m currently hooking into parsedResultAction
; is that not the right place to do this? Do I need to use renamedResultAction
? I think that would work too, as long as it’s before the typechecking phase