Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
module Geometry.ConvexPoly
|
||||
@@ -10,6 +11,8 @@ module Geometry.ConvexPoly
|
||||
, convexPolysOverlap
|
||||
, pointInPolyPoints
|
||||
) where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Geometry.Data
|
||||
import Geometry.Vector
|
||||
import Geometry.LHS
|
||||
@@ -23,7 +26,10 @@ data ConvexPoly = ConvexPoly
|
||||
, _cpCen :: Point2
|
||||
, _cpRad :: Float
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ConvexPoly where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ConvexPoly
|
||||
pointsToPoly :: [Point2] -> ConvexPoly
|
||||
pointsToPoly xs = ConvexPoly
|
||||
{ _cpPoints = xs
|
||||
|
||||
Reference in New Issue
Block a user