diff --git a/.ghci b/.ghci index 18b1832d2..639be4528 100644 --- a/.ghci +++ b/.ghci @@ -3,7 +3,7 @@ -- See docs/💡ProTip!.md :undef pretty -:def pretty \ _ -> return (unlines [":set -interactive-print Semantic.Util.prettyShow"]) +:def pretty \ _ -> return ":set -interactive-print Semantic.Util.Pretty.prettyShow" -- See docs/💡ProTip!.md :undef no-pretty diff --git a/semantic.cabal b/semantic.cabal index ee2bc6d2e..89f73bbc5 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -197,6 +197,7 @@ library , Semantic.Telemetry.Stat , Semantic.Timeout , Semantic.Util + , Semantic.Util.Pretty , Semantic.Util.Rewriting , Semantic.Version -- Serialization diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index 9095013fe..ee116058c 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -24,8 +24,6 @@ import Data.List (uncons) import Data.Project hiding (readFile) import Data.Quieterm (quieterm) import Data.Sum (weaken) -import Language.Haskell.HsColour -import Language.Haskell.HsColour.Colourise import Parsing.Parser import Prologue hiding (weaken) import Semantic.Config @@ -35,7 +33,7 @@ import Semantic.Task import Semantic.Telemetry (LogQueue, StatQueue) import System.Exit (die) import System.FilePath.Posix (takeDirectory) -import Text.Show.Pretty (ppShow) + justEvaluating = runM @@ -145,8 +143,4 @@ mergeExcs = either (\ (SomeExc sum) -> Left (SomeExc (weaken sum))) (either (\ ( reassociate :: Either (SomeExc exc1) (Either (SomeExc exc2) (Either (SomeExc exc3) (Either (SomeExc exc4) (Either (SomeExc exc5) (Either (SomeExc exc6) (Either (SomeExc exc7) result)))))) -> Either (SomeExc (Sum '[exc7, exc6, exc5, exc4, exc3, exc2, exc1])) result reassociate = mergeExcs . mergeExcs . mergeExcs . mergeExcs . mergeExcs . mergeExcs . mergeExcs . Right - -prettyShow :: Show a => a -> IO () -prettyShow = putStrLn . hscolour TTY defaultColourPrefs False False "" False . ppShow - {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} diff --git a/src/Semantic/Util/Pretty.hs b/src/Semantic/Util/Pretty.hs new file mode 100644 index 000000000..7cc1bf77b --- /dev/null +++ b/src/Semantic/Util/Pretty.hs @@ -0,0 +1,8 @@ +module Semantic.Util.Pretty (prettyShow) where + +import Language.Haskell.HsColour +import Language.Haskell.HsColour.Colourise +import Text.Show.Pretty (ppShow) + +prettyShow :: Show a => a -> IO () +prettyShow = putStrLn . hscolour TTY defaultColourPrefs False False "" False . ppShow