From d2983b867a106ee0581d8dc1d8f413178cdd4027 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 28 Oct 2021 13:28:55 +0200 Subject: make aeson instances agree with themselves This cleans up all the old rubble that came from the Tiled package I originally took from hackage. It now uses generics instead of implementing all the ToJSON and FromJSON instances by hand, and (deserialize . serialise) will now actually return a (semantically) equivalent json. It'll now also reject keys that it doesn't know, which required adding some in several places which the tiled package didn't know about (or which were introduced after it was originally written, dunno). Several more Maybes are required now, to represent the difference between e.g. empty lists and on set value, which does make the code slightly weirder in other places … --- lib/CheckMap.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 036f4e8..d7d45c0 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -23,7 +23,8 @@ import LintWriter (LintResult (..), LintWriter, askContext, filterLintLevel, lintToDep, resultToDeps, resultToLints, resultToOffers, runLintWriter) import Properties (checkLayerProperty, checkMap, checkTileset) -import Tiled2 (Layer (layerName, layerProperties), +import Tiled2 (HasProperties (getProperties), + Layer (layerName, layerProperties), LoadResult (..), Tiledmap (tiledmapLayers, tiledmapTilesets), Tileset (tilesetName), loadTiledmap) @@ -96,7 +97,7 @@ runLinter tiledmap depth = MapResult checkLayer :: LintWriter Layer checkLayer = do layer <- askContext - mapM_ checkLayerProperty (layerProperties layer) + mapM_ checkLayerProperty (getProperties layer) -- human-readable lint output, e.g. for consoles instance PrettyPrint (Level, MapResult) where -- cgit v1.2.3