Skip to content
Snippets Groups Projects
Commit 5bb4079f authored by stuebinm's avatar stuebinm
Browse files

remove dead code

(also fix some hlints)

This removes some code that was apparently dead and I never noticed. I
only noticed now since it wouldn't work with the newer versions of Aeson
anymore.
parent 62916338
Branches
No related tags found
No related merge requests found
...@@ -20,15 +20,12 @@ import qualified Data.Vector as V ...@@ -20,15 +20,12 @@ import qualified Data.Vector as V
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Data.Bifunctor (Bifunctor (second))
import Data.Functor ((<&>)) import Data.Functor ((<&>))
import LintWriter (filterLintLevel, invertLintResult, lintToDep, import LintWriter (filterLintLevel, invertLintResult, lintToDep,
resultToAdjusted, resultToDeps, resultToAdjusted, resultToDeps,
resultToLints, resultToOffers, runLintWriter) resultToLints, resultToOffers, runLintWriter)
import Properties (checkLayer, checkMap, checkTileset) import Properties (checkLayer, checkMap, checkTileset)
import Tiled2 (HasName (getName), import Tiled2 (HasName (getName), Layer, LoadResult (..),
HasProperties (getProperties), Layer,
LoadResult (..),
Tiledmap (tiledmapLayers, tiledmapTilesets), Tiledmap (tiledmapLayers, tiledmapTilesets),
Tileset, loadTiledmap) Tileset, loadTiledmap)
import Types (Dep, Hint (hintLevel, hintMsg), Level (..), import Types (Dep, Hint (hintLevel, hintMsg), Level (..),
...@@ -90,7 +87,7 @@ runLinter tiledmap depth = MapResult ...@@ -90,7 +87,7 @@ runLinter tiledmap depth = MapResult
{ mapresultLayer = invertThing layer { mapresultLayer = invertThing layer
, mapresultTileset = invertThing tileset , mapresultTileset = invertThing tileset
, mapresultGeneral = resultToLints generalResult , mapresultGeneral = resultToLints generalResult
, mapresultDepends = mapMaybe lintToDep generalLints , mapresultDepends = mapMaybe lintToDep (resultToLints generalResult)
<> concatMap resultToDeps layer <> concatMap resultToDeps layer
<> concatMap resultToDeps tileset <> concatMap resultToDeps tileset
, mapresultProvides = concatMap resultToOffers layer , mapresultProvides = concatMap resultToOffers layer
......
...@@ -18,7 +18,7 @@ import Control.Exception (try) ...@@ -18,7 +18,7 @@ import Control.Exception (try)
import Control.Exception.Base (SomeException) import Control.Exception.Base (SomeException)
import Data.Aeson hiding (Object) import Data.Aeson hiding (Object)
import qualified Data.Aeson as A import qualified Data.Aeson as A
import Data.Aeson.Types (Parser, typeMismatch) import Data.Aeson.Types (typeMismatch)
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LB import qualified Data.ByteString.Lazy as LB
import Data.Char (toLower) import Data.Char (toLower)
...@@ -28,7 +28,6 @@ import Data.String (IsString (fromString)) ...@@ -28,7 +28,6 @@ import Data.String (IsString (fromString))
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import Data.Vector (Vector) import Data.Vector (Vector)
import GHC.Exts (IsString, fromList, toList)
import GHC.Generics (Generic) import GHC.Generics (Generic)
...@@ -55,41 +54,15 @@ newtype LocalId = LocalId { unLocalId :: Int } ...@@ -55,41 +54,15 @@ newtype LocalId = LocalId { unLocalId :: Int }
-- | TODO: type-check colours? -- | TODO: type-check colours?
type Color = Text type Color = Text
data XYPair a = XYPair a a -- | A custom tiled property, which just has a name and a value.
data Property = Property Text PropertyValue
instance FromJSON a => FromJSON (XYPair a) where deriving (Eq, Generic, Show)
parseJSON (A.Object o) =
XYPair <$> o .: "x"
<*> o .: "y"
parseJSON invalid = typeMismatch "Object" invalid
instance ToJSON a => ToJSON (XYPair a) where
toJSON (XYPair x y) =
object [ "x" .= x
, "y" .= y
]
fromXYPair :: XYPair a -> (a, a)
fromXYPair (XYPair x y) = (x, y)
toXYPair :: (a, a) -> XYPair a
toXYPair (x, y) = XYPair x y
omitNulls :: Value -> Value
omitNulls (A.Object hs) = A.Object
. fromList
. filter ((/= Null) . snd)
$ toList hs
omitNulls x = x
parseDefault :: FromJSON a => A.Object -> Text -> a -> Parser a
parseDefault o s d = fromMaybe d <$> o .:? s
-- | The value of a custom tiled property.
-- It is strongly typed via a tag in the json representation,
-- and needs a custom ToJSON and FromJSON instance because of that.
data PropertyValue = StrProp Text | BoolProp Bool data PropertyValue = StrProp Text | BoolProp Bool
deriving (Eq, Generic, Show) deriving (Eq, Generic, Show)
data Property = Property Text PropertyValue
deriving (Eq, Generic, Show)
instance IsString PropertyValue where instance IsString PropertyValue where
fromString s = StrProp (T.pack s) fromString s = StrProp (T.pack s)
...@@ -375,5 +348,5 @@ loadTiledmap path = do ...@@ -375,5 +348,5 @@ loadTiledmap path = do
pure $ case res of pure $ case res of
Right file -> case eitherDecode . LB.fromStrict $ file of Right file -> case eitherDecode . LB.fromStrict $ file of
Left err -> DecodeErr err Left err -> DecodeErr err
Right map -> Loaded map Right tiledmap -> Loaded tiledmap
Left (err :: SomeException) -> IOErr $ show err Left (err :: SomeException) -> IOErr $ show err
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment