2013-05-17 01:00:01 +00:00
|
|
|
module Language.Haskell.GhcMod.Doc where
|
2013-03-12 13:15:23 +00:00
|
|
|
|
|
|
|
import DynFlags (DynFlags)
|
2014-01-14 06:37:16 +00:00
|
|
|
import Language.Haskell.GhcMod.Gap (withStyle, showDocWith)
|
2013-03-12 13:15:23 +00:00
|
|
|
import Outputable
|
2014-01-14 06:37:16 +00:00
|
|
|
import Pretty (Mode(..))
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2013-07-14 08:07:30 +00:00
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
{-
|
|
|
|
pretty :: Outputable a => a -> String
|
|
|
|
pretty = showSDocForUser neverQualify . ppr
|
|
|
|
|
|
|
|
debug :: Outputable a => a -> b -> b
|
|
|
|
debug x v = trace (pretty x) v
|
|
|
|
-}
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-03-12 13:15:23 +00:00
|
|
|
styleQualified :: PprStyle
|
|
|
|
styleQualified = mkUserStyle alwaysQualify AllTheWay
|
|
|
|
|
2013-07-14 08:07:30 +00:00
|
|
|
styleUnqualified :: PprStyle
|
|
|
|
styleUnqualified = mkUserStyle neverQualify AllTheWay
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-07-14 07:45:43 +00:00
|
|
|
-- For "ghc-mod type"
|
2013-03-12 13:15:23 +00:00
|
|
|
showQualifiedPage :: DynFlags -> SDoc -> String
|
2014-01-14 06:37:16 +00:00
|
|
|
showQualifiedPage dflag = showDocWith dflag PageMode . withStyle dflag styleQualified
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2013-07-14 08:07:30 +00:00
|
|
|
-- For "ghc-mod browse" and show GHC's error messages.
|
|
|
|
showUnqualifiedPage :: DynFlags -> SDoc -> String
|
2014-01-14 06:37:16 +00:00
|
|
|
showUnqualifiedPage dflag = showDocWith dflag PageMode
|
2013-07-14 08:07:30 +00:00
|
|
|
. withStyle dflag styleUnqualified
|
|
|
|
|
2013-07-14 07:45:43 +00:00
|
|
|
-- Not used
|
2013-03-12 13:15:23 +00:00
|
|
|
showQualifiedOneLine :: DynFlags -> SDoc -> String
|
2014-01-14 06:37:16 +00:00
|
|
|
showQualifiedOneLine dflag = showDocWith dflag OneLineMode . withStyle dflag styleQualified
|
2013-03-12 13:15:23 +00:00
|
|
|
|
2013-07-14 07:45:43 +00:00
|
|
|
-- To write Haskell code in a buffer
|
2013-03-12 13:15:23 +00:00
|
|
|
showUnqualifiedOneLine :: DynFlags -> SDoc -> String
|
2014-01-14 06:37:16 +00:00
|
|
|
showUnqualifiedOneLine dflag = showDocWith dflag OneLineMode . withStyle dflag styleUnqualified
|