Add generic derivations and To/FromJSON instances
This commit is contained in:
+15
-3
@@ -1,6 +1,9 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Block where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Shape.Data
|
||||
import Color
|
||||
import Dodge.Data.Material
|
||||
@@ -21,13 +24,22 @@ data Block = Block
|
||||
, _blDraw :: BlockDraw --Block -> SPic
|
||||
, _blObstructs :: [(Int,Int,PathEdge)]
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Block where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Block
|
||||
data BlockDraw = BlockDrawMempty
|
||||
| BlockDrawBlSh BlSh
|
||||
| BlockDraws [BlockDraw]
|
||||
| BlockDrawColHeightPoss Color Float [Point2]
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON BlockDraw where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON BlockDraw
|
||||
data BlSh = BlShMempty
|
||||
| BlShConst Shape
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON BlSh where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON BlSh
|
||||
makeLenses ''Block
|
||||
|
||||
Reference in New Issue
Block a user