diff --git a/Language/Haskell/GhcMod/Debug.hs b/Language/Haskell/GhcMod/Debug.hs index 0fbb8f5..9f391cc 100644 --- a/Language/Haskell/GhcMod/Debug.hs +++ b/Language/Haskell/GhcMod/Debug.hs @@ -9,7 +9,7 @@ import Data.Char import Data.Version import Data.List.Split import System.Directory -import Text.PrettyPrint +import Pretty import Language.Haskell.GhcMod.Monad import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Internal diff --git a/Language/Haskell/GhcMod/Error.hs b/Language/Haskell/GhcMod/Error.hs index 4ec373c..362c06e 100644 --- a/Language/Haskell/GhcMod/Error.hs +++ b/Language/Haskell/GhcMod/Error.hs @@ -39,11 +39,11 @@ import qualified Data.Set as Set import Data.List import Data.Version import System.Process (showCommandForUser) -import Text.PrettyPrint import Text.Printf import Exception import Panic +import Pretty import Config (cProjectVersion, cHostPlatformString) import Paths_ghc_mod (version) diff --git a/Language/Haskell/GhcMod/FillSig.hs b/Language/Haskell/GhcMod/FillSig.hs index 3e03ec0..c58e248 100644 --- a/Language/Haskell/GhcMod/FillSig.hs +++ b/Language/Haskell/GhcMod/FillSig.hs @@ -13,12 +13,12 @@ import Data.Functor import Data.List (find, nub, sortBy) import qualified Data.Map as M import Data.Maybe (catMaybes) -import Text.PrettyPrint (($$), text, nest) import Prelude import Exception (ghandle, SomeException(..)) import GHC (GhcMonad, Id, ParsedModule(..), TypecheckedModule(..), DynFlags, SrcSpan, Type, GenLocated(L)) +import Pretty (($$), text, nest) import qualified GHC as G import qualified Name as G import Outputable (PprStyle) diff --git a/Language/Haskell/GhcMod/HomeModuleGraph.hs b/Language/Haskell/GhcMod/HomeModuleGraph.hs index e9e2a85..bb1f350 100644 --- a/Language/Haskell/GhcMod/HomeModuleGraph.hs +++ b/Language/Haskell/GhcMod/HomeModuleGraph.hs @@ -39,6 +39,7 @@ import Exception import Finder import GHC import HscTypes +import Pretty import Control.Arrow ((&&&)) import Control.Applicative @@ -223,7 +224,7 @@ updateHomeModuleGraph' env smp0 = do Left errs -> do -- TODO: Remember these and present them as proper errors if this is -- the file the user is looking at. - gmLog GmWarning ("preprocess " ++ show fn) $ Monoid.mempty $+$ (vcat $ map text errs) + gmLog GmWarning ("preprocess " ++ show fn) $ Pretty.empty $+$ (vcat $ map text errs) return Nothing diff --git a/Language/Haskell/GhcMod/Logger.hs b/Language/Haskell/GhcMod/Logger.hs index 74e88f0..62c6e0f 100644 --- a/Language/Haskell/GhcMod/Logger.hs +++ b/Language/Haskell/GhcMod/Logger.hs @@ -17,7 +17,6 @@ import Data.Function import Control.Monad.Reader (Reader, ask, runReader) import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef) import System.FilePath (normalise) -import Text.PrettyPrint import ErrUtils import GHC @@ -34,6 +33,7 @@ import Language.Haskell.GhcMod.DynFlags (withDynFlags) import Language.Haskell.GhcMod.Monad.Types import Language.Haskell.GhcMod.Error import Language.Haskell.GhcMod.Utils (mkRevRedirMapFunc) +import Language.Haskell.GhcMod.Pretty import qualified Language.Haskell.GhcMod.Gap as Gap import Prelude diff --git a/Language/Haskell/GhcMod/Logging.hs b/Language/Haskell/GhcMod/Logging.hs index a7768ff..14f021d 100644 --- a/Language/Haskell/GhcMod/Logging.hs +++ b/Language/Haskell/GhcMod/Logging.hs @@ -20,8 +20,8 @@ module Language.Haskell.GhcMod.Logging ( module Language.Haskell.GhcMod.Logging , module Language.Haskell.GhcMod.Pretty , GmLogLevel(..) - , module Text.PrettyPrint , module Data.Monoid + , module Pretty ) where import Control.Applicative hiding (empty) @@ -33,9 +33,10 @@ import Data.Monoid import Data.Maybe import System.IO import System.FilePath -import Text.PrettyPrint hiding (style, (<>)) import Prelude +import Pretty hiding (style, (<>)) + import Language.Haskell.GhcMod.Monad.Types import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Pretty @@ -77,7 +78,7 @@ gmLog level loc' doc = do let loc | loc' == "" = empty | otherwise = text loc' <+>: empty msgDoc = sep [loc, doc] - msg = dropWhileEnd isSpace $ gmRenderDoc $ gmLogLevelDoc level <+>: msgDoc + msg = dropWhileEnd isSpace $ render $ gmLogLevelDoc level <+>: msgDoc when (level <= level') $ gmErrStrLn msg gmLogQuiet level loc' doc diff --git a/Language/Haskell/GhcMod/Pretty.hs b/Language/Haskell/GhcMod/Pretty.hs index b2d9e7d..2e498e9 100644 --- a/Language/Haskell/GhcMod/Pretty.hs +++ b/Language/Haskell/GhcMod/Pretty.hs @@ -20,15 +20,24 @@ import Control.Arrow hiding ((<+>)) import Data.Char import Data.List import Distribution.Helper -import Text.PrettyPrint +import Pretty +import GHC +import Outputable (SDoc, withPprStyleDoc) import Language.Haskell.GhcMod.Types +import Language.Haskell.GhcMod.Doc docStyle :: Style docStyle = style { ribbonsPerLine = 1.2 } -gmRenderDoc :: Doc -> String -gmRenderDoc = renderStyle docStyle +render :: Doc -> String +render = renderStyle docStyle + +renderSDoc :: GhcMonad m => SDoc -> m Doc +renderSDoc sdoc = do + df <- getSessionDynFlags + ppsty <- getStyle + return $ withPprStyleDoc df ppsty sdoc gmComponentNameDoc :: ChComponentName -> Doc gmComponentNameDoc ChSetupHsName = text $ "Setup.hs" diff --git a/Language/Haskell/GhcMod/Target.hs b/Language/Haskell/GhcMod/Target.hs index 30b461b..64fbfdf 100644 --- a/Language/Haskell/GhcMod/Target.hs +++ b/Language/Haskell/GhcMod/Target.hs @@ -28,6 +28,7 @@ import GHC.Paths (libdir) import SysTools import DynFlags import HscTypes +import Pretty import Language.Haskell.GhcMod.DynFlags import Language.Haskell.GhcMod.Monad.Types @@ -393,7 +394,7 @@ resolveModule env srcDirs (Left fn') = do case emn of Left errs -> do gmLog GmWarning ("resolveModule " ++ show fn) $ - Monoid.mempty $+$ (vcat $ map text errs) + Pretty.empty $+$ (vcat $ map text errs) return Nothing -- TODO: should expose these errors otherwise -- modules with preprocessor/parse errors are -- going to be missing diff --git a/Language/Haskell/GhcMod/Types.hs b/Language/Haskell/GhcMod/Types.hs index 2be44cc..4836abb 100644 --- a/Language/Haskell/GhcMod/Types.hs +++ b/Language/Haskell/GhcMod/Types.hs @@ -37,7 +37,7 @@ import qualified MonadUtils as GHC (MonadIO(..)) import GHC (ModuleName, moduleNameString, mkModuleName) import HscTypes (HscEnv) import GHC.Generics -import Text.PrettyPrint (Doc) +import Pretty (Doc) import Prelude import Language.Haskell.GhcMod.Caching.Types diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 062dbfa..a14a02e 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -186,7 +186,6 @@ Library , hlint < 1.10 && >= 1.9.27 , monad-journal < 0.8 && >= 0.4 , old-time < 1.2 - , pretty < 1.2 , process < 1.5 , syb < 0.7 , temporary < 1.3 @@ -224,7 +223,6 @@ Executable ghc-mod Build-Depends: base < 5 && >= 4.0 , directory < 1.3 , filepath < 1.5 - , pretty < 1.2 , process < 1.5 , split < 0.3 , mtl < 2.3 && >= 2.0 @@ -306,7 +304,6 @@ Benchmark criterion Build-Depends: base , directory < 1.3 , filepath < 1.5 - , pretty < 1.2 , process < 1.5 , split < 0.3 , mtl < 2.3 && >= 2.0 diff --git a/src/GHCMod.hs b/src/GHCMod.hs index ed28d56..1cc11d7 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -18,7 +18,7 @@ import System.Directory (setCurrentDirectory, getAppUserDataDirectory, removeDirectoryRecursive) import System.IO import System.Exit -import Text.PrettyPrint hiding ((<>)) +import Pretty hiding ((<>)) import GHCMod.Options import Prelude