ghc-mod/Language/Haskell/GhcMod/Doc.hs

44 lines
1.5 KiB
Haskell
Raw Normal View History

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)
import Language.Haskell.GhcMod.Gap (withStyle, showDocWith)
2014-03-27 06:25:02 +00:00
import Outputable (SDoc, PprStyle, Depth(AllTheWay), mkUserStyle, alwaysQualify, neverQualify)
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
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
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
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
showUnqualifiedOneLine dflag = showDocWith dflag OneLineMode . withStyle dflag styleUnqualified