summaryrefslogtreecommitdiff
path: root/lib/CheckMap.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-20 23:03:56 +0200
committerstuebinm2021-09-20 23:06:56 +0200
commitc6be6366d6411d7b0b53fd8879537a33fefd5a88 (patch)
treeefceb26894fc455c85d7ccfd436a415d8ee69985 /lib/CheckMap.hs
parent42df3cf0eb0c5877ac3320994cadec07619bcd6b (diff)
use PrettyPrinter more
Diffstat (limited to '')
-rw-r--r--lib/CheckMap.hs24
1 files changed, 3 insertions, 21 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 3966988..c03197c 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -5,7 +5,6 @@
{-# LANGUAGE OverloadedStrings #-}
-- | Module that contains the high-level checking functions
-{-# OPTIONS_GHC -Wno-deferred-out-of-scope-variables #-}
module CheckMap (loadAndLintMap) where
import Data.Aeson (ToJSON)
@@ -22,7 +21,7 @@ import LintWriter (LintResult (..), LintWriter, askContext,
import Properties (checkLayerProperty, checkMap)
import Tiled2 (Layer (layerName, layerProperties),
Tiledmap (tiledmapLayers), loadTiledmap)
-import Types (Dep, Level (..), Lint (..), hint, lintLevel)
+import Types (Dep, Level (..), Lint (..), hint)
import Util (PrettyPrint (prettyprint), prettyprint)
@@ -81,26 +80,9 @@ instance PrettyPrint a => PrettyPrint (MapResult a) where
where
-- TODO: this can be simplified further
prettyLayer :: [Text]
- prettyLayer = mapMaybe
- (uncurry showResult)
+ prettyLayer = map
+ (prettyprint . snd)
(maybe [] toList . mapresultLayer $ mapResult)
prettyGeneral :: [Text]
prettyGeneral = flip (<>) "\n" . prettyprint <$> mapresultGeneral mapResult
-
--- TODO: possibly expand this to something more detailed?
-showContext :: Text -> Text
-showContext ctxt = " (in layer " <> ctxt <> ")\n"
-
--- | pretty-printer for a LintResult. Isn't an instance of PrettyPrint since
--- it needs to know about the result's context (yes, there could be
--- a wrapper type for that – but I wasn't really in the mood)
-showResult :: Text -> LintResult c -> Maybe Text
-showResult ctxt (LintResult (_, lints)) =
- Just $ T.concat (mapMaybe showHint lints)
- where
- -- TODO: make the "log level" configurable
- showHint hint = case lintLevel hint of
- Info -> Nothing
- _ -> Just $ prettyprint hint <> ctxtHint
- ctxtHint = showContext ctxt