summaryrefslogtreecommitdiff
path: root/lib/CheckDir.hs
diff options
context:
space:
mode:
authorstuebinm2022-02-17 00:41:36 +0100
committerstuebinm2022-03-19 19:29:16 +0100
commit53fb449b008e9b6aed9877b9d33f4026e454e0f9 (patch)
tree1b95b0d7607426c66bd6173e0f1ff8c97a7b6541 /lib/CheckDir.hs
parent252a4a3e1553295ffafbfa5150306f0f31dda8cd (diff)
sprinkle some NFData everywhere
(also some evaluateNF, leading to slightly less memory usage)
Diffstat (limited to '')
-rw-r--r--lib/CheckDir.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index eeb94a8..1aeb5e3 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -10,6 +10,7 @@
module CheckDir (maximumLintLevel, recursiveCheckDir, DirResult(..), MissingAsset(..), MissingDep(..), resultIsFatal) where
import CheckMap (MapResult (..), loadAndLintMap)
+import Control.DeepSeq (NFData)
import Control.Monad (void)
import Control.Monad.Extra (mapMaybeM)
import Data.Aeson (ToJSON, (.=))
@@ -38,6 +39,7 @@ import Types (Dep (Local, LocalMap), Hint (Hint),
Level (..), hintLevel)
import Util (PrettyPrint (prettyprint), ellipsis)
+
-- based on the startling observation that Data.Map has lower complexity
-- for difference than Data.Set, but the same complexity for fromList
type Set a = Map a ()
@@ -54,19 +56,20 @@ data DirResult = DirResult
-- ^ all dependencies to things outside this repository
, dirresultMissingAssets :: [MissingAsset]
-- ^ entrypoints of maps which are referred to but missing
- , dirresultGraph :: Dot ()
- } deriving (Generic)
+ , dirresultGraph :: Text
+ } deriving (Generic, NFData)
data MissingDep = MissingDep
{ depFatal :: Maybe Bool
, entrypoint :: Text
, neededBy :: [FilePath]
- } deriving (Generic, ToJSON)
+ } deriving (Generic, ToJSON, NFData)
-- | Missing assets are the same thing as missing dependencies,
-- but should not be confused (and also serialise differently
-- to json)
newtype MissingAsset = MissingAsset MissingDep
+ deriving (Generic, NFData)
-- | given this config, should the result be considered to have failed?
resultIsFatal :: LintConfig' -> DirResult -> Bool
@@ -105,7 +108,6 @@ instance ToJSON DirResult where
. foldr aggregateSameResults []
. M.toList
$ dirresultMaps res)
- -- unused in the hub, temporarily removed to make the output smaller
, "exitGraph" .= showDot (dirresultGraph res)
]
, "severity" .= maximumLintLevel res
@@ -178,7 +180,9 @@ recursiveCheckDir config prefix root = do
, dirresultMissingAssets = mAssets
, dirresultMaps = maps'
, dirresultGraph =
- graphToDot
+ T.pack
+ . showDot
+ . graphToDot
. takeSubGraph 7 root
$ exitGraph
}