From 52b73711fc21e121267318677840a54fbe174b10 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 14 Nov 2021 03:09:50 +0100 Subject: Functional jitsiRoomAdminTag adjustment also yet another typeclass™, because why not? --- lib/CheckMap.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 1b42854..962da22 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -21,6 +21,7 @@ import qualified Data.Vector as V import GHC.Generics (Generic) +import LintConfig (LintConfig') import LintWriter (filterLintLevel, invertLintResult, lintToDep, resultToAdjusted, resultToDeps, resultToLints, resultToOffers, runLintWriter) @@ -71,19 +72,19 @@ instance ToJSON CollectedLints where -- | this module's raison d'être -- Lints the map at `path`, and limits local links to at most `depth` -- layers upwards in the file hierarchy -loadAndLintMap :: FilePath -> Int -> IO (Maybe MapResult) -loadAndLintMap path depth = loadTiledmap path <&> (\case +loadAndLintMap :: LintConfig' -> FilePath -> Int -> IO (Maybe MapResult) +loadAndLintMap config path depth = loadTiledmap path <&> (\case DecodeErr err -> Just (MapResult mempty mempty mempty mempty Nothing [ hint Fatal . T.pack $ path <> ": Fatal: " <> err ]) IOErr _ -> Nothing Loaded waMap -> - Just (runLinter waMap depth)) + Just (runLinter config waMap depth)) -- | lint a loaded map -runLinter :: Tiledmap -> Int -> MapResult -runLinter tiledmap depth = MapResult +runLinter :: LintConfig' -> Tiledmap -> Int -> MapResult +runLinter config tiledmap depth = MapResult { mapresultLayer = invertThing layer , mapresultTileset = invertThing tileset , mapresultGeneral = resultToLints generalResult @@ -96,10 +97,10 @@ runLinter tiledmap depth = MapResult where layer = checkThing tiledmapLayers checkLayer tileset = checkThing tiledmapTilesets checkTileset - generalResult = runLintWriter tiledmap depth checkMap + generalResult = runLintWriter config tiledmap depth checkMap checkThing getter checker = V.toList . V.map runCheck $ getter tiledmap - where runCheck thing = runLintWriter thing depth checker + where runCheck thing = runLintWriter config thing depth checker -- | "inverts" a LintResult, i.e. groups it by lints instead of -- layers / maps -- cgit v1.2.3