From 4caded904c54d1cd85bf54239517e93650a404f5 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 11 Oct 2022 13:39:16 +0200 Subject: use template haskell aeson, not generics this has been bothering me for MONTHS, and it compiles faster now. also fixed some warnings --- tiled/Data/Tiled/Abstract.hs | 6 +++--- tiled/Data/Tiled/TH.hs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tiled/Data/Tiled/TH.hs (limited to 'tiled/Data/Tiled') diff --git a/tiled/Data/Tiled/Abstract.hs b/tiled/Data/Tiled/Abstract.hs index 89c40b4..29e9022 100644 --- a/tiled/Data/Tiled/Abstract.hs +++ b/tiled/Data/Tiled/Abstract.hs @@ -4,9 +4,9 @@ module Data.Tiled.Abstract where import Universum -import Data.Tiled (GlobalId, Layer (..), Object (..), Property (..), +import Data.Tiled (GlobalId (..), Layer (..), Object (..), Property (..), PropertyValue (..), Tile (..), Tiledmap (..), - Tileset (..), mkTiledId) + Tileset (..)) import qualified Data.Vector as V class HasProperties a where @@ -81,4 +81,4 @@ instance IsProperty Text where layerIsEmpty :: HasData a => a -> Bool layerIsEmpty layer = case getData layer of Nothing -> True - Just d -> all ((==) $ mkTiledId 0) d + Just d -> all ((==) $ GlobalId 0) d diff --git a/tiled/Data/Tiled/TH.hs b/tiled/Data/Tiled/TH.hs new file mode 100644 index 0000000..e0ad0e8 --- /dev/null +++ b/tiled/Data/Tiled/TH.hs @@ -0,0 +1,15 @@ +module Data.Tiled.TH where + +import Universum + +import qualified Data.Aeson.TH as TH +import Data.Char (toLower) + +aesonOptions :: Int -> TH.Options +aesonOptions l = TH.defaultOptions + { TH.omitNothingFields = True + , TH.rejectUnknownFields = True + -- can't be bothered to do a nicer prefix strip + , TH.fieldLabelModifier = drop l . map toLower + , TH.sumEncoding = TH.UntaggedValue + } -- cgit v1.2.3