summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Session.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-03-16 15:17:49 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-21 06:39:32 -0400
commit35e43d48a9a3ab22da90c4c2ea2c805fe762b9c5 (patch)
tree3cd08ed7ce20790f9fd522936b2d5e737f41c7f4 /compiler/GHC/Driver/Session.hs
parent70be0fbcefa07ff164437476bf2809ea7c3ff495 (diff)
downloadhaskell-35e43d48a9a3ab22da90c4c2ea2c805fe762b9c5.tar.gz
Avoid DynFlags in Ppr code (#17957)
* replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int`
Diffstat (limited to 'compiler/GHC/Driver/Session.hs')
-rw-r--r--compiler/GHC/Driver/Session.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 5ed6e093d7..8f64966131 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -230,7 +230,7 @@ module GHC.Driver.Session (
IncludeSpecs(..), addGlobalInclude, addQuoteInclude, flattenIncludes,
-- * SDoc
- initSDocContext,
+ initSDocContext, initDefaultSDocContext,
-- * Make use of the Cmm CFG
CfgWeights(..)
@@ -1588,7 +1588,8 @@ defaultLogActionHPutStrDoc :: DynFlags -> Handle -> SDoc -> PprStyle -> IO ()
defaultLogActionHPutStrDoc dflags h d sty
-- Don't add a newline at the end, so that successive
-- calls to this log-action can output all on the same line
- = printSDoc Pretty.PageMode dflags h sty d
+ = printSDoc ctx Pretty.PageMode h d
+ where ctx = initSDocContext dflags sty
newtype FlushOut = FlushOut (IO ())
@@ -5184,7 +5185,7 @@ emptyFilesToClean :: FilesToClean
emptyFilesToClean = FilesToClean Set.empty Set.empty
-
+-- | Initialize the pretty-printing options
initSDocContext :: DynFlags -> PprStyle -> SDocContext
initSDocContext dflags style = SDC
{ sdocStyle = style
@@ -5220,3 +5221,7 @@ initSDocContext dflags style = SDC
, sdocImpredicativeTypes = xopt LangExt.ImpredicativeTypes dflags
, sdocDynFlags = dflags
}
+
+-- | Initialize the pretty-printing options using the default user style
+initDefaultSDocContext :: DynFlags -> SDocContext
+initDefaultSDocContext dflags = initSDocContext dflags (defaultUserStyle dflags)