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.Version
import Data.List.Split import Data.List.Split
import System.Directory import System.Directory
import Text.PrettyPrint import Pretty
import Language.Haskell.GhcMod.Monad import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.Internal import Language.Haskell.GhcMod.Internal

View File

@ -39,11 +39,11 @@ import qualified Data.Set as Set
import Data.List import Data.List
import Data.Version import Data.Version
import System.Process (showCommandForUser) import System.Process (showCommandForUser)
import Text.PrettyPrint
import Text.Printf import Text.Printf
import Exception import Exception
import Panic import Panic
import Pretty
import Config (cProjectVersion, cHostPlatformString) import Config (cProjectVersion, cHostPlatformString)
import Paths_ghc_mod (version) import Paths_ghc_mod (version)

View File

@ -13,12 +13,12 @@ import Data.Functor
import Data.List (find, nub, sortBy) import Data.List (find, nub, sortBy)
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe (catMaybes) import Data.Maybe (catMaybes)
import Text.PrettyPrint (($$), text, nest)
import Prelude import Prelude
import Exception (ghandle, SomeException(..)) import Exception (ghandle, SomeException(..))
import GHC (GhcMonad, Id, ParsedModule(..), TypecheckedModule(..), DynFlags, import GHC (GhcMonad, Id, ParsedModule(..), TypecheckedModule(..), DynFlags,
SrcSpan, Type, GenLocated(L)) SrcSpan, Type, GenLocated(L))
import Pretty (($$), text, nest)
import qualified GHC as G import qualified GHC as G
import qualified Name as G import qualified Name as G
import Outputable (PprStyle) import Outputable (PprStyle)

View File

@ -39,6 +39,7 @@ import Exception
import Finder import Finder
import GHC import GHC
import HscTypes import HscTypes
import Pretty
import Control.Arrow ((&&&)) import Control.Arrow ((&&&))
import Control.Applicative import Control.Applicative
@ -223,7 +224,7 @@ updateHomeModuleGraph' env smp0 = do
Left errs -> do Left errs -> do
-- TODO: Remember these and present them as proper errors if this is -- TODO: Remember these and present them as proper errors if this is
-- the file the user is looking at. -- 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 return Nothing

View File

@ -17,7 +17,6 @@ import Data.Function
import Control.Monad.Reader (Reader, ask, runReader) import Control.Monad.Reader (Reader, ask, runReader)
import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef) import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef)
import System.FilePath (normalise) import System.FilePath (normalise)
import Text.PrettyPrint
import ErrUtils import ErrUtils
import GHC import GHC
@ -34,6 +33,7 @@ import Language.Haskell.GhcMod.DynFlags (withDynFlags)
import Language.Haskell.GhcMod.Monad.Types import Language.Haskell.GhcMod.Monad.Types
import Language.Haskell.GhcMod.Error import Language.Haskell.GhcMod.Error
import Language.Haskell.GhcMod.Utils (mkRevRedirMapFunc) import Language.Haskell.GhcMod.Utils (mkRevRedirMapFunc)
import Language.Haskell.GhcMod.Pretty
import qualified Language.Haskell.GhcMod.Gap as Gap import qualified Language.Haskell.GhcMod.Gap as Gap
import Prelude import Prelude

View File

@ -20,8 +20,8 @@ module Language.Haskell.GhcMod.Logging (
module Language.Haskell.GhcMod.Logging module Language.Haskell.GhcMod.Logging
, module Language.Haskell.GhcMod.Pretty , module Language.Haskell.GhcMod.Pretty
, GmLogLevel(..) , GmLogLevel(..)
, module Text.PrettyPrint
, module Data.Monoid , module Data.Monoid
, module Pretty
) where ) where
import Control.Applicative hiding (empty) import Control.Applicative hiding (empty)
@ -33,9 +33,10 @@ import Data.Monoid
import Data.Maybe import Data.Maybe
import System.IO import System.IO
import System.FilePath import System.FilePath
import Text.PrettyPrint hiding (style, (<>))
import Prelude import Prelude
import Pretty hiding (style, (<>))
import Language.Haskell.GhcMod.Monad.Types import Language.Haskell.GhcMod.Monad.Types
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.Pretty import Language.Haskell.GhcMod.Pretty
@ -77,7 +78,7 @@ gmLog level loc' doc = do
let loc | loc' == "" = empty let loc | loc' == "" = empty
| otherwise = text loc' <+>: empty | otherwise = text loc' <+>: empty
msgDoc = sep [loc, doc] msgDoc = sep [loc, doc]
msg = dropWhileEnd isSpace $ gmRenderDoc $ gmLogLevelDoc level <+>: msgDoc msg = dropWhileEnd isSpace $ render $ gmLogLevelDoc level <+>: msgDoc
when (level <= level') $ gmErrStrLn msg when (level <= level') $ gmErrStrLn msg
gmLogQuiet level loc' doc gmLogQuiet level loc' doc

