Add Store instances

This commit is contained in:
2022-08-21 12:21:05 +01:00
parent 1ce7d4a72d
commit dd62e30026
92 changed files with 465 additions and 255 deletions
+14 -11
View File
@@ -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 ) |]))