{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuantifiedConstraints #-}
module HGeometry.Polygon.Simple.Type
( SimplePolygon
, SimplePolygonF(..)
, toCyclic
, VertexContainer
, _SimplePolygonF
) where
import Control.DeepSeq (NFData)
import Control.Lens
import Data.Aeson
import qualified Data.Aeson as Aeson
import qualified Data.Foldable as F
import Data.Functor.Apply (WrappedApplicative(..))
import Data.Functor.Classes
import Data.Semigroup.Foldable
import Data.Vector.NonEmpty.Internal (NonEmptyVector(..))
import GHC.Generics
import HGeometry.Box
import HGeometry.Cyclic
import HGeometry.Foldable.Util
import qualified HGeometry.Foldable.Util as F
import HGeometry.Point
import HGeometry.Properties
import HGeometry.Vector.NonEmpty.Util ()
import Hiraffe.Graph.Class
newtype SimplePolygonF f point = MkSimplePolygon (f point)
deriving stock ((forall x.
SimplePolygonF f point -> Rep (SimplePolygonF f point) x)
-> (forall x.
Rep (SimplePolygonF f point) x -> SimplePolygonF f point)
-> Generic (SimplePolygonF f point)
forall x. Rep (SimplePolygonF f point) x -> SimplePolygonF f point
forall x. SimplePolygonF f point -> Rep (SimplePolygonF f point) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (point :: k) x.
Rep (SimplePolygonF f point) x -> SimplePolygonF f point
forall k (f :: k -> *) (point :: k) x.
SimplePolygonF f point -> Rep (SimplePolygonF f point) x
$cfrom :: forall k (f :: k -> *) (point :: k) x.
SimplePolygonF f point -> Rep (SimplePolygonF f point) x
from :: forall x. SimplePolygonF f point -> Rep (SimplePolygonF f point) x
$cto :: forall k (f :: k -> *) (point :: k) x.
Rep (SimplePolygonF f point) x -> SimplePolygonF f point
to :: forall x. Rep (SimplePolygonF f point) x -> SimplePolygonF f point
Generic)
deriving newtype (SimplePolygonF f point -> ()
(SimplePolygonF f point -> ()) -> NFData (SimplePolygonF f point)
forall a. (a -> ()) -> NFData a
forall k (f :: k -> *) (point :: k).
NFData (f point) =>
SimplePolygonF f point -> ()
$crnf :: forall k (f :: k -> *) (point :: k).
NFData (f point) =>
SimplePolygonF f point -> ()
rnf :: SimplePolygonF f point -> ()
NFData,(forall a b. (a -> b) -> SimplePolygonF f a -> SimplePolygonF f b)
-> (forall a b. a -> SimplePolygonF f b -> SimplePolygonF f a)
-> Functor (SimplePolygonF f)
forall a b. a -> SimplePolygonF f b -> SimplePolygonF f a
forall a b. (a -> b) -> SimplePolygonF f a -> SimplePolygonF f b
forall (f :: * -> *) a b.
Functor f =>
a -> SimplePolygonF f b -> SimplePolygonF f a
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> SimplePolygonF f a -> SimplePolygonF f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> SimplePolygonF f a -> SimplePolygonF f b
fmap :: forall a b. (a -> b) -> SimplePolygonF f a -> SimplePolygonF f b
$c<$ :: forall (f :: * -> *) a b.
Functor f =>
a -> SimplePolygonF f b -> SimplePolygonF f a
<$ :: forall a b. a -> SimplePolygonF f b -> SimplePolygonF f a
Functor,(forall m. Monoid m => SimplePolygonF f m -> m)
-> (forall m a. Monoid m => (a -> m) -> SimplePolygonF f a -> m)
-> (forall m a. Monoid m => (a -> m) -> SimplePolygonF f a -> m)
-> (forall a b. (a -> b -> b) -> b -> SimplePolygonF f a -> b)
-> (forall a b. (a -> b -> b) -> b -> SimplePolygonF f a -> b)
-> (forall b a. (b -> a -> b) -> b -> SimplePolygonF f a -> b)
-> (forall b a. (b -> a -> b) -> b -> SimplePolygonF f a -> b)
-> (forall a. (a -> a -> a) -> SimplePolygonF f a -> a)
-> (forall a. (a -> a -> a) -> SimplePolygonF f a -> a)
-> (forall a. SimplePolygonF f a -> [a])
-> (forall a. SimplePolygonF f a -> Bool)
-> (forall a. SimplePolygonF f a -> Int)
-> (forall a. Eq a => a -> SimplePolygonF f a -> Bool)
-> (forall a. Ord a => SimplePolygonF f a -> a)
-> (forall a. Ord a => SimplePolygonF f a -> a)
-> (forall a. Num a => SimplePolygonF f a -> a)
-> (forall a. Num a => SimplePolygonF f a -> a)
-> Foldable (SimplePolygonF f)
forall a. Eq a => a -> SimplePolygonF f a -> Bool
forall a. Num a => SimplePolygonF f a -> a
forall a. Ord a => SimplePolygonF f a -> a
forall m. Monoid m => SimplePolygonF f m -> m
forall a. SimplePolygonF f a -> Bool
forall a. SimplePolygonF f a -> Int
forall a. SimplePolygonF f a -> [a]
forall a. (a -> a -> a) -> SimplePolygonF f a -> a
forall m a. Monoid m => (a -> m) -> SimplePolygonF f a -> m
forall b a. (b -> a -> b) -> b -> SimplePolygonF f a -> b
forall a b. (a -> b -> b) -> b -> SimplePolygonF f a -> b
forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> SimplePolygonF f a -> Bool
forall (f :: * -> *) a.
(Foldable f, Num a) =>
SimplePolygonF f a -> a
forall (f :: * -> *) a.
(Foldable f, Ord a) =>
SimplePolygonF f a -> a
forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
SimplePolygonF f m -> m
forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> Bool
forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> Int
forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> [a]
forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> SimplePolygonF f a -> a
forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> SimplePolygonF f a -> m
forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> SimplePolygonF f a -> b
forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> SimplePolygonF f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
SimplePolygonF f m -> m
fold :: forall m. Monoid m => SimplePolygonF f m -> m
$cfoldMap :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> SimplePolygonF f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> SimplePolygonF f a -> m
$cfoldMap' :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> SimplePolygonF f a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> SimplePolygonF f a -> m
$cfoldr :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> SimplePolygonF f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> SimplePolygonF f a -> b
$cfoldr' :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> SimplePolygonF f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> SimplePolygonF f a -> b
$cfoldl :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> SimplePolygonF f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> SimplePolygonF f a -> b
$cfoldl' :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> SimplePolygonF f a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> SimplePolygonF f a -> b
$cfoldr1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> SimplePolygonF f a -> a
foldr1 :: forall a. (a -> a -> a) -> SimplePolygonF f a -> a
$cfoldl1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> SimplePolygonF f a -> a
foldl1 :: forall a. (a -> a -> a) -> SimplePolygonF f a -> a
$ctoList :: forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> [a]
toList :: forall a. SimplePolygonF f a -> [a]
$cnull :: forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> Bool
null :: forall a. SimplePolygonF f a -> Bool
$clength :: forall (f :: * -> *) a. Foldable f => SimplePolygonF f a -> Int
length :: forall a. SimplePolygonF f a -> Int
$celem :: forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> SimplePolygonF f a -> Bool
elem :: forall a. Eq a => a -> SimplePolygonF f a -> Bool
$cmaximum :: forall (f :: * -> *) a.
(Foldable f, Ord a) =>
SimplePolygonF f a -> a
maximum :: forall a. Ord a => SimplePolygonF f a -> a
$cminimum :: forall (f :: * -> *) a.
(Foldable f, Ord a) =>
SimplePolygonF f a -> a
minimum :: forall a. Ord a => SimplePolygonF f a -> a
$csum :: forall (f :: * -> *) a.
(Foldable f, Num a) =>
SimplePolygonF f a -> a
sum :: forall a. Num a => SimplePolygonF f a -> a
$cproduct :: forall (f :: * -> *) a.
(Foldable f, Num a) =>
SimplePolygonF f a -> a
product :: forall a. Num a => SimplePolygonF f a -> a
Foldable,Foldable (SimplePolygonF f)
Foldable (SimplePolygonF f) =>
(forall m. Semigroup m => SimplePolygonF f m -> m)
-> (forall m a. Semigroup m => (a -> m) -> SimplePolygonF f a -> m)
-> (forall m a. Semigroup m => (a -> m) -> SimplePolygonF f a -> m)
-> (forall a. SimplePolygonF f a -> NonEmpty a)
-> (forall a. Ord a => SimplePolygonF f a -> a)
-> (forall a. Ord a => SimplePolygonF f a -> a)
-> (forall a. SimplePolygonF f a -> a)
-> (forall a. SimplePolygonF f a -> a)
-> (forall a b.
(a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b)
-> (forall a b.
(a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b)
-> (forall a b.
(a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b)
-> (forall a b.
(a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b)
-> Foldable1 (SimplePolygonF f)
forall a. Ord a => SimplePolygonF f a -> a
forall m. Semigroup m => SimplePolygonF f m -> m
forall a. SimplePolygonF f a -> a
forall a. SimplePolygonF f a -> NonEmpty a
forall m a. Semigroup m => (a -> m) -> SimplePolygonF f a -> m
forall a b. (a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
forall a b. (a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
forall (t :: * -> *).
Foldable t =>
(forall m. Semigroup m => t m -> m)
-> (forall m a. Semigroup m => (a -> m) -> t a -> m)
-> (forall m a. Semigroup m => (a -> m) -> t a -> m)
-> (forall a. t a -> NonEmpty a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. t a -> a)
-> (forall a. t a -> a)
-> (forall a b. (a -> b) -> (a -> b -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (a -> b -> b) -> t a -> b)
-> Foldable1 t
forall (f :: * -> *). Foldable1 f => Foldable (SimplePolygonF f)
forall (f :: * -> *) a.
(Foldable1 f, Ord a) =>
SimplePolygonF f a -> a
forall (f :: * -> *) m.
(Foldable1 f, Semigroup m) =>
SimplePolygonF f m -> m
forall (f :: * -> *) a. Foldable1 f => SimplePolygonF f a -> a
forall (f :: * -> *) a.
Foldable1 f =>
SimplePolygonF f a -> NonEmpty a
forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> SimplePolygonF f a -> m
forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
$cfold1 :: forall (f :: * -> *) m.
(Foldable1 f, Semigroup m) =>
SimplePolygonF f m -> m
fold1 :: forall m. Semigroup m => SimplePolygonF f m -> m
$cfoldMap1 :: forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> SimplePolygonF f a -> m
foldMap1 :: forall m a. Semigroup m => (a -> m) -> SimplePolygonF f a -> m
$cfoldMap1' :: forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> SimplePolygonF f a -> m
foldMap1' :: forall m a. Semigroup m => (a -> m) -> SimplePolygonF f a -> m
$ctoNonEmpty :: forall (f :: * -> *) a.
Foldable1 f =>
SimplePolygonF f a -> NonEmpty a
toNonEmpty :: forall a. SimplePolygonF f a -> NonEmpty a
$cmaximum :: forall (f :: * -> *) a.
(Foldable1 f, Ord a) =>
SimplePolygonF f a -> a
maximum :: forall a. Ord a => SimplePolygonF f a -> a
$cminimum :: forall (f :: * -> *) a.
(Foldable1 f, Ord a) =>
SimplePolygonF f a -> a
minimum :: forall a. Ord a => SimplePolygonF f a -> a
$chead :: forall (f :: * -> *) a. Foldable1 f => SimplePolygonF f a -> a
head :: forall a. SimplePolygonF f a -> a
$clast :: forall (f :: * -> *) a. Foldable1 f => SimplePolygonF f a -> a
last :: forall a. SimplePolygonF f a -> a
$cfoldrMap1 :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
foldrMap1 :: forall a b. (a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
$cfoldlMap1' :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
foldlMap1' :: forall a b. (a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
$cfoldlMap1 :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
foldlMap1 :: forall a b. (a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b
$cfoldrMap1' :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
foldrMap1' :: forall a b. (a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b
Foldable1,SimplePolygonF f point -> SimplePolygonF f point -> Bool
(SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> (SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> Eq (SimplePolygonF f point)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (point :: k).
Eq (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
$c== :: forall k (f :: k -> *) (point :: k).
Eq (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
== :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
$c/= :: forall k (f :: k -> *) (point :: k).
Eq (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
/= :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
Eq,Eq (SimplePolygonF f point)
Eq (SimplePolygonF f point) =>
(SimplePolygonF f point -> SimplePolygonF f point -> Ordering)
-> (SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> (SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> (SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> (SimplePolygonF f point -> SimplePolygonF f point -> Bool)
-> (SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point)
-> (SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point)
-> Ord (SimplePolygonF f point)
SimplePolygonF f point -> SimplePolygonF f point -> Bool
SimplePolygonF f point -> SimplePolygonF f point -> Ordering
SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
Eq (SimplePolygonF f point)
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Ordering
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
$ccompare :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Ordering
compare :: SimplePolygonF f point -> SimplePolygonF f point -> Ordering
$c< :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
< :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
$c<= :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
<= :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
$c> :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
> :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
$c>= :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
>= :: SimplePolygonF f point -> SimplePolygonF f point -> Bool
$cmax :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
max :: SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
$cmin :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
min :: SimplePolygonF f point
-> SimplePolygonF f point -> SimplePolygonF f point
Ord,(forall a. Eq a => Eq (SimplePolygonF f a)) =>
(forall a b.
(a -> b -> Bool)
-> SimplePolygonF f a -> SimplePolygonF f b -> Bool)
-> Eq1 (SimplePolygonF f)
forall a. Eq a => Eq (SimplePolygonF f a)
forall a b.
(a -> b -> Bool)
-> SimplePolygonF f a -> SimplePolygonF f b -> Bool
forall (f :: * -> *) a. (Eq1 f, Eq a) => Eq (SimplePolygonF f a)
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool)
-> SimplePolygonF f a -> SimplePolygonF f b -> Bool
forall (f :: * -> *).
(forall a. Eq a => Eq (f a)) =>
(forall a b. (a -> b -> Bool) -> f a -> f b -> Bool) -> Eq1 f
$cliftEq :: forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool)
-> SimplePolygonF f a -> SimplePolygonF f b -> Bool
liftEq :: forall a b.
(a -> b -> Bool)
-> SimplePolygonF f a -> SimplePolygonF f b -> Bool
Eq1,Eq1 (SimplePolygonF f)
(Eq1 (SimplePolygonF f),
forall a. Ord a => Ord (SimplePolygonF f a)) =>
(forall a b.
(a -> b -> Ordering)
-> SimplePolygonF f a -> SimplePolygonF f b -> Ordering)
-> Ord1 (SimplePolygonF f)
forall a. Ord a => Ord (SimplePolygonF f a)
forall a b.
(a -> b -> Ordering)
-> SimplePolygonF f a -> SimplePolygonF f b -> Ordering
forall (f :: * -> *). Ord1 f => Eq1 (SimplePolygonF f)
forall (f :: * -> *) a. (Ord1 f, Ord a) => Ord (SimplePolygonF f a)
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering)
-> SimplePolygonF f a -> SimplePolygonF f b -> Ordering
forall (f :: * -> *).
(Eq1 f, forall a. Ord a => Ord (f a)) =>
(forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering)
-> Ord1 f
$cliftCompare :: forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering)
-> SimplePolygonF f a -> SimplePolygonF f b -> Ordering
liftCompare :: forall a b.
(a -> b -> Ordering)
-> SimplePolygonF f a -> SimplePolygonF f b -> Ordering
Ord1)
type SimplePolygon = SimplePolygonF (Cyclic NonEmptyVector)
type instance Dimension (SimplePolygonF f point) = 2
type instance NumType (SimplePolygonF f point) = NumType point
_SimplePolygonF :: Iso (SimplePolygonF f point) (SimplePolygonF f' point')
(f point) (f' point' )
_SimplePolygonF :: forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF = (SimplePolygonF f point -> f point)
-> (f' point' -> SimplePolygonF f' point')
-> Iso
(SimplePolygonF f point)
(SimplePolygonF f' point')
(f point)
(f' point')
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(MkSimplePolygon f point
vs) -> f point
vs) f' point' -> SimplePolygonF f' point'
forall {k} (f :: k -> *) (point :: k).
f point -> SimplePolygonF f point
MkSimplePolygon
instance Traversable f => Traversable (SimplePolygonF f) where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> SimplePolygonF f a -> f (SimplePolygonF f b)
traverse a -> f b
f (MkSimplePolygon f a
vs) = f b -> SimplePolygonF f b
forall {k} (f :: k -> *) (point :: k).
f point -> SimplePolygonF f point
MkSimplePolygon (f b -> SimplePolygonF f b) -> f (f b) -> f (SimplePolygonF f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> f a -> f (f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse a -> f b
f f a
vs
instance Traversable1 f => Traversable1 (SimplePolygonF f) where
traverse1 :: forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> SimplePolygonF f a -> f (SimplePolygonF f b)
traverse1 a -> f b
f (MkSimplePolygon f a
vs) = f b -> SimplePolygonF f b
forall {k} (f :: k -> *) (point :: k).
f point -> SimplePolygonF f point
MkSimplePolygon (f b -> SimplePolygonF f b) -> f (f b) -> f (SimplePolygonF f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> f a -> f (f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b. Apply f => (a -> f b) -> f a -> f (f b)
traverse1 a -> f b
f f a
vs
instance (ShiftedEq (f point), ElemCyclic (f point) ~ point
) => ShiftedEq (SimplePolygonF f point) where
type ElemCyclic (SimplePolygonF f point) = point
isShiftOf :: Eq (ElemCyclic (SimplePolygonF f point)) =>
SimplePolygonF f point -> SimplePolygonF f point -> Bool
isShiftOf SimplePolygonF f point
p SimplePolygonF f point
q = f point -> f point -> Bool
forall t. (ShiftedEq t, Eq (ElemCyclic t)) => t -> t -> Bool
isShiftOf (SimplePolygonF f point
pSimplePolygonF f point
-> Getting (f point) (SimplePolygonF f point) (f point) -> f point
forall s a. s -> Getting a s a -> a
^.Getting (f point) (SimplePolygonF f point) (f point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF) (SimplePolygonF f point
qSimplePolygonF f point
-> Getting (f point) (SimplePolygonF f point) (f point) -> f point
forall s a. s -> Getting a s a -> a
^.Getting (f point) (SimplePolygonF f point) (f point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF)
instance (Foldable f, ToJSON point) => ToJSON (SimplePolygonF f point) where
toJSON :: SimplePolygonF f point -> Value
toJSON SimplePolygonF f point
pg = [Pair] -> Value
object [ Key
"tag" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= (String
"SimplePolygon" :: String)
, Key
"vertices" Key -> [point] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
Aeson..= SimplePolygonF f point -> [point]
forall a. SimplePolygonF f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList SimplePolygonF f point
pg
]
instance (HasFromFoldable1 f, FromJSON point) => FromJSON (SimplePolygonF f point) where
parseJSON :: Value -> Parser (SimplePolygonF f point)
parseJSON = String
-> (Object -> Parser (SimplePolygonF f point))
-> Value
-> Parser (SimplePolygonF f point)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"SimplePolygon" ((Object -> Parser (SimplePolygonF f point))
-> Value -> Parser (SimplePolygonF f point))
-> (Object -> Parser (SimplePolygonF f point))
-> Value
-> Parser (SimplePolygonF f point)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
("SimplePolygon" :: String) <- Object
o Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"tag"
MkSimplePolygon . F.fromNonEmpty @f @point <$> o .: "vertices"
type VertexContainer f point = ( IxValue (f point) ~ point
, Index (f point) ~ Int
, TraversableWithIndex Int f
, Traversable1 f
, Ixed (f point)
, HasDirectedTraversals f
)
instance ( VertexContainer f point
) => HasPoints (SimplePolygonF f point) (SimplePolygonF f point') point point' where
allPoints :: forall (d :: Nat) r r'.
(Point_ point d r, Point_ point' d r',
NumType (SimplePolygonF f point) ~ r,
NumType (SimplePolygonF f point') ~ r',
Dimension (SimplePolygonF f point) ~ d,
Dimension (SimplePolygonF f point') ~ d) =>
Traversal1
(SimplePolygonF f point) (SimplePolygonF f point') point point'
allPoints = (f point -> f (f point'))
-> SimplePolygonF f point -> f (SimplePolygonF f point')
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF ((f point -> f (f point'))
-> SimplePolygonF f point -> f (SimplePolygonF f point'))
-> ((point -> f point') -> f point -> f (f point'))
-> (point -> f point')
-> SimplePolygonF f point
-> f (SimplePolygonF f point')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (point -> f point') -> f point -> f (f point')
forall (f :: * -> *) a b.
Traversable1 f =>
IndexedTraversal1 Int (f a) (f b) a b
IndexedTraversal1 Int (f point) (f point') point point'
traversed1
instance ( VertexContainer f point
, Point_ point 2 r
) => IsBoxable (SimplePolygonF f point)
instance ( VertexContainer f point
) => HasVertices (SimplePolygonF f point) (SimplePolygonF f point') where
vertices :: IndexedTraversal1
(VertexIx (SimplePolygonF f point))
(SimplePolygonF f point)
(SimplePolygonF f point')
(Vertex (SimplePolygonF f point))
(Vertex (SimplePolygonF f point'))
vertices = (f point -> f (f point'))
-> SimplePolygonF f point -> f (SimplePolygonF f point')
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF ((f point -> f (f point'))
-> SimplePolygonF f point -> f (SimplePolygonF f point'))
-> (p point (f point') -> f point -> f (f point'))
-> p point (f point')
-> SimplePolygonF f point
-> f (SimplePolygonF f point')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p point (f point') -> f point -> f (f point')
forall (f :: * -> *) a b.
Traversable1 f =>
IndexedTraversal1 Int (f a) (f b) a b
IndexedTraversal1 Int (f point) (f point') point point'
traversed1
instance ( VertexContainer f point
) => HasVertices' (SimplePolygonF f point) where
type Vertex (SimplePolygonF f point) = point
type VertexIx (SimplePolygonF f point) = Int
vertexAt :: VertexIx (SimplePolygonF f point)
-> IndexedTraversal'
(VertexIx (SimplePolygonF f point))
(SimplePolygonF f point)
(Vertex (SimplePolygonF f point))
vertexAt VertexIx (SimplePolygonF f point)
i = (f point -> f (f point))
-> SimplePolygonF f point -> f (SimplePolygonF f point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF ((f point -> f (f point))
-> SimplePolygonF f point -> f (SimplePolygonF f point))
-> (p point (f point) -> f point -> f (f point))
-> p point (f point)
-> SimplePolygonF f point
-> f (SimplePolygonF f point)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (f point)
-> IndexedTraversal'
(Index (f point)) (f point) (IxValue (f point))
forall m.
Ixed m =>
Index m -> IndexedTraversal' (Index m) m (IxValue m)
iix VertexIx (SimplePolygonF f point)
Index (f point)
i
numVertices :: SimplePolygonF f point -> Int
numVertices = f point -> Int
forall a. f a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
F.length (f point -> Int)
-> (SimplePolygonF f point -> f point)
-> SimplePolygonF f point
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (f point) (SimplePolygonF f point) (f point)
-> SimplePolygonF f point -> f point
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (f point) (SimplePolygonF f point) (f point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF
instance VertexContainer f vertex => HasEdges' (SimplePolygonF f vertex) where
type Edge (SimplePolygonF f vertex) = ()
type EdgeIx (SimplePolygonF f vertex) = VertexIx (SimplePolygonF f vertex)
edgeAt :: EdgeIx (SimplePolygonF f vertex)
-> IndexedTraversal'
(EdgeIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
(Edge (SimplePolygonF f vertex))
edgeAt EdgeIx (SimplePolygonF f vertex)
u = \p (Edge (SimplePolygonF f vertex))
(f (Edge (SimplePolygonF f vertex)))
pUnitFUnit SimplePolygonF f vertex
poly -> SimplePolygonF f vertex
poly SimplePolygonF f vertex -> f () -> f (SimplePolygonF f vertex)
forall a b. a -> f b -> f a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ p () (f ()) -> Int -> () -> f ()
forall a b. p a b -> Int -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed p () (f ())
p (Edge (SimplePolygonF f vertex))
(f (Edge (SimplePolygonF f vertex)))
pUnitFUnit Int
EdgeIx (SimplePolygonF f vertex)
u ()
numEdges :: SimplePolygonF f vertex -> Int
numEdges = SimplePolygonF f vertex -> Int
forall graph. HasVertices' graph => graph -> Int
numVertices
instance VertexContainer f vertex
=> HasEdges (SimplePolygonF f vertex) (SimplePolygonF f vertex) where
edges :: IndexedTraversal
(EdgeIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
(SimplePolygonF f vertex)
(Edge (SimplePolygonF f vertex))
(Edge (SimplePolygonF f vertex))
edges = ((p ~ (->)) =>
(() -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex))
-> (p () (f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex))
-> p () (f ())
-> SimplePolygonF f vertex
-> f (SimplePolygonF f vertex)
forall (p :: * -> * -> *) (q :: * -> * -> *) a b r.
Conjoined p =>
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
forall (q :: * -> * -> *) a b r.
((p ~ (->)) => q (a -> b) r) -> q (p a b) r -> q (p a b) r
conjoined (p ~ (->)) =>
(() -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
(() -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
forall (g :: * -> *).
Applicative g =>
(() -> g ())
-> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
trav ((Int -> () -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
(VertexIx (SimplePolygonF f vertex) -> () -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
forall (g :: * -> *).
Applicative g =>
(VertexIx (SimplePolygonF f vertex) -> () -> g ())
-> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
itrav((Int -> () -> f ())
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex))
-> (p () (f ()) -> Int -> () -> f ())
-> p () (f ())
-> SimplePolygonF f vertex
-> f (SimplePolygonF f vertex)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.p () (f ()) -> Int -> () -> f ()
forall a b. p a b -> Int -> a -> b
forall i (p :: * -> * -> *) a b.
Indexable i p =>
p a b -> i -> a -> b
indexed)
where
trav :: Applicative g
=> (() -> g ()) -> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
trav :: forall (g :: * -> *).
Applicative g =>
(() -> g ())
-> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
trav () -> g ()
f SimplePolygonF f vertex
poly = WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex)
forall (f :: * -> *) a. WrappedApplicative f a -> f a
unwrapApplicative (WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex))
-> WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex)
forall a b. (a -> b) -> a -> b
$
SimplePolygonF f vertex
poly SimplePolygonF f vertex
-> WrappedApplicative g (SimplePolygonF f vertex)
-> WrappedApplicative g (SimplePolygonF f vertex)
forall a b. a -> WrappedApplicative g b -> WrappedApplicative g a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ((vertex -> WrappedApplicative g vertex)
-> SimplePolygonF f vertex
-> WrappedApplicative g (SimplePolygonF f vertex)
IndexedTraversal1'
(VertexIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
vertex
vertices' (\vertex
x -> vertex
x vertex -> WrappedApplicative g () -> WrappedApplicative g vertex
forall a b. a -> WrappedApplicative g b -> WrappedApplicative g a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ g () -> WrappedApplicative g ()
forall (f :: * -> *) a. f a -> WrappedApplicative f a
WrapApplicative (() -> g ()
f ())) SimplePolygonF f vertex
poly)
itrav :: Applicative g
=> (VertexIx (SimplePolygonF f vertex) -> () -> g ())
-> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
itrav :: forall (g :: * -> *).
Applicative g =>
(VertexIx (SimplePolygonF f vertex) -> () -> g ())
-> SimplePolygonF f vertex -> g (SimplePolygonF f vertex)
itrav VertexIx (SimplePolygonF f vertex) -> () -> g ()
f SimplePolygonF f vertex
poly = WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex)
forall (f :: * -> *) a. WrappedApplicative f a -> f a
unwrapApplicative (WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex))
-> WrappedApplicative g (SimplePolygonF f vertex)
-> g (SimplePolygonF f vertex)
forall a b. (a -> b) -> a -> b
$
SimplePolygonF f vertex
poly SimplePolygonF f vertex
-> WrappedApplicative g (SimplePolygonF f vertex)
-> WrappedApplicative g (SimplePolygonF f vertex)
forall a b. a -> WrappedApplicative g b -> WrappedApplicative g a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Indexed Int vertex (WrappedApplicative g vertex)
-> SimplePolygonF f vertex
-> WrappedApplicative g (SimplePolygonF f vertex)
IndexedTraversal1'
(VertexIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
vertex
vertices' ((Int -> vertex -> WrappedApplicative g vertex)
-> Indexed Int vertex (WrappedApplicative g vertex)
forall i a b. (i -> a -> b) -> Indexed i a b
Indexed ((Int -> vertex -> WrappedApplicative g vertex)
-> Indexed Int vertex (WrappedApplicative g vertex))
-> (Int -> vertex -> WrappedApplicative g vertex)
-> Indexed Int vertex (WrappedApplicative g vertex)
forall a b. (a -> b) -> a -> b
$ \Int
v vertex
x -> vertex
x vertex -> WrappedApplicative g () -> WrappedApplicative g vertex
forall a b. a -> WrappedApplicative g b -> WrappedApplicative g a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ g () -> WrappedApplicative g ()
forall (f :: * -> *) a. f a -> WrappedApplicative f a
WrapApplicative (VertexIx (SimplePolygonF f vertex) -> () -> g ()
f Int
VertexIx (SimplePolygonF f vertex)
v ())) SimplePolygonF f vertex
poly
vertices' :: IndexedTraversal1' (VertexIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex) vertex
vertices' :: IndexedTraversal1'
(VertexIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
vertex
vertices' = p vertex (f vertex)
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
p (Vertex (SimplePolygonF f vertex))
(f (Vertex (SimplePolygonF f vertex)))
-> SimplePolygonF f vertex -> f (SimplePolygonF f vertex)
forall graph graph'.
HasVertices graph graph' =>
IndexedTraversal1
(VertexIx graph) graph graph' (Vertex graph) (Vertex graph')
IndexedTraversal1
(VertexIx (SimplePolygonF f vertex))
(SimplePolygonF f vertex)
(SimplePolygonF f vertex)
(Vertex (SimplePolygonF f vertex))
(Vertex (SimplePolygonF f vertex))
vertices
toCyclic :: SimplePolygonF (Cyclic v) point -> Cyclic v point
toCyclic :: forall {k} (v :: k -> *) (point :: k).
SimplePolygonF (Cyclic v) point -> Cyclic v point
toCyclic = Getting
(Cyclic v point) (SimplePolygonF (Cyclic v) point) (Cyclic v point)
-> SimplePolygonF (Cyclic v) point -> Cyclic v point
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
(Cyclic v point) (SimplePolygonF (Cyclic v) point) (Cyclic v point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
(point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (SimplePolygonF f point) (f (SimplePolygonF f' point'))
_SimplePolygonF