View File

@ -20,15 +20,24 @@ import Control.Arrow hiding ((<+>))
import Data.Char import Data.Char
import Data.List import Data.List
import Distribution.Helper import Distribution.Helper
import Text.PrettyPrint import Pretty
import GHC
import Outputable (SDoc, withPprStyleDoc)
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.Doc
docStyle :: Style docStyle :: Style
docStyle = style { ribbonsPerLine = 1.2 } docStyle = style { ribbonsPerLine = 1.2 }
gmRenderDoc :: Doc -> String render :: Doc -> String
gmRenderDoc = renderStyle docStyle 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 :: ChComponentName -> Doc
gmComponentNameDoc ChSetupHsName = text $ "Setup.hs" gmComponentNameDoc ChSetupHsName = text $ "Setup.hs"

View File

@ -28,6 +28,7 @@ import GHC.Paths (libdir)
import SysTools import SysTools
import DynFlags import DynFlags
import HscTypes import HscTypes
import Pretty
import Language.Haskell.GhcMod.DynFlags import Language.Haskell.GhcMod.DynFlags
import Language.Haskell.GhcMod.Monad.Types import Language.Haskell.GhcMod.Monad.Types
@ -393,7 +394,7 @@ resolveModule env srcDirs (Left fn') = do
case emn of case emn of
Left errs -> do Left errs -> do
gmLog GmWarning ("resolveModule " ++ show fn) $ 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 return Nothing -- TODO: should expose these errors otherwise
-- modules with preprocessor/parse errors are -- modules with preprocessor/parse errors are
-- going to be missing -- going to be missing

View File

@ -37,7 +37,7 @@ import qualified MonadUtils as GHC (MonadIO(..))
import GHC (ModuleName, moduleNameString, mkModuleName) import GHC (ModuleName, moduleNameString, mkModuleName)
import HscTypes (HscEnv) import HscTypes (HscEnv)
import GHC.Generics import GHC.Generics
import Text.PrettyPrint (Doc) import Pretty (Doc)
import Prelude import Prelude
import Language.Haskell.GhcMod.Caching.Types import Language.Haskell.GhcMod.Caching.Types

View File

@ -186,7 +186,6 @@ Library
, hlint < 1.10 && >= 1.9.27 , hlint < 1.10 && >= 1.9.27
, monad-journal < 0.8 && >= 0.4 , monad-journal < 0.8 && >= 0.4
, old-time < 1.2 , old-time < 1.2
, pretty < 1.2
, process < 1.5 , process < 1.5
, syb < 0.7 , syb < 0.7
, temporary < 1.3 , temporary < 1.3
@ -224,7 +223,6 @@ Executable ghc-mod
Build-Depends: base < 5 && >= 4.0 Build-Depends: base < 5 && >= 4.0
, directory < 1.3 , directory < 1.3
, filepath < 1.5 , filepath < 1.5
, pretty < 1.2
, process < 1.5 , process < 1.5
, split < 0.3 , split < 0.3
, mtl < 2.3 && >= 2.0 , mtl < 2.3 && >= 2.0
@ -306,7 +304,6 @@ Benchmark criterion
Build-Depends: base Build-Depends: base
, directory < 1.3 , directory < 1.3
, filepath < 1.5 , filepath < 1.5
, pretty < 1.2
, process < 1.5 , process < 1.5
, split < 0.3 , split < 0.3
, mtl < 2.3 && >= 2.0 , mtl < 2.3 && >= 2.0

View File

@ -18,7 +18,7 @@ import System.Directory (setCurrentDirectory, getAppUserDataDirectory,
removeDirectoryRecursive) removeDirectoryRecursive)
import System.IO import System.IO
import System.Exit import System.Exit
import Text.PrettyPrint hiding ((<>)) import Pretty hiding ((<>))
import GHCMod.Options import GHCMod.Options
import Prelude import Prelude