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
No related branches found
No related tags found
No related merge requests found
......@@ -20,15 +20,12 @@ import qualified Data.Vector as V
import GHC.Generics (Generic)
import Data.Bifunctor (Bifunctor (second))
import Data.Functor ((<&>))
import LintWriter (filterLintLevel, invertLintResult, lintToDep,
resultToAdjusted, resultToDeps,
resultToLints, resultToOffers, runLintWriter)
import Properties (checkLayer, checkMap, checkTileset)
import Tiled2 (HasName (getName),
HasProperties (getProperties), Layer,
LoadResult (..),
import Tiled2 (HasName (getName), Layer, LoadResult (..),
Tiledmap (tiledmapLayers, tiledmapTilesets),
Tileset, loadTiledmap)
import Types (Dep, Hint (hintLevel, hintMsg), Level (..),
......@@ -90,7 +87,7 @@ runLinter tiledmap depth = MapResult
{ mapresultLayer = invertThing layer
, mapresultTileset = invertThing tileset
, mapresultGeneral = resultToLints generalResult
, mapresultDepends = mapMaybe lintToDep generalLints
, mapresultDepends = mapMaybe lintToDep (resultToLints generalResult)
<> concatMap resultToDeps layer
<> concatMap resultToDeps tileset
, mapresultProvides = concatMap resultToOffers layer
......
......@@ -18,7 +18,7 @@ import Control.Exception (try)
import Control.Exception.Base (SomeException)
import Data.Aeson hiding (Object)
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.Lazy as LB
import Data.Char (toLower)
......@@ -28,7 +28,6 @@ import Data.String (IsString (fromString))
import Data.Text (Text)
import qualified Data.Text as T
import Data.Vector (Vector)
import GHC.Exts (IsString, fromList, toList)
import GHC.Generics (Generic)
......@@ -55,41 +54,15 @@ newtype LocalId = LocalId { unLocalId :: Int }
-- | TODO: type-check colours?
type Color = Text
data XYPair a = XYPair a a
instance FromJSON a => FromJSON (XYPair a) where
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
-- | A custom tiled property, which just has a name and a value.
data Property = Property Text PropertyValue
deriving (Eq, Generic, Show)
-- | 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
deriving (Eq, Generic, Show)
data Property = Property Text PropertyValue
deriving (Eq, Generic, Show)
instance IsString PropertyValue where
fromString s = StrProp (T.pack s)
......@@ -375,5 +348,5 @@ loadTiledmap path = do
pure $ case res of
Right file -> case eitherDecode . LB.fromStrict $ file of
Left err -> DecodeErr err
Right map -> Loaded map
Right tiledmap -> Loaded tiledmap
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