module HIE.Bios.Ghc.Doc where
import GHC (DynFlags, getPrintUnqual, pprCols, GhcMonad)
import Outputable (PprStyle, SDoc, withPprStyleDoc, neverQualify)
import Pretty (Mode(..), Doc, Style(..), renderStyle, style)
import HIE.Bios.Ghc.Gap (makeUserStyle)
showPage :: DynFlags -> PprStyle -> SDoc -> String
showPage :: DynFlags -> PprStyle -> SDoc -> String
showPage DynFlags
dflag PprStyle
stl = DynFlags -> Mode -> Doc -> String
showDocWith DynFlags
dflag Mode
PageMode (Doc -> String) -> (SDoc -> Doc) -> SDoc -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DynFlags -> PprStyle -> SDoc -> Doc
withPprStyleDoc DynFlags
dflag PprStyle
stl
showOneLine :: DynFlags -> PprStyle -> SDoc -> String
showOneLine :: DynFlags -> PprStyle -> SDoc -> String
showOneLine DynFlags
dflag PprStyle
stl = DynFlags -> Mode -> Doc -> String
showDocWith DynFlags
dflag Mode
OneLineMode (Doc -> String) -> (SDoc -> Doc) -> SDoc -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DynFlags -> PprStyle -> SDoc -> Doc
withPprStyleDoc DynFlags
dflag PprStyle
stl
getStyle :: (GhcMonad m) => DynFlags -> m PprStyle
getStyle :: DynFlags -> m PprStyle
getStyle DynFlags
dflags = DynFlags -> PrintUnqualified -> PprStyle
makeUserStyle DynFlags
dflags (PrintUnqualified -> PprStyle) -> m PrintUnqualified -> m PprStyle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m PrintUnqualified
forall (m :: * -> *). GhcMonad m => m PrintUnqualified
getPrintUnqual
styleUnqualified :: DynFlags -> PprStyle
styleUnqualified :: DynFlags -> PprStyle
styleUnqualified DynFlags
dflags = DynFlags -> PrintUnqualified -> PprStyle
makeUserStyle DynFlags
dflags PrintUnqualified
neverQualify
showDocWith :: DynFlags -> Mode -> Doc -> String
showDocWith :: DynFlags -> Mode -> Doc -> String
showDocWith DynFlags
dflags Mode
md = Style -> Doc -> String
renderStyle Style
mstyle
where
mstyle :: Style
mstyle = Style
style { mode :: Mode
mode = Mode
md, lineLength :: Int
lineLength = DynFlags -> Int
pprCols DynFlags
dflags }