{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Ipe.Content(
    Image(Image), imageData, imageRect
  , TextLabel(..)
  , MiniPage(..), width

  , IpeSymbol(Symbol), symbolPoint, symbolName

  , Path(Path), pathSegments
  , PathSegment(..)

  , Group(Group), groupItems


  , IpeObject(..), _IpeGroup, _IpeImage, _IpeTextLabel, _IpeMiniPage, _IpeUse, _IpePath
  , IpeObject'
  , ipeObject', ToObject(..)

  , IpeAttributes
  , attributes

  , flattenGroups
  ) where

import           Ipe.Value
import           Data.Bitraversable
import           Control.Lens hiding (views, elements)
import           Data.Kind
import           Data.Proxy
import           Data.Text (Text)
import           Data.Traversable
import           GHC.Generics (Generic)
import           HGeometry.Box (Rectangle)
import           HGeometry.Ext
import           HGeometry.Matrix
import           HGeometry.Point
import           HGeometry.Properties
import           HGeometry.Transformation
import qualified Ipe.Attributes as AT
import           Ipe.Attributes hiding (Matrix)
import           Ipe.Color
import           Ipe.Layer
import           Ipe.Path
import           Ipe.Attributes.Types

--------------------------------------------------------------------------------
-- | Image Objects

-- | bitmap image objects in Ipe
data Image r = Image { forall r. Image r -> ()
_imageData :: ()
                     , forall r. Image r -> Rectangle (Point 2 r)
_imageRect      :: Rectangle (Point 2 r)
                     } deriving (Int -> Image r -> ShowS
[Image r] -> ShowS
Image r -> String
(Int -> Image r -> ShowS)
-> (Image r -> String) -> ([Image r] -> ShowS) -> Show (Image r)
forall r. Show r => Int -> Image r -> ShowS
forall r. Show r => [Image r] -> ShowS
forall r. Show r => Image r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> Image r -> ShowS
showsPrec :: Int -> Image r -> ShowS
$cshow :: forall r. Show r => Image r -> String
show :: Image r -> String
$cshowList :: forall r. Show r => [Image r] -> ShowS
showList :: [Image r] -> ShowS
Show,Image r -> Image r -> Bool
(Image r -> Image r -> Bool)
-> (Image r -> Image r -> Bool) -> Eq (Image r)
forall r. Eq r => Image r -> Image r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => Image r -> Image r -> Bool
== :: Image r -> Image r -> Bool
$c/= :: forall r. Eq r => Image r -> Image r -> Bool
/= :: Image r -> Image r -> Bool
Eq,Eq (Image r)
Eq (Image r) =>
(Image r -> Image r -> Ordering)
-> (Image r -> Image r -> Bool)
-> (Image r -> Image r -> Bool)
-> (Image r -> Image r -> Bool)
-> (Image r -> Image r -> Bool)
-> (Image r -> Image r -> Image r)
-> (Image r -> Image r -> Image r)
-> Ord (Image r)
Image r -> Image r -> Bool
Image r -> Image r -> Ordering
Image r -> Image r -> Image r
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 r. Ord r => Eq (Image r)
forall r. Ord r => Image r -> Image r -> Bool
forall r. Ord r => Image r -> Image r -> Ordering
forall r. Ord r => Image r -> Image r -> Image r
$ccompare :: forall r. Ord r => Image r -> Image r -> Ordering
compare :: Image r -> Image r -> Ordering
$c< :: forall r. Ord r => Image r -> Image r -> Bool
< :: Image r -> Image r -> Bool
$c<= :: forall r. Ord r => Image r -> Image r -> Bool
<= :: Image r -> Image r -> Bool
$c> :: forall r. Ord r => Image r -> Image r -> Bool
> :: Image r -> Image r -> Bool
$c>= :: forall r. Ord r => Image r -> Image r -> Bool
>= :: Image r -> Image r -> Bool
$cmax :: forall r. Ord r => Image r -> Image r -> Image r
max :: Image r -> Image r -> Image r
$cmin :: forall r. Ord r => Image r -> Image r -> Image r
min :: Image r -> Image r -> Image r
Ord,(forall x. Image r -> Rep (Image r) x)
-> (forall x. Rep (Image r) x -> Image r) -> Generic (Image r)
forall x. Rep (Image r) x -> Image r
forall x. Image r -> Rep (Image r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (Image r) x -> Image r
forall r x. Image r -> Rep (Image r) x
$cfrom :: forall r x. Image r -> Rep (Image r) x
from :: forall x. Image r -> Rep (Image r) x
$cto :: forall r x. Rep (Image r) x -> Image r
to :: forall x. Rep (Image r) x -> Image r
Generic)

-- | Lens to access the image data
imageData :: Lens' (Image r) ()
imageData :: forall r (f :: * -> *).
Functor f =>
(() -> f ()) -> Image r -> f (Image r)
imageData () -> f ()
f (Image ()
i Rectangle (Point 2 r)
r) = (() -> Image r) -> f () -> f (Image r)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\()
i' -> () -> Rectangle (Point 2 r) -> Image r
forall r. () -> Rectangle (Point 2 r) -> Image r
Image ()
i' Rectangle (Point 2 r)
r) (() -> f ()
f ()
i)
{-# INLINE imageData #-}

-- | Lens to access the rectangle of the image
imageRect :: Lens (Image r) (Image r') (Rectangle (Point 2 r)) (Rectangle (Point 2 r'))
imageRect :: forall r r' (f :: * -> *).
Functor f =>
(Rectangle (Point 2 r) -> f (Rectangle (Point 2 r')))
-> Image r -> f (Image r')
imageRect Rectangle (Point 2 r) -> f (Rectangle (Point 2 r'))
f (Image ()
i Rectangle (Point 2 r)
r) = (Rectangle (Point 2 r') -> Image r')
-> f (Rectangle (Point 2 r')) -> f (Image r')
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Rectangle (Point 2 r')
r' -> () -> Rectangle (Point 2 r') -> Image r'
forall r. () -> Rectangle (Point 2 r) -> Image r
Image ()
i Rectangle (Point 2 r')
r') (Rectangle (Point 2 r) -> f (Rectangle (Point 2 r'))
f Rectangle (Point 2 r)
r)
{-# INLINE imageRect #-}

type instance NumType   (Image r) = r
type instance Dimension (Image r) = 2

instance Fractional r => IsTransformable (Image r) where
  transformBy :: Transformation (Dimension (Image r)) (NumType (Image r))
-> Image r -> Image r
transformBy Transformation (Dimension (Image r)) (NumType (Image r))
t = ASetter
  (Image r) (Image r) (Rectangle (Point 2 r)) (Rectangle (Point 2 r))
-> (Rectangle (Point 2 r) -> Rectangle (Point 2 r))
-> Image r
-> Image r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
  (Image r) (Image r) (Rectangle (Point 2 r)) (Rectangle (Point 2 r))
forall r r' (f :: * -> *).
Functor f =>
(Rectangle (Point 2 r) -> f (Rectangle (Point 2 r')))
-> Image r -> f (Image r')
imageRect (Transformation
  (Dimension (Rectangle (Point 2 r)))
  (NumType (Rectangle (Point 2 r)))
-> Rectangle (Point 2 r) -> Rectangle (Point 2 r)
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation
  (Dimension (Rectangle (Point 2 r)))
  (NumType (Rectangle (Point 2 r)))
Transformation (Dimension (Image r)) (NumType (Image r))
t)

instance Functor Image where
  fmap :: forall a b. (a -> b) -> Image a -> Image b
fmap = (a -> b) -> Image a -> Image b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable Image where
  foldMap :: forall m a. Monoid m => (a -> m) -> Image a -> m
foldMap = (a -> m) -> Image a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable Image where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Image a -> f (Image b)
traverse a -> f b
f (Image ()
d Rectangle (Point 2 a)
r) = () -> Rectangle (Point 2 b) -> Image b
forall r. () -> Rectangle (Point 2 r) -> Image r
Image ()
d (Rectangle (Point 2 b) -> Image b)
-> f (Rectangle (Point 2 b)) -> f (Image b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Point 2 a -> f (Point 2 b))
-> Rectangle (Point 2 a) -> f (Rectangle (Point 2 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) -> Box a -> f (Box b)
traverse (ATraversal (Point 2 a) (Point 2 b) a b
-> Traversal (Point 2 a) (Point 2 b) a b
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal (Point 2 a) (Point 2 b) a b
(NumType (Point 2 a) -> Bazaar (->) a b (NumType (Point 2 b)))
-> Point 2 a -> Bazaar (->) a b (Point 2 b)
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates a -> f b
f) Rectangle (Point 2 a)
r

--------------------------------------------------------------------------------
-- | Text Objects

-- | A text label
data TextLabel r = Label Text (Point 2 r)
                 deriving (Int -> TextLabel r -> ShowS
[TextLabel r] -> ShowS
TextLabel r -> String
(Int -> TextLabel r -> ShowS)
-> (TextLabel r -> String)
-> ([TextLabel r] -> ShowS)
-> Show (TextLabel r)
forall r. Show r => Int -> TextLabel r -> ShowS
forall r. Show r => [TextLabel r] -> ShowS
forall r. Show r => TextLabel r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> TextLabel r -> ShowS
showsPrec :: Int -> TextLabel r -> ShowS
$cshow :: forall r. Show r => TextLabel r -> String
show :: TextLabel r -> String
$cshowList :: forall r. Show r => [TextLabel r] -> ShowS
showList :: [TextLabel r] -> ShowS
Show,TextLabel r -> TextLabel r -> Bool
(TextLabel r -> TextLabel r -> Bool)
-> (TextLabel r -> TextLabel r -> Bool) -> Eq (TextLabel r)
forall r. Eq r => TextLabel r -> TextLabel r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => TextLabel r -> TextLabel r -> Bool
== :: TextLabel r -> TextLabel r -> Bool
$c/= :: forall r. Eq r => TextLabel r -> TextLabel r -> Bool
/= :: TextLabel r -> TextLabel r -> Bool
Eq,Eq (TextLabel r)
Eq (TextLabel r) =>
(TextLabel r -> TextLabel r -> Ordering)
-> (TextLabel r -> TextLabel r -> Bool)
-> (TextLabel r -> TextLabel r -> Bool)
-> (TextLabel r -> TextLabel r -> Bool)
-> (TextLabel r -> TextLabel r -> Bool)
-> (TextLabel r -> TextLabel r -> TextLabel r)
-> (TextLabel r -> TextLabel r -> TextLabel r)
-> Ord (TextLabel r)
TextLabel r -> TextLabel r -> Bool
TextLabel r -> TextLabel r -> Ordering
TextLabel r -> TextLabel r -> TextLabel r
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 r. Ord r => Eq (TextLabel r)
forall r. Ord r => TextLabel r -> TextLabel r -> Bool
forall r. Ord r => TextLabel r -> TextLabel r -> Ordering
forall r. Ord r => TextLabel r -> TextLabel r -> TextLabel r
$ccompare :: forall r. Ord r => TextLabel r -> TextLabel r -> Ordering
compare :: TextLabel r -> TextLabel r -> Ordering
$c< :: forall r. Ord r => TextLabel r -> TextLabel r -> Bool
< :: TextLabel r -> TextLabel r -> Bool
$c<= :: forall r. Ord r => TextLabel r -> TextLabel r -> Bool
<= :: TextLabel r -> TextLabel r -> Bool
$c> :: forall r. Ord r => TextLabel r -> TextLabel r -> Bool
> :: TextLabel r -> TextLabel r -> Bool
$c>= :: forall r. Ord r => TextLabel r -> TextLabel r -> Bool
>= :: TextLabel r -> TextLabel r -> Bool
$cmax :: forall r. Ord r => TextLabel r -> TextLabel r -> TextLabel r
max :: TextLabel r -> TextLabel r -> TextLabel r
$cmin :: forall r. Ord r => TextLabel r -> TextLabel r -> TextLabel r
min :: TextLabel r -> TextLabel r -> TextLabel r
Ord,(forall x. TextLabel r -> Rep (TextLabel r) x)
-> (forall x. Rep (TextLabel r) x -> TextLabel r)
-> Generic (TextLabel r)
forall x. Rep (TextLabel r) x -> TextLabel r
forall x. TextLabel r -> Rep (TextLabel r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (TextLabel r) x -> TextLabel r
forall r x. TextLabel r -> Rep (TextLabel r) x
$cfrom :: forall r x. TextLabel r -> Rep (TextLabel r) x
from :: forall x. TextLabel r -> Rep (TextLabel r) x
$cto :: forall r x. Rep (TextLabel r) x -> TextLabel r
to :: forall x. Rep (TextLabel r) x -> TextLabel r
Generic)

type instance NumType   (TextLabel r) = r
type instance Dimension (TextLabel r) = 2

instance Functor TextLabel  where fmap :: forall a b. (a -> b) -> TextLabel a -> TextLabel b
fmap = (a -> b) -> TextLabel a -> TextLabel b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable TextLabel where foldMap :: forall m a. Monoid m => (a -> m) -> TextLabel a -> m
foldMap = (a -> m) -> TextLabel a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable TextLabel where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TextLabel a -> f (TextLabel b)
traverse a -> f b
f (Label Text
t Point 2 a
p) = let coordinates' :: (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' = ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
-> Traversal
     (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates
                           in Text -> Point 2 b -> TextLabel b
forall r. Text -> Point 2 r -> TextLabel r
Label Text
t (Point 2 b -> TextLabel b) -> f (Point 2 b) -> f (TextLabel b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p

instance Fractional r => IsTransformable (TextLabel r) where
  transformBy :: Transformation (Dimension (TextLabel r)) (NumType (TextLabel r))
-> TextLabel r -> TextLabel r
transformBy Transformation (Dimension (TextLabel r)) (NumType (TextLabel r))
t (Label Text
txt Point 2 r
p) = Text -> Point 2 r -> TextLabel r
forall r. Text -> Point 2 r -> TextLabel r
Label Text
txt (Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
-> Point 2 r -> Point 2 r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
Transformation (Dimension (TextLabel r)) (NumType (TextLabel r))
t Point 2 r
p)


-- | A Minipage
data MiniPage r = MiniPage Text (Point 2 r) r
                 deriving (Int -> MiniPage r -> ShowS
[MiniPage r] -> ShowS
MiniPage r -> String
(Int -> MiniPage r -> ShowS)
-> (MiniPage r -> String)
-> ([MiniPage r] -> ShowS)
-> Show (MiniPage r)
forall r. Show r => Int -> MiniPage r -> ShowS
forall r. Show r => [MiniPage r] -> ShowS
forall r. Show r => MiniPage r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> MiniPage r -> ShowS
showsPrec :: Int -> MiniPage r -> ShowS
$cshow :: forall r. Show r => MiniPage r -> String
show :: MiniPage r -> String
$cshowList :: forall r. Show r => [MiniPage r] -> ShowS
showList :: [MiniPage r] -> ShowS
Show,MiniPage r -> MiniPage r -> Bool
(MiniPage r -> MiniPage r -> Bool)
-> (MiniPage r -> MiniPage r -> Bool) -> Eq (MiniPage r)
forall r. Eq r => MiniPage r -> MiniPage r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => MiniPage r -> MiniPage r -> Bool
== :: MiniPage r -> MiniPage r -> Bool
$c/= :: forall r. Eq r => MiniPage r -> MiniPage r -> Bool
/= :: MiniPage r -> MiniPage r -> Bool
Eq,Eq (MiniPage r)
Eq (MiniPage r) =>
(MiniPage r -> MiniPage r -> Ordering)
-> (MiniPage r -> MiniPage r -> Bool)
-> (MiniPage r -> MiniPage r -> Bool)
-> (MiniPage r -> MiniPage r -> Bool)
-> (MiniPage r -> MiniPage r -> Bool)
-> (MiniPage r -> MiniPage r -> MiniPage r)
-> (MiniPage r -> MiniPage r -> MiniPage r)
-> Ord (MiniPage r)
MiniPage r -> MiniPage r -> Bool
MiniPage r -> MiniPage r -> Ordering
MiniPage r -> MiniPage r -> MiniPage r
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 r. Ord r => Eq (MiniPage r)
forall r. Ord r => MiniPage r -> MiniPage r -> Bool
forall r. Ord r => MiniPage r -> MiniPage r -> Ordering
forall r. Ord r => MiniPage r -> MiniPage r -> MiniPage r
$ccompare :: forall r. Ord r => MiniPage r -> MiniPage r -> Ordering
compare :: MiniPage r -> MiniPage r -> Ordering
$c< :: forall r. Ord r => MiniPage r -> MiniPage r -> Bool
< :: MiniPage r -> MiniPage r -> Bool
$c<= :: forall r. Ord r => MiniPage r -> MiniPage r -> Bool
<= :: MiniPage r -> MiniPage r -> Bool
$c> :: forall r. Ord r => MiniPage r -> MiniPage r -> Bool
> :: MiniPage r -> MiniPage r -> Bool
$c>= :: forall r. Ord r => MiniPage r -> MiniPage r -> Bool
>= :: MiniPage r -> MiniPage r -> Bool
$cmax :: forall r. Ord r => MiniPage r -> MiniPage r -> MiniPage r
max :: MiniPage r -> MiniPage r -> MiniPage r
$cmin :: forall r. Ord r => MiniPage r -> MiniPage r -> MiniPage r
min :: MiniPage r -> MiniPage r -> MiniPage r
Ord,(forall x. MiniPage r -> Rep (MiniPage r) x)
-> (forall x. Rep (MiniPage r) x -> MiniPage r)
-> Generic (MiniPage r)
forall x. Rep (MiniPage r) x -> MiniPage r
forall x. MiniPage r -> Rep (MiniPage r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (MiniPage r) x -> MiniPage r
forall r x. MiniPage r -> Rep (MiniPage r) x
$cfrom :: forall r x. MiniPage r -> Rep (MiniPage r) x
from :: forall x. MiniPage r -> Rep (MiniPage r) x
$cto :: forall r x. Rep (MiniPage r) x -> MiniPage r
to :: forall x. Rep (MiniPage r) x -> MiniPage r
Generic)

type instance NumType   (MiniPage r) = r
type instance Dimension (MiniPage r) = 2

instance Functor MiniPage  where fmap :: forall a b. (a -> b) -> MiniPage a -> MiniPage b
fmap = (a -> b) -> MiniPage a -> MiniPage b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable MiniPage where foldMap :: forall m a. Monoid m => (a -> m) -> MiniPage a -> m
foldMap = (a -> m) -> MiniPage a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable MiniPage where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MiniPage a -> f (MiniPage b)
traverse a -> f b
f (MiniPage Text
t Point 2 a
p a
w) = let coordinates' :: (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' = ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
-> Traversal
     (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates
                                in Text -> Point 2 b -> b -> MiniPage b
forall r. Text -> Point 2 r -> r -> MiniPage r
MiniPage Text
t (Point 2 b -> b -> MiniPage b)
-> f (Point 2 b) -> f (b -> MiniPage b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p f (b -> MiniPage b) -> f b -> f (MiniPage b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
w

instance Fractional r => IsTransformable (MiniPage r) where
  transformBy :: Transformation (Dimension (MiniPage r)) (NumType (MiniPage r))
-> MiniPage r -> MiniPage r
transformBy Transformation (Dimension (MiniPage r)) (NumType (MiniPage r))
t (MiniPage Text
txt Point 2 r
p r
w) = Text -> Point 2 r -> r -> MiniPage r
forall r. Text -> Point 2 r -> r -> MiniPage r
MiniPage Text
txt (Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
-> Point 2 r -> Point 2 r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
Transformation (Dimension (MiniPage r)) (NumType (MiniPage r))
t Point 2 r
p) r
w

width                  :: MiniPage t -> t
width :: forall t. MiniPage t -> t
width (MiniPage Text
_ Point 2 t
_ t
w) = t
w

--------------------------------------------------------------------------------
-- | Ipe Symbols, i.e. Points

-- | A symbol (point) in ipe
data IpeSymbol r = Symbol { forall r. IpeSymbol r -> Point 2 r
_symbolPoint :: Point 2 r
                          , forall r. IpeSymbol r -> Text
_symbolName  :: Text
                          }
                 deriving (Int -> IpeSymbol r -> ShowS
[IpeSymbol r] -> ShowS
IpeSymbol r -> String
(Int -> IpeSymbol r -> ShowS)
-> (IpeSymbol r -> String)
-> ([IpeSymbol r] -> ShowS)
-> Show (IpeSymbol r)
forall r. Show r => Int -> IpeSymbol r -> ShowS
forall r. Show r => [IpeSymbol r] -> ShowS
forall r. Show r => IpeSymbol r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> IpeSymbol r -> ShowS
showsPrec :: Int -> IpeSymbol r -> ShowS
$cshow :: forall r. Show r => IpeSymbol r -> String
show :: IpeSymbol r -> String
$cshowList :: forall r. Show r => [IpeSymbol r] -> ShowS
showList :: [IpeSymbol r] -> ShowS
Show,IpeSymbol r -> IpeSymbol r -> Bool
(IpeSymbol r -> IpeSymbol r -> Bool)
-> (IpeSymbol r -> IpeSymbol r -> Bool) -> Eq (IpeSymbol r)
forall r. Eq r => IpeSymbol r -> IpeSymbol r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => IpeSymbol r -> IpeSymbol r -> Bool
== :: IpeSymbol r -> IpeSymbol r -> Bool
$c/= :: forall r. Eq r => IpeSymbol r -> IpeSymbol r -> Bool
/= :: IpeSymbol r -> IpeSymbol r -> Bool
Eq,Eq (IpeSymbol r)
Eq (IpeSymbol r) =>
(IpeSymbol r -> IpeSymbol r -> Ordering)
-> (IpeSymbol r -> IpeSymbol r -> Bool)
-> (IpeSymbol r -> IpeSymbol r -> Bool)
-> (IpeSymbol r -> IpeSymbol r -> Bool)
-> (IpeSymbol r -> IpeSymbol r -> Bool)
-> (IpeSymbol r -> IpeSymbol r -> IpeSymbol r)
-> (IpeSymbol r -> IpeSymbol r -> IpeSymbol r)
-> Ord (IpeSymbol r)
IpeSymbol r -> IpeSymbol r -> Bool
IpeSymbol r -> IpeSymbol r -> Ordering
IpeSymbol r -> IpeSymbol r -> IpeSymbol r
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 r. Ord r => Eq (IpeSymbol r)
forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Bool
forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Ordering
forall r. Ord r => IpeSymbol r -> IpeSymbol r -> IpeSymbol r
$ccompare :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Ordering
compare :: IpeSymbol r -> IpeSymbol r -> Ordering
$c< :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Bool
< :: IpeSymbol r -> IpeSymbol r -> Bool
$c<= :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Bool
<= :: IpeSymbol r -> IpeSymbol r -> Bool
$c> :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Bool
> :: IpeSymbol r -> IpeSymbol r -> Bool
$c>= :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> Bool
>= :: IpeSymbol r -> IpeSymbol r -> Bool
$cmax :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> IpeSymbol r
max :: IpeSymbol r -> IpeSymbol r -> IpeSymbol r
$cmin :: forall r. Ord r => IpeSymbol r -> IpeSymbol r -> IpeSymbol r
min :: IpeSymbol r -> IpeSymbol r -> IpeSymbol r
Ord,(forall x. IpeSymbol r -> Rep (IpeSymbol r) x)
-> (forall x. Rep (IpeSymbol r) x -> IpeSymbol r)
-> Generic (IpeSymbol r)
forall x. Rep (IpeSymbol r) x -> IpeSymbol r
forall x. IpeSymbol r -> Rep (IpeSymbol r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (IpeSymbol r) x -> IpeSymbol r
forall r x. IpeSymbol r -> Rep (IpeSymbol r) x
$cfrom :: forall r x. IpeSymbol r -> Rep (IpeSymbol r) x
from :: forall x. IpeSymbol r -> Rep (IpeSymbol r) x
$cto :: forall r x. Rep (IpeSymbol r) x -> IpeSymbol r
to :: forall x. Rep (IpeSymbol r) x -> IpeSymbol r
Generic)

-- | Lens to access the position of the symbol
symbolPoint :: Lens (IpeSymbol r) (IpeSymbol r') (Point 2 r) (Point 2 r')
symbolPoint :: forall r r' (f :: * -> *).
Functor f =>
(Point 2 r -> f (Point 2 r')) -> IpeSymbol r -> f (IpeSymbol r')
symbolPoint Point 2 r -> f (Point 2 r')
f (Symbol Point 2 r
p Text
n) = (Point 2 r' -> IpeSymbol r') -> f (Point 2 r') -> f (IpeSymbol r')
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Point 2 r'
p' -> Point 2 r' -> Text -> IpeSymbol r'
forall r. Point 2 r -> Text -> IpeSymbol r
Symbol Point 2 r'
p' Text
n) (Point 2 r -> f (Point 2 r')
f Point 2 r
p)
{-# INLINE symbolPoint #-}

-- | Lens to access the name of the symbol
symbolName :: Lens' (IpeSymbol r) Text
symbolName :: forall r (f :: * -> *).
Functor f =>
(Text -> f Text) -> IpeSymbol r -> f (IpeSymbol r)
symbolName Text -> f Text
f (Symbol Point 2 r
p Text
n) = (Text -> IpeSymbol r) -> f Text -> f (IpeSymbol r)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Text
n' -> Point 2 r -> Text -> IpeSymbol r
forall r. Point 2 r -> Text -> IpeSymbol r
Symbol Point 2 r
p Text
n') (Text -> f Text
f Text
n)
{-# INLINE symbolName #-}


type instance NumType   (IpeSymbol r) = r
type instance Dimension (IpeSymbol r) = 2

instance Functor IpeSymbol  where fmap :: forall a b. (a -> b) -> IpeSymbol a -> IpeSymbol b
fmap = (a -> b) -> IpeSymbol a -> IpeSymbol b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable IpeSymbol where foldMap :: forall m a. Monoid m => (a -> m) -> IpeSymbol a -> m
foldMap = (a -> m) -> IpeSymbol a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable IpeSymbol where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IpeSymbol a -> f (IpeSymbol b)
traverse a -> f b
f (Symbol Point 2 a
p Text
t) = let coordinates' :: (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' = ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
-> Traversal
     (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall s t a b. ATraversal s t a b -> Traversal s t a b
cloneTraversal ATraversal
  (Point 2 a) (Point 2 b) (NumType (Point 2 a)) (NumType (Point 2 b))
forall point point'.
HasCoordinates point point' =>
IndexedTraversal1 Int point point' (NumType point) (NumType point')
IndexedTraversal1
  Int
  (Point 2 a)
  (Point 2 b)
  (NumType (Point 2 a))
  (NumType (Point 2 b))
coordinates
                            in (Point 2 b -> Text -> IpeSymbol b)
-> Text -> Point 2 b -> IpeSymbol b
forall a b c. (a -> b -> c) -> b -> a -> c
flip Point 2 b -> Text -> IpeSymbol b
forall r. Point 2 r -> Text -> IpeSymbol r
Symbol Text
t (Point 2 b -> IpeSymbol b) -> f (Point 2 b) -> f (IpeSymbol b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NumType (Point 2 a) -> f (NumType (Point 2 b)))
-> Point 2 a -> f (Point 2 b)
coordinates' a -> f b
NumType (Point 2 a) -> f (NumType (Point 2 b))
f Point 2 a
p

instance Fractional r => IsTransformable (IpeSymbol r) where
  transformBy :: Transformation (Dimension (IpeSymbol r)) (NumType (IpeSymbol r))
-> IpeSymbol r -> IpeSymbol r
transformBy Transformation (Dimension (IpeSymbol r)) (NumType (IpeSymbol r))
t = ASetter (IpeSymbol r) (IpeSymbol r) (Point 2 r) (Point 2 r)
-> (Point 2 r -> Point 2 r) -> IpeSymbol r -> IpeSymbol r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (IpeSymbol r) (IpeSymbol r) (Point 2 r) (Point 2 r)
forall r r' (f :: * -> *).
Functor f =>
(Point 2 r -> f (Point 2 r')) -> IpeSymbol r -> f (IpeSymbol r')
symbolPoint (Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
-> Point 2 r -> Point 2 r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (Point 2 r)) (NumType (Point 2 r))
Transformation (Dimension (IpeSymbol r)) (NumType (IpeSymbol r))
t)


--------------------------------------------------------------------------------
-- * Paths are in a separate module


--------------------------------------------------------------------------------



--------------------------------------------------------------------------------
-- | Groups and Objects

--------------------------------------------------------------------------------
-- | Group Attributes



-- | A group is essentially a list of IpeObjects.
newtype Group r = Group [IpeObject r]
  deriving (Int -> Group r -> ShowS
[Group r] -> ShowS
Group r -> String
(Int -> Group r -> ShowS)
-> (Group r -> String) -> ([Group r] -> ShowS) -> Show (Group r)
forall r. Show r => Int -> Group r -> ShowS
forall r. Show r => [Group r] -> ShowS
forall r. Show r => Group r -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall r. Show r => Int -> Group r -> ShowS
showsPrec :: Int -> Group r -> ShowS
$cshow :: forall r. Show r => Group r -> String
show :: Group r -> String
$cshowList :: forall r. Show r => [Group r] -> ShowS
showList :: [Group r] -> ShowS
Show,Group r -> Group r -> Bool
(Group r -> Group r -> Bool)
-> (Group r -> Group r -> Bool) -> Eq (Group r)
forall r. Eq r => Group r -> Group r -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall r. Eq r => Group r -> Group r -> Bool
== :: Group r -> Group r -> Bool
$c/= :: forall r. Eq r => Group r -> Group r -> Bool
/= :: Group r -> Group r -> Bool
Eq,(forall a b. (a -> b) -> Group a -> Group b)
-> (forall a b. a -> Group b -> Group a) -> Functor Group
forall a b. a -> Group b -> Group a
forall a b. (a -> b) -> Group a -> Group b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Group a -> Group b
fmap :: forall a b. (a -> b) -> Group a -> Group b
$c<$ :: forall a b. a -> Group b -> Group a
<$ :: forall a b. a -> Group b -> Group a
Functor,(forall m. Monoid m => Group m -> m)
-> (forall m a. Monoid m => (a -> m) -> Group a -> m)
-> (forall m a. Monoid m => (a -> m) -> Group a -> m)
-> (forall a b. (a -> b -> b) -> b -> Group a -> b)
-> (forall a b. (a -> b -> b) -> b -> Group a -> b)
-> (forall b a. (b -> a -> b) -> b -> Group a -> b)
-> (forall b a. (b -> a -> b) -> b -> Group a -> b)
-> (forall a. (a -> a -> a) -> Group a -> a)
-> (forall a. (a -> a -> a) -> Group a -> a)
-> (forall a. Group a -> [a])
-> (forall a. Group a -> Bool)
-> (forall a. Group a -> Int)
-> (forall a. Eq a => a -> Group a -> Bool)
-> (forall a. Ord a => Group a -> a)
-> (forall a. Ord a => Group a -> a)
-> (forall a. Num a => Group a -> a)
-> (forall a. Num a => Group a -> a)
-> Foldable Group
forall a. Eq a => a -> Group a -> Bool
forall a. Num a => Group a -> a
forall a. Ord a => Group a -> a
forall m. Monoid m => Group m -> m
forall a. Group a -> Bool
forall a. Group a -> Int
forall a. Group a -> [a]
forall a. (a -> a -> a) -> Group a -> a
forall m a. Monoid m => (a -> m) -> Group a -> m
forall b a. (b -> a -> b) -> b -> Group a -> b
forall a b. (a -> b -> b) -> b -> Group 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 m. Monoid m => Group m -> m
fold :: forall m. Monoid m => Group m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Group a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Group a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Group a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Group a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Group a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Group a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Group a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Group a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Group a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Group a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Group a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Group a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Group a -> a
foldr1 :: forall a. (a -> a -> a) -> Group a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Group a -> a
foldl1 :: forall a. (a -> a -> a) -> Group a -> a
$ctoList :: forall a. Group a -> [a]
toList :: forall a. Group a -> [a]
$cnull :: forall a. Group a -> Bool
null :: forall a. Group a -> Bool
$clength :: forall a. Group a -> Int
length :: forall a. Group a -> Int
$celem :: forall a. Eq a => a -> Group a -> Bool
elem :: forall a. Eq a => a -> Group a -> Bool
$cmaximum :: forall a. Ord a => Group a -> a
maximum :: forall a. Ord a => Group a -> a
$cminimum :: forall a. Ord a => Group a -> a
minimum :: forall a. Ord a => Group a -> a
$csum :: forall a. Num a => Group a -> a
sum :: forall a. Num a => Group a -> a
$cproduct :: forall a. Num a => Group a -> a
product :: forall a. Num a => Group a -> a
Foldable,Functor Group
Foldable Group
(Functor Group, Foldable Group) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> Group a -> f (Group b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Group (f a) -> f (Group a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Group a -> m (Group b))
-> (forall (m :: * -> *) a. Monad m => Group (m a) -> m (Group a))
-> Traversable Group
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Group (m a) -> m (Group a)
forall (f :: * -> *) a. Applicative f => Group (f a) -> f (Group a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Group a -> m (Group b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Group a -> f (Group b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Group a -> f (Group b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Group a -> f (Group b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Group (f a) -> f (Group a)
sequenceA :: forall (f :: * -> *) a. Applicative f => Group (f a) -> f (Group a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Group a -> m (Group b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Group a -> m (Group b)
$csequence :: forall (m :: * -> *) a. Monad m => Group (m a) -> m (Group a)
sequence :: forall (m :: * -> *) a. Monad m => Group (m a) -> m (Group a)
Traversable,(forall x. Group r -> Rep (Group r) x)
-> (forall x. Rep (Group r) x -> Group r) -> Generic (Group r)
forall x. Rep (Group r) x -> Group r
forall x. Group r -> Rep (Group r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (Group r) x -> Group r
forall r x. Group r -> Rep (Group r) x
$cfrom :: forall r x. Group r -> Rep (Group r) x
from :: forall x. Group r -> Rep (Group r) x
$cto :: forall r x. Rep (Group r) x -> Group r
to :: forall x. Rep (Group r) x -> Group r
Generic)

type instance NumType   (Group r) = r
type instance Dimension (Group r) = 2

instance (Fractional r, Eq r) => IsTransformable (IpeObject r) where
  transformBy :: Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
-> IpeObject r -> IpeObject r
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpeGroup IpeObject' Group r
i)     = IpeObject' Group r -> IpeObject r
forall r. IpeObject' Group r -> IpeObject r
IpeGroup     (IpeObject' Group r -> IpeObject r)
-> IpeObject' Group r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ Group r :+ GroupAttributes r
IpeObject' Group r
i(Group r :+ GroupAttributes r)
-> ((Group r :+ GroupAttributes r) -> IpeObject' Group r)
-> IpeObject' Group r
forall a b. a -> (a -> b) -> b
&(Group r -> Identity (Group r))
-> (Group r :+ GroupAttributes r)
-> Identity (Group r :+ GroupAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((Group r -> Identity (Group r))
 -> (Group r :+ GroupAttributes r)
 -> Identity (Group r :+ GroupAttributes r))
-> (Group r -> Group r)
-> (Group r :+ GroupAttributes r)
-> Group r :+ GroupAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (Group r)) (NumType (Group r))
-> Group r -> Group r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (Group r)) (NumType (Group r))
t
  transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpeImage IpeObject' Image r
i)     = IpeObject' Image r -> IpeObject r
forall r. IpeObject' Image r -> IpeObject r
IpeImage     (IpeObject' Image r -> IpeObject r)
-> IpeObject' Image r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ Image r :+ ImageAttributes r
IpeObject' Image r
i(Image r :+ ImageAttributes r)
-> ((Image r :+ ImageAttributes r) -> IpeObject' Image r)
-> IpeObject' Image r
forall a b. a -> (a -> b) -> b
&(Image r -> Identity (Image r))
-> (Image r :+ ImageAttributes r)
-> Identity (Image r :+ ImageAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((Image r -> Identity (Image r))
 -> (Image r :+ ImageAttributes r)
 -> Identity (Image r :+ ImageAttributes r))
-> (Image r -> Image r)
-> (Image r :+ ImageAttributes r)
-> Image r :+ ImageAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (Image r)) (NumType (Image r))
-> Image r -> Image r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (Image r)) (NumType (Image r))
t
  transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpeTextLabel IpeObject' TextLabel r
i) = IpeObject' TextLabel r -> IpeObject r
forall r. IpeObject' TextLabel r -> IpeObject r
IpeTextLabel (IpeObject' TextLabel r -> IpeObject r)
-> IpeObject' TextLabel r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ TextLabel r :+ TextAttributes r
IpeObject' TextLabel r
i(TextLabel r :+ TextAttributes r)
-> ((TextLabel r :+ TextAttributes r) -> IpeObject' TextLabel r)
-> IpeObject' TextLabel r
forall a b. a -> (a -> b) -> b
&(TextLabel r -> Identity (TextLabel r))
-> (TextLabel r :+ TextAttributes r)
-> Identity (TextLabel r :+ TextAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((TextLabel r -> Identity (TextLabel r))
 -> (TextLabel r :+ TextAttributes r)
 -> Identity (TextLabel r :+ TextAttributes r))
-> (TextLabel r -> TextLabel r)
-> (TextLabel r :+ TextAttributes r)
-> TextLabel r :+ TextAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (TextLabel r)) (NumType (TextLabel r))
-> TextLabel r -> TextLabel r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (TextLabel r)) (NumType (TextLabel r))
t
  transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpeMiniPage IpeObject' MiniPage r
i)  = IpeObject' MiniPage r -> IpeObject r
forall r. IpeObject' MiniPage r -> IpeObject r
IpeMiniPage  (IpeObject' MiniPage r -> IpeObject r)
-> IpeObject' MiniPage r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ MiniPage r :+ TextAttributes r
IpeObject' MiniPage r
i(MiniPage r :+ TextAttributes r)
-> ((MiniPage r :+ TextAttributes r) -> IpeObject' MiniPage r)
-> IpeObject' MiniPage r
forall a b. a -> (a -> b) -> b
&(MiniPage r -> Identity (MiniPage r))
-> (MiniPage r :+ TextAttributes r)
-> Identity (MiniPage r :+ TextAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((MiniPage r -> Identity (MiniPage r))
 -> (MiniPage r :+ TextAttributes r)
 -> Identity (MiniPage r :+ TextAttributes r))
-> (MiniPage r -> MiniPage r)
-> (MiniPage r :+ TextAttributes r)
-> MiniPage r :+ TextAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (MiniPage r)) (NumType (MiniPage r))
-> MiniPage r -> MiniPage r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (MiniPage r)) (NumType (MiniPage r))
t
  transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpeUse IpeObject' IpeSymbol r
i)       = IpeObject' IpeSymbol r -> IpeObject r
forall r. IpeObject' IpeSymbol r -> IpeObject r
IpeUse       (IpeObject' IpeSymbol r -> IpeObject r)
-> IpeObject' IpeSymbol r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ IpeSymbol r :+ SymbolAttributes r
IpeObject' IpeSymbol r
i(IpeSymbol r :+ SymbolAttributes r)
-> ((IpeSymbol r :+ SymbolAttributes r) -> IpeObject' IpeSymbol r)
-> IpeObject' IpeSymbol r
forall a b. a -> (a -> b) -> b
&(IpeSymbol r -> Identity (IpeSymbol r))
-> (IpeSymbol r :+ SymbolAttributes r)
-> Identity (IpeSymbol r :+ SymbolAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((IpeSymbol r -> Identity (IpeSymbol r))
 -> (IpeSymbol r :+ SymbolAttributes r)
 -> Identity (IpeSymbol r :+ SymbolAttributes r))
-> (IpeSymbol r -> IpeSymbol r)
-> (IpeSymbol r :+ SymbolAttributes r)
-> IpeSymbol r :+ SymbolAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (IpeSymbol r)) (NumType (IpeSymbol r))
-> IpeSymbol r -> IpeSymbol r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (IpeSymbol r)) (NumType (IpeSymbol r))
t
  transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t (IpePath IpeObject' Path r
i)      = IpeObject' Path r -> IpeObject r
forall r. IpeObject' Path r -> IpeObject r
IpePath      (IpeObject' Path r -> IpeObject r)
-> IpeObject' Path r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ Path r :+ PathAttributes r
IpeObject' Path r
i(Path r :+ PathAttributes r)
-> ((Path r :+ PathAttributes r) -> IpeObject' Path r)
-> IpeObject' Path r
forall a b. a -> (a -> b) -> b
&(Path r -> Identity (Path r))
-> (Path r :+ PathAttributes r)
-> Identity (Path r :+ PathAttributes r)
forall core extra core' (f :: * -> *).
Functor f =>
(core -> f core') -> (core :+ extra) -> f (core' :+ extra)
core ((Path r -> Identity (Path r))
 -> (Path r :+ PathAttributes r)
 -> Identity (Path r :+ PathAttributes r))
-> (Path r -> Path r)
-> (Path r :+ PathAttributes r)
-> Path r :+ PathAttributes r
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Transformation (Dimension (Path r)) (NumType (Path r))
-> Path r -> Path r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (Path r)) (NumType (Path r))
Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
t

instance (Fractional r, Eq r) => IsTransformable (Group r) where
  transformBy :: Transformation (Dimension (Group r)) (NumType (Group r))
-> Group r -> Group r
transformBy Transformation (Dimension (Group r)) (NumType (Group r))
t (Group [IpeObject r]
s) = [IpeObject r] -> Group r
forall r. [IpeObject r] -> Group r
Group ([IpeObject r] -> Group r) -> [IpeObject r] -> Group r
forall a b. (a -> b) -> a -> b
$ (IpeObject r -> IpeObject r) -> [IpeObject r] -> [IpeObject r]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
-> IpeObject r -> IpeObject r
forall g.
IsTransformable g =>
Transformation (Dimension g) (NumType g) -> g -> g
transformBy Transformation (Dimension (IpeObject r)) (NumType (IpeObject r))
Transformation (Dimension (Group r)) (NumType (Group r))
t) [IpeObject r]
s

type family IpeAttributes (g :: Type -> Type) (r :: Type) :: Type where
  IpeAttributes Group     r = GroupAttributes r
  IpeAttributes Image     r = ImageAttributes r
  IpeAttributes TextLabel r = TextAttributes r
  IpeAttributes MiniPage  r = TextAttributes r
  IpeAttributes Path      r = PathAttributes r
  IpeAttributes IpeSymbol r = SymbolAttributes r


-- | An IpeObject' is essentially the oject ogether with its attributes
type IpeObject' g r = g r :+ IpeAttributes g r


data IpeObject r =
    IpeGroup     (IpeObject' Group     r)
  | IpeImage     (IpeObject' Image     r)
  | IpeTextLabel (IpeObject' TextLabel r)
  | IpeMiniPage  (IpeObject' MiniPage  r)
  | IpeUse       (IpeObject' IpeSymbol r)
  | IpePath      (IpeObject' Path      r)
  deriving ((forall x. IpeObject r -> Rep (IpeObject r) x)
-> (forall x. Rep (IpeObject r) x -> IpeObject r)
-> Generic (IpeObject r)
forall x. Rep (IpeObject r) x -> IpeObject r
forall x. IpeObject r -> Rep (IpeObject r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall r x. Rep (IpeObject r) x -> IpeObject r
forall r x. IpeObject r -> Rep (IpeObject r) x
$cfrom :: forall r x. IpeObject r -> Rep (IpeObject r) x
from :: forall x. IpeObject r -> Rep (IpeObject r) x
$cto :: forall r x. Rep (IpeObject r) x -> IpeObject r
to :: forall x. Rep (IpeObject r) x -> IpeObject r
Generic)

instance Functor IpeObject where
  fmap :: forall a b. (a -> b) -> IpeObject a -> IpeObject b
fmap = (a -> b) -> IpeObject a -> IpeObject b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault
instance Foldable IpeObject where
  foldMap :: forall m a. Monoid m => (a -> m) -> IpeObject a -> m
foldMap = (a -> m) -> IpeObject a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault
instance Traversable IpeObject where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IpeObject a -> f (IpeObject b)
traverse a -> f b
f = \case
    IpeGroup IpeObject' Group a
g     -> (Group b :+ GroupAttributes b) -> IpeObject b
IpeObject' Group b -> IpeObject b
forall r. IpeObject' Group r -> IpeObject r
IpeGroup     ((Group b :+ GroupAttributes b) -> IpeObject b)
-> f (Group b :+ GroupAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Group a -> f (Group b))
-> (GroupAttributesF a Maybe -> f (GroupAttributes b))
-> (Group a :+ GroupAttributesF a Maybe)
-> f (Group b :+ GroupAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> Group a -> f (Group 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) -> Group a -> f (Group b)
traverse a -> f b
f) ((a -> f b) -> GroupAttributesF a Maybe -> f (GroupAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> GroupAttributesF r f -> g (GroupAttributesF s f)
traverseGroup a -> f b
f) Group a :+ GroupAttributesF a Maybe
IpeObject' Group a
g
    IpeImage IpeObject' Image a
i     -> (Image b :+ ImageAttributes b) -> IpeObject b
IpeObject' Image b -> IpeObject b
forall r. IpeObject' Image r -> IpeObject r
IpeImage     ((Image b :+ ImageAttributes b) -> IpeObject b)
-> f (Image b :+ ImageAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image a -> f (Image b))
-> (CommonAttributes a Maybe -> f (ImageAttributes b))
-> (Image a :+ CommonAttributes a Maybe)
-> f (Image b :+ ImageAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> Image a -> f (Image 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) -> Image a -> f (Image b)
traverse a -> f b
f) ((a -> f b) -> CommonAttributes a Maybe -> f (ImageAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> CommonAttributes r f -> g (CommonAttributes s f)
traverseCommon a -> f b
f) Image a :+ CommonAttributes a Maybe
IpeObject' Image a
i
    IpeTextLabel IpeObject' TextLabel a
l -> (TextLabel b :+ TextAttributes b) -> IpeObject b
IpeObject' TextLabel b -> IpeObject b
forall r. IpeObject' TextLabel r -> IpeObject r
IpeTextLabel ((TextLabel b :+ TextAttributes b) -> IpeObject b)
-> f (TextLabel b :+ TextAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TextLabel a -> f (TextLabel b))
-> (TextAttributesF a Maybe -> f (TextAttributes b))
-> (TextLabel a :+ TextAttributesF a Maybe)
-> f (TextLabel b :+ TextAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> TextLabel a -> f (TextLabel 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) -> TextLabel a -> f (TextLabel b)
traverse a -> f b
f) ((a -> f b) -> TextAttributesF a Maybe -> f (TextAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> TextAttributesF r f -> g (TextAttributesF s f)
traverseText a -> f b
f) TextLabel a :+ TextAttributesF a Maybe
IpeObject' TextLabel a
l
    IpeMiniPage IpeObject' MiniPage a
p  -> (MiniPage b :+ TextAttributes b) -> IpeObject b
IpeObject' MiniPage b -> IpeObject b
forall r. IpeObject' MiniPage r -> IpeObject r
IpeMiniPage  ((MiniPage b :+ TextAttributes b) -> IpeObject b)
-> f (MiniPage b :+ TextAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MiniPage a -> f (MiniPage b))
-> (TextAttributesF a Maybe -> f (TextAttributes b))
-> (MiniPage a :+ TextAttributesF a Maybe)
-> f (MiniPage b :+ TextAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> MiniPage a -> f (MiniPage 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) -> MiniPage a -> f (MiniPage b)
traverse a -> f b
f) ((a -> f b) -> TextAttributesF a Maybe -> f (TextAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> TextAttributesF r f -> g (TextAttributesF s f)
traverseText a -> f b
f) MiniPage a :+ TextAttributesF a Maybe
IpeObject' MiniPage a
p
    IpeUse IpeObject' IpeSymbol a
u       -> (IpeSymbol b :+ SymbolAttributes b) -> IpeObject b
IpeObject' IpeSymbol b -> IpeObject b
forall r. IpeObject' IpeSymbol r -> IpeObject r
IpeUse       ((IpeSymbol b :+ SymbolAttributes b) -> IpeObject b)
-> f (IpeSymbol b :+ SymbolAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (IpeSymbol a -> f (IpeSymbol b))
-> (SymbolAttributesF a Maybe -> f (SymbolAttributes b))
-> (IpeSymbol a :+ SymbolAttributesF a Maybe)
-> f (IpeSymbol b :+ SymbolAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> IpeSymbol a -> f (IpeSymbol 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) -> IpeSymbol a -> f (IpeSymbol b)
traverse a -> f b
f) ((a -> f b) -> SymbolAttributesF a Maybe -> f (SymbolAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> SymbolAttributesF r f -> g (SymbolAttributesF s f)
traverseSymbol a -> f b
f) IpeSymbol a :+ SymbolAttributesF a Maybe
IpeObject' IpeSymbol a
u
    IpePath IpeObject' Path a
p      -> (Path b :+ PathAttributes b) -> IpeObject b
IpeObject' Path b -> IpeObject b
forall r. IpeObject' Path r -> IpeObject r
IpePath      ((Path b :+ PathAttributes b) -> IpeObject b)
-> f (Path b :+ PathAttributes b) -> f (IpeObject b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Path a -> f (Path b))
-> (PathAttributesF a Maybe -> f (PathAttributes b))
-> (Path a :+ PathAttributesF a Maybe)
-> f (Path b :+ PathAttributes b)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :+ b) -> f (c :+ d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse ((a -> f b) -> Path a -> f (Path 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) -> Path a -> f (Path b)
traverse a -> f b
f) ((a -> f b) -> PathAttributesF a Maybe -> f (PathAttributes b)
forall (g :: * -> *) (f :: * -> *) r s.
(Applicative g, Traversable f) =>
(r -> g s) -> PathAttributesF r f -> g (PathAttributesF s f)
traversePath a -> f b
f) Path a :+ PathAttributesF a Maybe
IpeObject' Path a
p


deriving instance (Show r) => Show (IpeObject r)
-- deriving instance (Read r) => Read (IpeObject r)
deriving instance (Eq r)   => Eq   (IpeObject r)

type instance NumType   (IpeObject r) = r
type instance Dimension (IpeObject r) = 2

makePrisms ''IpeObject

groupItems :: Lens (Group r) (Group s) [IpeObject r] [IpeObject s]
groupItems :: forall r s (f :: * -> *).
Functor f =>
([IpeObject r] -> f [IpeObject s]) -> Group r -> f (Group s)
groupItems = (Group r -> [IpeObject r])
-> (Group r -> [IpeObject s] -> Group s)
-> Lens (Group r) (Group s) [IpeObject r] [IpeObject s]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(Group [IpeObject r]
xs) -> [IpeObject r]
xs) (([IpeObject s] -> Group s) -> Group r -> [IpeObject s] -> Group s
forall a b. a -> b -> a
const [IpeObject s] -> Group s
forall r. [IpeObject r] -> Group r
Group)

class ToObject i where
  _IpeObject  :: Prism' (IpeObject r) (i r :+ IpeAttributes i r)

  mkIpeObject :: IpeObject' i r -> IpeObject r
  mkIpeObject = AReview (IpeObject r) (i r :+ IpeAttributes i r)
-> (i r :+ IpeAttributes i r) -> IpeObject r
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview (IpeObject r) (i r :+ IpeAttributes i r)
forall r. Prism' (IpeObject r) (i r :+ IpeAttributes i r)
forall (i :: * -> *) r.
ToObject i =>
Prism' (IpeObject r) (i r :+ IpeAttributes i r)
_IpeObject

instance ToObject Group      where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Group r) (f (IpeObject' Group r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' Group r) (f (IpeObject' Group r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Group r) (f (IpeObject' Group r))
-> p (IpeObject r) (f (IpeObject r))
_IpeGroup
instance ToObject Image      where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Image r) (f (IpeObject' Image r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' Image r) (f (IpeObject' Image r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Image r) (f (IpeObject' Image r))
-> p (IpeObject r) (f (IpeObject r))
_IpeImage
instance ToObject TextLabel  where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' TextLabel r) (f (IpeObject' TextLabel r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' TextLabel r) (f (IpeObject' TextLabel r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' TextLabel r) (f (IpeObject' TextLabel r))
-> p (IpeObject r) (f (IpeObject r))
_IpeTextLabel
instance ToObject MiniPage   where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' MiniPage r) (f (IpeObject' MiniPage r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' MiniPage r) (f (IpeObject' MiniPage r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' MiniPage r) (f (IpeObject' MiniPage r))
-> p (IpeObject r) (f (IpeObject r))
_IpeMiniPage
instance ToObject IpeSymbol  where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' IpeSymbol r) (f (IpeObject' IpeSymbol r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' IpeSymbol r) (f (IpeObject' IpeSymbol r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' IpeSymbol r) (f (IpeObject' IpeSymbol r))
-> p (IpeObject r) (f (IpeObject r))
_IpeUse
instance ToObject Path       where _IpeObject :: forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Path r) (f (IpeObject' Path r))
-> p (IpeObject r) (f (IpeObject r))
_IpeObject = p (IpeObject' Path r) (f (IpeObject' Path r))
-> p (IpeObject r) (f (IpeObject r))
forall r (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (IpeObject' Path r) (f (IpeObject' Path r))
-> p (IpeObject r) (f (IpeObject r))
_IpePath


-- | Shorthand for constructing ipeObjects
ipeObject'     :: ToObject i => i r -> IpeAttributes i r -> IpeObject r
ipeObject' :: forall (i :: * -> *) r.
ToObject i =>
i r -> IpeAttributes i r -> IpeObject r
ipeObject' i r
i IpeAttributes i r
a = AReview (IpeObject r) (i r :+ IpeAttributes i r)
-> (i r :+ IpeAttributes i r) -> IpeObject r
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview (IpeObject r) (i r :+ IpeAttributes i r)
forall r. Prism' (IpeObject r) (i r :+ IpeAttributes i r)
forall (i :: * -> *) r.
ToObject i =>
Prism' (IpeObject r) (i r :+ IpeAttributes i r)
_IpeObject ((i r :+ IpeAttributes i r) -> IpeObject r)
-> (i r :+ IpeAttributes i r) -> IpeObject r
forall a b. (a -> b) -> a -> b
$ i r
i i r -> IpeAttributes i r -> i r :+ IpeAttributes i r
forall core extra. core -> extra -> core :+ extra
:+ IpeAttributes i r
a


-- Applicative f => (ipeAttributes i r -> f (IpeAttributes i r :+ ats))
--            -> IpeObject r -> f (IpeObject r)
 -- s s a a

-- | Access the attributes
attributes :: Lens' (IpeObject' i r) (IpeAttributes i r)
attributes :: forall (i :: * -> *) r (f :: * -> *).
Functor f =>
(IpeAttributes i r -> f (IpeAttributes i r))
-> IpeObject' i r -> f (IpeObject' i r)
attributes = (IpeAttributes i r -> f (IpeAttributes i r))
-> (i r :+ IpeAttributes i r) -> f (i r :+ IpeAttributes i r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra

-- | Access the attributes
instance HasCommonAttributes (IpeObject r) r Maybe where
-- commonAttributes'      :: Lens' (IpeObject r) (CommonAttributes r Maybe)
  commonAttributes :: Lens' (IpeObject r) (CommonAttributes r Maybe)
commonAttributes CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts = \case
    IpeGroup IpeObject' Group r
g     -> (Group r :+ GroupAttributes r) -> IpeObject r
IpeObject' Group r -> IpeObject r
forall r. IpeObject' Group r -> IpeObject r
IpeGroup     ((Group r :+ GroupAttributes r) -> IpeObject r)
-> f (Group r :+ GroupAttributes r) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((GroupAttributes r -> f (GroupAttributes r))
-> (Group r :+ GroupAttributes r)
-> f (Group r :+ GroupAttributes r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((GroupAttributes r -> f (GroupAttributes r))
 -> (Group r :+ GroupAttributes r)
 -> f (Group r :+ GroupAttributes r))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> GroupAttributes r -> f (GroupAttributes r))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (Group r :+ GroupAttributes r)
-> f (Group r :+ GroupAttributes r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> GroupAttributes r -> f (GroupAttributes r)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (GroupAttributes r) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts Group r :+ GroupAttributes r
IpeObject' Group r
g
    IpeImage IpeObject' Image r
i     -> (Image r :+ CommonAttributes r Maybe) -> IpeObject r
IpeObject' Image r -> IpeObject r
forall r. IpeObject' Image r -> IpeObject r
IpeImage     ((Image r :+ CommonAttributes r Maybe) -> IpeObject r)
-> f (Image r :+ CommonAttributes r Maybe) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (Image r :+ CommonAttributes r Maybe)
-> f (Image r :+ CommonAttributes r Maybe)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
 -> (Image r :+ CommonAttributes r Maybe)
 -> f (Image r :+ CommonAttributes r Maybe))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (Image r :+ CommonAttributes r Maybe)
-> f (Image r :+ CommonAttributes r Maybe)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (CommonAttributes r Maybe) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts Image r :+ CommonAttributes r Maybe
IpeObject' Image r
i
    IpeTextLabel IpeObject' TextLabel r
l -> (TextLabel r :+ TextAttributes r) -> IpeObject r
IpeObject' TextLabel r -> IpeObject r
forall r. IpeObject' TextLabel r -> IpeObject r
IpeTextLabel ((TextLabel r :+ TextAttributes r) -> IpeObject r)
-> f (TextLabel r :+ TextAttributes r) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((TextAttributes r -> f (TextAttributes r))
-> (TextLabel r :+ TextAttributes r)
-> f (TextLabel r :+ TextAttributes r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((TextAttributes r -> f (TextAttributes r))
 -> (TextLabel r :+ TextAttributes r)
 -> f (TextLabel r :+ TextAttributes r))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> TextAttributes r -> f (TextAttributes r))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (TextLabel r :+ TextAttributes r)
-> f (TextLabel r :+ TextAttributes r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> TextAttributes r -> f (TextAttributes r)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (TextAttributes r) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts TextLabel r :+ TextAttributes r
IpeObject' TextLabel r
l
    IpeMiniPage IpeObject' MiniPage r
p  -> (MiniPage r :+ TextAttributes r) -> IpeObject r
IpeObject' MiniPage r -> IpeObject r
forall r. IpeObject' MiniPage r -> IpeObject r
IpeMiniPage  ((MiniPage r :+ TextAttributes r) -> IpeObject r)
-> f (MiniPage r :+ TextAttributes r) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((TextAttributes r -> f (TextAttributes r))
-> (MiniPage r :+ TextAttributes r)
-> f (MiniPage r :+ TextAttributes r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((TextAttributes r -> f (TextAttributes r))
 -> (MiniPage r :+ TextAttributes r)
 -> f (MiniPage r :+ TextAttributes r))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> TextAttributes r -> f (TextAttributes r))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (MiniPage r :+ TextAttributes r)
-> f (MiniPage r :+ TextAttributes r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> TextAttributes r -> f (TextAttributes r)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (TextAttributes r) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts MiniPage r :+ TextAttributes r
IpeObject' MiniPage r
p
    IpeUse IpeObject' IpeSymbol r
u       -> (IpeSymbol r :+ SymbolAttributes r) -> IpeObject r
IpeObject' IpeSymbol r -> IpeObject r
forall r. IpeObject' IpeSymbol r -> IpeObject r
IpeUse       ((IpeSymbol r :+ SymbolAttributes r) -> IpeObject r)
-> f (IpeSymbol r :+ SymbolAttributes r) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((SymbolAttributes r -> f (SymbolAttributes r))
-> (IpeSymbol r :+ SymbolAttributes r)
-> f (IpeSymbol r :+ SymbolAttributes r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((SymbolAttributes r -> f (SymbolAttributes r))
 -> (IpeSymbol r :+ SymbolAttributes r)
 -> f (IpeSymbol r :+ SymbolAttributes r))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> SymbolAttributes r -> f (SymbolAttributes r))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (IpeSymbol r :+ SymbolAttributes r)
-> f (IpeSymbol r :+ SymbolAttributes r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> SymbolAttributes r -> f (SymbolAttributes r)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (SymbolAttributes r) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts IpeSymbol r :+ SymbolAttributes r
IpeObject' IpeSymbol r
u
    IpePath IpeObject' Path r
p      -> (Path r :+ PathAttributes r) -> IpeObject r
IpeObject' Path r -> IpeObject r
forall r. IpeObject' Path r -> IpeObject r
IpePath      ((Path r :+ PathAttributes r) -> IpeObject r)
-> f (Path r :+ PathAttributes r) -> f (IpeObject r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PathAttributes r -> f (PathAttributes r))
-> (Path r :+ PathAttributes r) -> f (Path r :+ PathAttributes r)
forall core extra extra' (f :: * -> *).
Functor f =>
(extra -> f extra') -> (core :+ extra) -> f (core :+ extra')
extra((PathAttributes r -> f (PathAttributes r))
 -> (Path r :+ PathAttributes r) -> f (Path r :+ PathAttributes r))
-> ((CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
    -> PathAttributes r -> f (PathAttributes r))
-> (CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> (Path r :+ PathAttributes r)
-> f (Path r :+ PathAttributes r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(CommonAttributes r Maybe -> f (CommonAttributes r Maybe))
-> PathAttributes r -> f (PathAttributes r)
forall c r (f :: * -> *).
HasCommonAttributes c r f =>
Lens' c (CommonAttributes r f)
Lens' (PathAttributes r) (CommonAttributes r Maybe)
commonAttributes) CommonAttributes r Maybe -> f (CommonAttributes r Maybe)
fAts Path r :+ PathAttributes r
IpeObject' Path r
p




  -- _IpeObject @i.extra


-- | collect all non-group objects
flattenGroups :: [IpeObject r] -> [IpeObject r]
flattenGroups :: forall r. [IpeObject r] -> [IpeObject r]
flattenGroups = (IpeObject r -> [IpeObject r]) -> [IpeObject r] -> [IpeObject r]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap IpeObject r -> [IpeObject r]
forall r. IpeObject r -> [IpeObject r]
flattenGroups'
  where
    flattenGroups'                              :: IpeObject r -> [IpeObject r]
    flattenGroups' :: forall r. IpeObject r -> [IpeObject r]
flattenGroups' (IpeGroup (Group [IpeObject r]
gs :+ IpeAttributes Group r
ats)) =
      (IpeObject r -> IpeObject r) -> [IpeObject r] -> [IpeObject r]
forall a b. (a -> b) -> [a] -> [b]
map (GroupAttributes r -> IpeObject r -> IpeObject r
forall {p} {a}. p -> a -> a
applyAts GroupAttributes r
IpeAttributes Group r
ats) ([IpeObject r] -> [IpeObject r])
-> ([IpeObject r] -> [IpeObject r])
-> [IpeObject r]
-> [IpeObject r]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IpeObject r -> [IpeObject r]) -> [IpeObject r] -> [IpeObject r]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap IpeObject r -> [IpeObject r]
forall r. IpeObject r -> [IpeObject r]
flattenGroups' ([IpeObject r] -> [IpeObject r]) -> [IpeObject r] -> [IpeObject r]
forall a b. (a -> b) -> a -> b
$ [IpeObject r]
gs
        where
          applyAts :: p -> a -> a
applyAts p
_ = a -> a
forall a. a -> a
id
    flattenGroups' IpeObject r
o                            = [IpeObject r
o]


--------------------------------------------------------------------------------