never executed always true always false
    1 -- | Printing related functions that depend on session state (DynFlags)
    2 module GHC.Driver.Ppr
    3    ( showSDoc
    4    , showSDocUnsafe
    5    , showSDocForUser
    6    , showPpr
    7    , showPprUnsafe
    8    , printForUser
    9    )
   10 where
   11 
   12 import GHC.Prelude
   13 
   14 import GHC.Driver.Session
   15 import GHC.Unit.State
   16 
   17 import GHC.Utils.Outputable
   18 import GHC.Utils.Ppr       ( Mode(..) )
   19 
   20 import System.IO ( Handle )
   21 
   22 -- | Show a SDoc as a String with the default user style
   23 showSDoc :: DynFlags -> SDoc -> String
   24 showSDoc dflags sdoc = renderWithContext (initSDocContext dflags defaultUserStyle) sdoc
   25 
   26 showPpr :: Outputable a => DynFlags -> a -> String
   27 showPpr dflags thing = showSDoc dflags (ppr thing)
   28 
   29 -- | Allows caller to specify the PrintUnqualified to use
   30 showSDocForUser :: DynFlags -> UnitState -> PrintUnqualified -> SDoc -> String
   31 showSDocForUser dflags unit_state unqual doc = renderWithContext (initSDocContext dflags sty) doc'
   32    where
   33       sty  = mkUserStyle unqual AllTheWay
   34       doc' = pprWithUnitState unit_state doc
   35 
   36 printForUser :: DynFlags -> Handle -> PrintUnqualified -> Depth -> SDoc -> IO ()
   37 printForUser dflags handle unqual depth doc
   38   = printSDocLn ctx (PageMode False) handle doc
   39     where ctx = initSDocContext dflags (mkUserStyle unqual depth)