2017-08-19 21:27:08 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
2017-05-28 02:22:56 +00:00
|
|
|
module GhcMod.Doc where
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2015-03-03 20:12:43 +00:00
|
|
|
import GHC
|
2017-05-28 02:22:56 +00:00
|
|
|
import GhcMod.Gap (withStyle, showDocWith)
|
2015-03-03 20:12:43 +00:00
|
|
|
import Outputable
|
2017-08-19 21:27:08 +00:00
|
|
|
#if __GLASGOW_HASKELL__ >= 802
|
|
|
|
import DynFlags
|
|
|
|
#endif
|
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-06-28 19:43:51 +00:00
|
|
|
getStyle :: GhcMonad m => m PprStyle
|
2014-04-03 00:49:23 +00:00
|
|
|
getStyle = do
|
2015-03-03 20:12:43 +00:00
|
|
|
unqual <- getPrintUnqual
|
2017-08-19 21:27:08 +00:00
|
|
|
#if __GLASGOW_HASKELL__ >= 802
|
|
|
|
dflags <- getDynFlags
|
|
|
|
return $ mkUserStyle dflags unqual AllTheWay
|
|
|
|
#else
|
2014-04-03 00:49:23 +00:00
|
|
|
return $ mkUserStyle unqual AllTheWay
|
2017-08-19 21:27:08 +00:00
|
|
|
#endif
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2017-08-19 21:27:08 +00:00
|
|
|
styleUnqualified :: DynFlags -> PprStyle
|
|
|
|
styleUnqualified dflags =
|
|
|
|
#if __GLASGOW_HASKELL__ >= 802
|
|
|
|
mkUserStyle dflags neverQualify AllTheWay
|
|
|
|
#else
|
|
|
|
mkUserStyle neverQualify AllTheWay
|
|
|
|
#endif
|