Remove dependency on 'pretty'

Now using GHC's 'Pretty' module instead
This commit is contained in:
Daniel Gröber 2016-12-13 01:40:05 +01:00
parent e32cb977b7
commit 5d3e5932a7
11 changed files with 26 additions and 17 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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