summaryrefslogtreecommitdiff
path: root/lib/CheckDir.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-23 04:34:02 +0200
committerstuebinm2021-09-23 04:34:58 +0200
commit68af04a4da6ba4ec61d1469337ce53457526d861 (patch)
treecb882c03ebe2c88450f16702cd4467a73e2c22a3 /lib/CheckDir.hs
parent04b98e4d62fe33b4fa357f2b52ffcc4f2c413302 (diff)
prettier pretty printing and stuff
also, configurable log level, which only required relaxing the type system once!
Diffstat (limited to 'lib/CheckDir.hs')
-rw-r--r--lib/CheckDir.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index f551e6a..ab231b9 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
@@ -21,7 +22,8 @@ import Paths (normalise)
import System.FilePath (splitPath, (</>))
import qualified System.FilePath as FP
import System.FilePath.Posix (takeDirectory)
-import Types (Dep (LocalMap))
+import Types (Dep (LocalMap), Hint (hintLevel),
+ Level (Info))
import Util (PrettyPrint (prettyprint))
-- based on the startling observation that Data.Map has lower complexity
@@ -38,10 +40,13 @@ data DirResult = DirResult
, dirresultDeps :: [Text]
} deriving (Generic, ToJSON)
-
-instance PrettyPrint DirResult where
- prettyprint res = T.concat
- (map (\(p,lints) -> "\nin " <> T.pack p <> ":\n" <> prettyprint lints) $ M.toList $ dirresultMaps res)
+instance PrettyPrint (Level, DirResult) where
+ prettyprint (level, res) = T.concat
+ (map prettyLint $ M.toList $ dirresultMaps res)
+ where
+ prettyLint :: (FilePath, MapResult) -> Text
+ prettyLint (p, lint) =
+ "\nin " <> T.pack p <> ":\n" <> prettyprint (level, lint)
instance Semigroup DirResult where
a <> b = DirResult
@@ -70,7 +75,6 @@ recursiveCheckDir prefix root = recursiveCheckDir' prefix [root] mempty mempty
-- like this seemed convenient at the time
recursiveCheckDir' :: FilePath -> [FilePath] -> Set FilePath -> DirResult -> IO DirResult
recursiveCheckDir' prefix paths done acc = do
- putStrLn $ "linting " <> show paths
-- lint all maps in paths
lints <-