Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
{- |
|
||||
WARNING: orphan instances concerning Aeson classes and Linear.Vx datatypes have been introduced.
|
||||
The warnings have been disabled.
|
||||
-}
|
||||
module Geometry.Data
|
||||
( module Geometry.Data
|
||||
, V2 (..)
|
||||
@@ -5,13 +11,25 @@ module Geometry.Data
|
||||
, V4 (..)
|
||||
)
|
||||
where
|
||||
import Data.Aeson
|
||||
import Linear.V2
|
||||
import Linear.V3
|
||||
import Linear.V4
|
||||
type Int2 = V2 Int
|
||||
type Point2 = V2 Float
|
||||
instance ToJSON a => ToJSON (V2 a) where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON a => FromJSON (V2 a)
|
||||
instance ToJSON a => ToJSONKey (V2 a)
|
||||
instance FromJSON a => FromJSONKey (V2 a)
|
||||
type Point3 = V3 Float
|
||||
instance ToJSON a => ToJSON (V3 a) where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON a => FromJSON (V3 a)
|
||||
type Point4 = V4 Float
|
||||
instance ToJSON a => ToJSON (V4 a) where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON a => FromJSON (V4 a)
|
||||
|
||||
type DPoint2 = (Point2,Float)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user