Commit 638fde50 authored by Alan Zimmerman's avatar Alan Zimmerman

Add comment to Parser.y re extra API Annotation

Document extra AnnRarrow annotation on a HsFunTy
parent 4976ab2b
......@@ -1607,12 +1607,28 @@ context :: { LHsContext RdrName }
else return ()
; ams ctx anns
} }
{- Note [GADT decl discards annotations]
~~~~~~~~~~~~~~~~~~~~~
The type production for
btype `->` btype
adds the AnnRarrow annotation twice, in different places.
This is because if the type is processed as usual, it belongs on the annotations
for the type as a whole.
But if the type is passed to mkGadtDecl, it discards the top level SrcSpan, and
the top-level annotation will be disconnected. Hence for this specific case it
is connected to the first type too.
-}
-- See Note [Parsing ~]
type :: { LHsType RdrName }
: btype { splitTilde $1 }
| btype qtyconop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 }
| btype tyvarop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 }
| btype '->' ctype {% ams $1 [mu AnnRarrow $2]
| btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations]
>> ams (sLL $1 $> $ HsFunTy (splitTilde $1) $3)
[mu AnnRarrow $2] }
| btype SIMPLEQUOTE qconop type {% ams (sLL $1 $> $ mkHsOpTy $1 $3 $4)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment