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

44 lines
1.3 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)
2013-07-14 08:07:30 +00:00
import Language.Haskell.GhcMod.Gap (withStyle)
2013-03-12 13:15:23 +00:00
import Outputable
import Pretty
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 PageMode . withStyle dflag styleQualified
2013-07-14 08:07:30 +00:00
-- For "ghc-mod browse" and show GHC's error messages.
showUnqualifiedPage :: DynFlags -> SDoc -> String
showUnqualifiedPage dflag = Pretty.showDocWith Pretty.PageMode
. 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 OneLineMode . withStyle dflag styleQualified
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 OneLineMode . withStyle dflag styleUnqualified