summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2022-03-06 17:56:30 +0100
committerstuebinm2022-03-19 20:00:53 +0100
commitab16b947984b230b38fb38aaeceab9e206a18587 (patch)
tree78c6f5387c377e58ad7bd6d2833e607cd879380d
parent5d8cbd7c9975ca1fb95fb332f7e27357cc18e982 (diff)
make tiled even more strict
turns out aeson really REALLY likes to keep huge scientific numbers around, which is great if your data structures consist largely of arrays of (small) integers!
-rw-r--r--tiled/Data/Tiled.hs15
-rw-r--r--tiled/Data/Tiled/Abstract.hs7
2 files changed, 11 insertions, 11 deletions
diff --git a/tiled/Data/Tiled.hs b/tiled/Data/Tiled.hs
index 8a8036e..d3ccb26 100644
--- a/tiled/Data/Tiled.hs
+++ b/tiled/Data/Tiled.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
@@ -19,10 +20,10 @@ module Data.Tiled where
import Universum
-import Data.Aeson hiding (Object)
-import qualified Data.Aeson as A
-import Data.Aeson.Types (typeMismatch)
-import Data.Char (toLower)
+import Data.Aeson hiding (Object)
+import qualified Data.Aeson as A
+import Data.Aeson.Types (typeMismatch)
+import Data.Char (toLower)
-- | options for Aeson's generic encoding and parsing functions
@@ -381,6 +382,6 @@ instance ToJSON Tiledmap where
-- | Load a Tiled map from the given 'FilePath'.
loadTiledmap :: FilePath -> IO (Either String Tiledmap)
-loadTiledmap path = eitherDecodeFileStrict' path <&> \case
- Left err -> Left err
- Right tiledmap -> Right tiledmap
+loadTiledmap path = eitherDecodeFileStrict' path >>= \case
+ Left err -> pure $ Left err
+ Right !tiledmap -> evaluateNF tiledmap <&> Right
diff --git a/tiled/Data/Tiled/Abstract.hs b/tiled/Data/Tiled/Abstract.hs
index 5a5b7c0..574a0ae 100644
--- a/tiled/Data/Tiled/Abstract.hs
+++ b/tiled/Data/Tiled/Abstract.hs
@@ -4,11 +4,10 @@ module Data.Tiled.Abstract where
import Universum
-import qualified Data.Vector as V
-import Data.Tiled (GlobalId, Layer (..), Object (..), Property (..),
+import Data.Tiled (Layer (..), Object (..), Property (..),
PropertyValue (..), Tile (..), Tiledmap (..),
- Tileset (..), mkTiledId)
-import Util (showText)
+ Tileset (..), GlobalId)
+import qualified Data.Vector as V
class HasProperties a where
getProperties :: a -> [Property]