summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/CheckMap.hs15
-rw-r--r--lib/LintWriter.hs7
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 51b4496..467fa26 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -30,8 +30,7 @@ import Properties (checkLayer, checkMap, checkTileset)
import Tiled (Layer (layerLayers, layerName),
LoadResult (..),
Tiledmap (tiledmapLayers, tiledmapTilesets),
- Tileset, loadTiledmap)
-import TiledAbstract (HasName (..))
+ loadTiledmap)
import Types (Dep, Hint (Hint, hintLevel, hintMsg),
Level (..), lintsToHints)
import Util (PrettyPrint (prettyprint), prettyprint)
@@ -40,9 +39,9 @@ import Util (PrettyPrint (prettyprint), prettyprint)
-- | What this linter produces: lints for a single map
data MapResult = MapResult
- { mapresultLayer :: Map Hint [Layer]
+ { mapresultLayer :: Map Hint [Text]
-- ^ lints that occurred in one or more layers
- , mapresultTileset :: Map Hint [Tileset]
+ , mapresultTileset :: Map Hint [Text]
-- ^ lints that occurred in one or more tilesets
, mapresultDepends :: [Dep]
-- ^ (external and local) dependencies of this map
@@ -58,8 +57,8 @@ data MapResult = MapResult
instance ToJSON MapResult where
toJSON res = A.object
- [ "layer" .= CollectedLints (fmap getName <$> mapresultLayer res)
- , "tileset" .= CollectedLints (fmap getName <$> mapresultTileset res)
+ [ "layer" .= CollectedLints (mapresultLayer res)
+ , "tileset" .= CollectedLints (mapresultTileset res)
, "general" .= mapresultGeneral res
, "offers" .= mapresultProvides res
]
@@ -178,7 +177,7 @@ instance PrettyPrint (Level, MapResult) where
-- | pretty-prints a collection of Hints, printing each
-- Hint only once, then a list of its occurences line-wrapped
-- to fit onto a decent-sized terminal
- prettyLints :: HasName a => (MapResult -> Map Hint [a]) -> [Text]
+ prettyLints :: (MapResult -> Map Hint [Text]) -> [Text]
prettyLints getter = fmap
(\(h, cs) -> prettyprint h
<> "\n (in "
@@ -188,7 +187,7 @@ instance PrettyPrint (Level, MapResult) where
_ | l < 70 -> (l+2+T.length c, a <> ", " <> c)
_ -> (6+T.length c, a <> ",\n " <> c)
)
- (0, "") (fmap getName cs))
+ (0, "") cs)
<> ")\n")
(toList . getter $ mapResult)
diff --git a/lib/LintWriter.hs b/lib/LintWriter.hs
index eb7d138..2b891c3 100644
--- a/lib/LintWriter.hs
+++ b/lib/LintWriter.hs
@@ -52,8 +52,9 @@ import Control.Monad.Writer.Lazy (lift)
import Data.Bifunctor (Bifunctor (second))
import Data.Map (Map, fromListWith)
import Data.Maybe (mapMaybe)
+import qualified Data.Set as S
import LintConfig (LintConfig')
-import TiledAbstract (HasName)
+import TiledAbstract (HasName (getName))
import Types (Dep, Hint, Level (..), Lint (..),
hint, lintsToHints)
@@ -106,9 +107,9 @@ zoom embed extract operation = do
-- | "invert" a linter's result, grouping lints by their messages
-invertLintResult :: HasName ctxt => LintResult ctxt -> Map Hint [ctxt]
+invertLintResult :: HasName ctxt => LintResult ctxt -> Map Hint [Text]
invertLintResult (LinterState (lints, ctxt)) =
- fromListWith (<>) $ (, [ctxt]) <$> lintsToHints lints
+ fmap (S.toList . S.fromList . fmap getName) . fromListWith (<>) $ (, [ctxt]) <$> lintsToHints lints
resultToDeps :: LintResult a -> [Dep]
resultToDeps (LinterState (lints,_)) = mapMaybe lintToDep lints