diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2019-04-18 12:53:56 -0700 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-19 23:50:29 -0400 |
commit | 99dd5d6b8365ecc8748651395c503b2c0b82490e (patch) | |
tree | eac883813baa2f1e53f54e3727c6f428987c7544 /compiler/hsSyn | |
parent | e7280c93ef8f0685bbd63552b5b72c029907687e (diff) | |
download | haskell-99dd5d6b8365ecc8748651395c503b2c0b82490e.tar.gz |
Haddock: support strict GADT args with docs
Rather than massaging the output of the parser to re-arrange docs and
bangs, it is simpler to patch the two places in which the strictness
info is needed (to accept that the `HsBangTy` may be inside an
`HsDocTy`).
Fixes #16585.
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r-- | compiler/hsSyn/HsTypes.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs index 9bb73c361b..b186b36abb 100644 --- a/compiler/hsSyn/HsTypes.hs +++ b/compiler/hsSyn/HsTypes.hs @@ -105,14 +105,22 @@ import Data.Data hiding ( Fixity, Prefix, Infix ) type LBangType pass = Located (BangType pass) -- | Bang Type +-- +-- In the parser, strictness and packedness annotations bind more tightly +-- than docstrings. This means that when consuming a 'BangType' (and looking +-- for 'HsBangTy') we must be ready to peer behind a potential layer of +-- 'HsDocTy'. See #15206 for motivation and 'getBangType' for an example. type BangType pass = HsType pass -- Bangs are in the HsType data type getBangType :: LHsType a -> LHsType a -getBangType (L _ (HsBangTy _ _ ty)) = ty -getBangType ty = ty +getBangType (L _ (HsBangTy _ _ lty)) = lty +getBangType (L _ (HsDocTy x (L _ (HsBangTy _ _ lty)) lds)) = + addCLoc lty lds (HsDocTy x lty lds) +getBangType lty = lty getBangStrictness :: LHsType a -> HsSrcBang -getBangStrictness (L _ (HsBangTy _ s _)) = s +getBangStrictness (L _ (HsBangTy _ s _)) = s +getBangStrictness (L _ (HsDocTy _ (L _ (HsBangTy _ s _)) _)) = s getBangStrictness _ = (HsSrcBang NoSourceText NoSrcUnpack NoSrcStrict) {- |