2013-05-17 01:00:01 +00:00
|
|
|
module Language.Haskell.GhcMod.Doc where
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2014-04-26 04:21:22 +00:00
|
|
|
import GHC (Ghc, DynFlags)
|
2014-04-03 00:49:23 +00:00
|
|
|
import qualified GHC as G
|
2014-01-14 06:37:16 +00:00
|
|
|
import Language.Haskell.GhcMod.Gap (withStyle, showDocWith)
|
2014-04-03 00:49:23 +00:00
|
|
|
import Outputable (SDoc, PprStyle, mkUserStyle, Depth(AllTheWay), neverQualify)
|
2014-01-14 06:37:16 +00:00
|
|
|
import Pretty (Mode(..))
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2014-04-03 00:49:23 +00:00
|
|
|
showPage :: DynFlags -> PprStyle -> SDoc -> String
|
|
|
|
showPage dflag style = showDocWith dflag PageMode . withStyle dflag style
|
2013-07-14 08:07:30 +00:00
|
|
|
|
2014-04-03 00:49:23 +00:00
|
|
|
showOneLine :: DynFlags -> PprStyle -> SDoc -> String
|
|
|
|
showOneLine dflag style = showDocWith dflag OneLineMode . withStyle dflag style
|
2013-07-14 08:07:30 +00:00
|
|
|
|
2014-04-03 00:49:23 +00:00
|
|
|
getStyle :: Ghc PprStyle
|
|
|
|
getStyle = do
|
|
|
|
unqual <- G.getPrintUnqual
|
|
|
|
return $ mkUserStyle unqual AllTheWay
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2013-07-14 08:07:30 +00:00
|
|
|
styleUnqualified :: PprStyle
|
|
|
|
styleUnqualified = mkUserStyle neverQualify AllTheWay
|