diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-07-29 19:31:11 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-30 22:55:25 -0400 |
commit | 175cb5b4044e6f4ad2224f54115f42e7a8b08f9b (patch) | |
tree | abed7bbfd688ebceaba3032e5fd416b0eebb2b4e /compiler/GHC/Tc/TyCl.hs | |
parent | 7c274cd530cc42a26028050b75d56b3437e06ec1 (diff) | |
download | haskell-175cb5b4044e6f4ad2224f54115f42e7a8b08f9b.tar.gz |
DynFlags: don't use sdocWithDynFlags in datacon ppr
We don't need to use `sdocWithDynFlags` to know whether we should
display linear types for datacon types, we already have
`sdocLinearTypes` field in `SDocContext`. Moreover we want to remove
`sdocWithDynFlags` (#10143, #17957)).
Diffstat (limited to 'compiler/GHC/Tc/TyCl.hs')
-rw-r--r-- | compiler/GHC/Tc/TyCl.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/TyCl.hs b/compiler/GHC/Tc/TyCl.hs index 6d33be2e61..c928a529fd 100644 --- a/compiler/GHC/Tc/TyCl.hs +++ b/compiler/GHC/Tc/TyCl.hs @@ -4136,7 +4136,8 @@ checkValidDataCon dflags existential_ok tc con = hang herald 2 (text "on the" <+> speakNth n <+> text "argument of" <+> quotes (ppr con)) - data_con_display_type = dataConDisplayType dflags con + show_linear_types = xopt LangExt.LinearTypes dflags + data_con_display_type = dataConDisplayType show_linear_types con ------------------------------- checkNewDataCon :: DataCon -> TcM () @@ -4152,10 +4153,10 @@ checkNewDataCon con [ text "A newtype cannot have an unlifted argument type" , text "Perhaps you intended to use UnliftedNewtypes" ] - ; dflags <- getDynFlags + ; show_linear_types <- xopt LangExt.LinearTypes <$> getDynFlags ; let check_con what msg = - checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con)) + checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con)) ; checkTc (ok_mult (scaledMult arg_ty1)) $ text "A newtype constructor must be linear" @@ -4843,10 +4844,10 @@ badGadtDecl tc_name badExistential :: DataCon -> SDoc badExistential con - = sdocWithDynFlags (\dflags -> + = sdocOption sdocLinearTypes (\show_linear_types -> hang (text "Data constructor" <+> quotes (ppr con) <+> text "has existential type variables, a context, or a specialised result type") - 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType dflags con) + 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConDisplayType show_linear_types con) , parens $ text "Enable ExistentialQuantification or GADTs to allow this" ])) badStupidTheta :: Name -> SDoc |