Add Store instances
This commit is contained in:
+14
-11
@@ -8,6 +8,8 @@
|
||||
|
||||
module Shape.Data where
|
||||
|
||||
import TH.Derive
|
||||
import Data.Store
|
||||
import Data.Binary
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
@@ -17,34 +19,30 @@ import Geometry.Data
|
||||
import LinearHelp ()
|
||||
import Streaming
|
||||
|
||||
type Shape' = Stream (Of ShapeObj) IO ()
|
||||
|
||||
type Shape = [ShapeObj]
|
||||
|
||||
{-# INLINE shVfromList #-}
|
||||
shVfromList = id
|
||||
|
||||
{-# INLINE shEfromList #-}
|
||||
shEfromList = id
|
||||
newtype ShapeType = TopPrism Int
|
||||
deriving newtype (Eq, Ord, Show, Read)
|
||||
deriving stock Generic
|
||||
deriving anyclass Flat
|
||||
|
||||
$($(derive [d| instance Deriving (Store ShapeType) |]))
|
||||
|
||||
data ShapeObj = ShapeObj
|
||||
{ _shType :: ShapeType
|
||||
, _shVs :: [ShapeV]
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read, Generic, Flat)
|
||||
instance Binary ShapeObj
|
||||
|
||||
instance ToJSON ShapeObj where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
|
||||
instance FromJSON ShapeObj
|
||||
|
||||
newtype ShapeType = TopPrism Int
|
||||
deriving newtype (Eq, Ord, Show, Read)
|
||||
deriving stock Generic
|
||||
deriving anyclass Flat
|
||||
|
||||
instance Binary ShapeType
|
||||
|
||||
instance ToJSON ShapeType where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
@@ -57,7 +55,6 @@ data ShapeV = ShapeV
|
||||
, _svCol :: Point4
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read, Generic, Flat)
|
||||
instance Binary ShapeV
|
||||
|
||||
instance ToJSON ShapeV where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
@@ -70,3 +67,9 @@ pairToSV = uncurry ShapeV
|
||||
|
||||
makeLenses ''ShapeV
|
||||
makeLenses ''ShapeObj
|
||||
type Shape' = Stream (Of ShapeObj) IO ()
|
||||
|
||||
type Shape = [ShapeObj]
|
||||
|
||||
$($(derive [d| instance Deriving (Store ShapeV ) |]))
|
||||
$($(derive [d| instance Deriving (Store ShapeObj ) |]))
|
||||
|
||||
Reference in New Issue
Block a user