Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Item.Attachment.Data
|
||||
where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Geometry.Data
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.Sequence as Seq
|
||||
|
||||
data ItAttachment
|
||||
= AttachFuse {_atFuseTime :: Int}
|
||||
| AttachMode {_atMode :: Int}
|
||||
@@ -17,8 +18,10 @@ data ItAttachment
|
||||
| AttachFloat { _atFloat :: Float }
|
||||
| AttachBool { _atBool :: Bool }
|
||||
| NoItAttachment
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ItAttachment where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ItAttachment
|
||||
data Scope = NoScope
|
||||
| RemoteScope
|
||||
{_scopePos :: Point2 -- ^ a camera offset
|
||||
@@ -32,7 +35,9 @@ data Scope = NoScope
|
||||
,_scopeDefaultZoom :: Float
|
||||
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Scope where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Scope
|
||||
makeLenses ''ItAttachment
|
||||
makeLenses ''Scope
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
--{-# LANGUAGE TemplateHaskell #-}
|
||||
module Dodge.Item.Data where
|
||||
--import Control.Lens
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
data CurseStatus
|
||||
= Uncursed
|
||||
| UndroppableIdentified
|
||||
| UndroppableUnidentified
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON CurseStatus where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON CurseStatus
|
||||
|
||||
Reference in New Issue
Block a user