summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorIavor Diatchki <iavor.diatchki@gmail.com>2018-06-07 13:32:27 -0400
committerBen Gamari <ben@smart-cactus.org>2018-06-07 18:06:31 -0400
commit200c8e046b44e38698d7e7bb9801f306e9570a0a (patch)
treec3e815b1c59d4fbf1c03cf4bffccf609ea1c9a63 /compiler/parser
parentdc8c03b2a5c70d3169e88d407f3ef28e0cb26af5 (diff)
downloadhaskell-200c8e046b44e38698d7e7bb9801f306e9570a0a.tar.gz
Allow Haddock comments before function arguments.
Currently, documentation strings on function arguments has to be written after the argument (i.e., using `{-^ -}` comments). This patch allows us to use `{-| -}` comments to put the comment string before an argument. The same works for the results of functions. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, mpickering, carter Differential Revision: https://phabricator.haskell.org/D4767
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Parser.y9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 6fc233ed42..25edb3e591 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1890,6 +1890,7 @@ type :: { LHsType GhcPs }
typedoc :: { LHsType GhcPs }
: btype { $1 }
| btype docprev { sLL $1 $> $ HsDocTy noExt $1 $2 }
+ | docnext btype { sLL $1 $> $ HsDocTy noExt $2 $1 }
| btype '->' ctypedoc {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations]
>> ams (sLL $1 $> $ HsFunTy noExt $1 $3)
[mu AnnRarrow $2] }
@@ -1899,6 +1900,14 @@ typedoc :: { LHsType GhcPs }
(HsDocTy noExt $1 $2))
$4)
[mu AnnRarrow $3] }
+ | docnext btype '->' ctypedoc {% ams $2 [mu AnnRarrow $3] -- See note [GADT decl discards annotations]
+ >> ams (sLL $1 $> $
+ HsFunTy noExt (L (comb2 $1 $2)
+ (HsDocTy noExt $2 $1))
+ $4)
+ [mu AnnRarrow $3] }
+
+
-- See Note [Parsing ~]
btype :: { LHsType GhcPs }