Add generic derivations and To/FromJSON instances

This commit is contained in:
2022-07-25 22:49:18 +01:00
parent f5604ef429
commit b8e8413daa
99 changed files with 1406 additions and 517 deletions
+11 -2
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Item
@@ -7,6 +8,8 @@ module Dodge.Data.Item
, module Dodge.Data.Item.Params
, module Dodge.Data.Item.Use
) where
import GHC.Generics
import Data.Aeson
import Control.Lens
import Dodge.Data.Item.Misc
import Dodge.Data.Item.Tweak
@@ -40,13 +43,19 @@ data Item = Item
, _itValue :: ItemValue
, _itParams :: ItemParams
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Item where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Item
data ItemTweaks
= NoTweaks
| Tweakable
{ _tweakParams :: IM.IntMap TweakParam
, _tweakSel :: Int
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemTweaks where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemTweaks
makeLenses ''Item
makeLenses ''ItemTweaks