{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.Location.Types.Leg where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types.LegGeometry
import Amazonka.Location.Types.Step
import qualified Amazonka.Prelude as Prelude
data Leg = Leg'
{
Leg -> Maybe LegGeometry
geometry :: Prelude.Maybe LegGeometry,
Leg -> Double
distance :: Prelude.Double,
Leg -> Double
durationSeconds :: Prelude.Double,
Leg -> Sensitive (NonEmpty Double)
endPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double),
Leg -> Sensitive (NonEmpty Double)
startPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double),
Leg -> [Step]
steps :: [Step]
}
deriving (Leg -> Leg -> Bool
(Leg -> Leg -> Bool) -> (Leg -> Leg -> Bool) -> Eq Leg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Leg -> Leg -> Bool
$c/= :: Leg -> Leg -> Bool
== :: Leg -> Leg -> Bool
$c== :: Leg -> Leg -> Bool
Prelude.Eq, Int -> Leg -> ShowS
[Leg] -> ShowS
Leg -> String
(Int -> Leg -> ShowS)
-> (Leg -> String) -> ([Leg] -> ShowS) -> Show Leg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Leg] -> ShowS
$cshowList :: [Leg] -> ShowS
show :: Leg -> String
$cshow :: Leg -> String
showsPrec :: Int -> Leg -> ShowS
$cshowsPrec :: Int -> Leg -> ShowS
Prelude.Show, (forall x. Leg -> Rep Leg x)
-> (forall x. Rep Leg x -> Leg) -> Generic Leg
forall x. Rep Leg x -> Leg
forall x. Leg -> Rep Leg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Leg x -> Leg
$cfrom :: forall x. Leg -> Rep Leg x
Prelude.Generic)
newLeg ::
Prelude.Double ->
Prelude.Double ->
Prelude.NonEmpty Prelude.Double ->
Prelude.NonEmpty Prelude.Double ->
Leg
newLeg :: Double -> Double -> NonEmpty Double -> NonEmpty Double -> Leg
newLeg
Double
pDistance_
Double
pDurationSeconds_
NonEmpty Double
pEndPosition_
NonEmpty Double
pStartPosition_ =
Leg' :: Maybe LegGeometry
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg
Leg'
{ $sel:geometry:Leg' :: Maybe LegGeometry
geometry = Maybe LegGeometry
forall a. Maybe a
Prelude.Nothing,
$sel:distance:Leg' :: Double
distance = Double
pDistance_,
$sel:durationSeconds:Leg' :: Double
durationSeconds = Double
pDurationSeconds_,
$sel:endPosition:Leg' :: Sensitive (NonEmpty Double)
endPosition =
Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
(Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pEndPosition_,
$sel:startPosition:Leg' :: Sensitive (NonEmpty Double)
startPosition =
Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
(Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
(Sensitive (NonEmpty Double))
(Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pStartPosition_,
$sel:steps:Leg' :: [Step]
steps = [Step]
forall a. Monoid a => a
Prelude.mempty
}
leg_geometry :: Lens.Lens' Leg (Prelude.Maybe LegGeometry)
leg_geometry :: (Maybe LegGeometry -> f (Maybe LegGeometry)) -> Leg -> f Leg
leg_geometry = (Leg -> Maybe LegGeometry)
-> (Leg -> Maybe LegGeometry -> Leg)
-> Lens Leg Leg (Maybe LegGeometry) (Maybe LegGeometry)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Maybe LegGeometry
geometry :: Maybe LegGeometry
$sel:geometry:Leg' :: Leg -> Maybe LegGeometry
geometry} -> Maybe LegGeometry
geometry) (\s :: Leg
s@Leg' {} Maybe LegGeometry
a -> Leg
s {$sel:geometry:Leg' :: Maybe LegGeometry
geometry = Maybe LegGeometry
a} :: Leg)
leg_distance :: Lens.Lens' Leg Prelude.Double
leg_distance :: (Double -> f Double) -> Leg -> f Leg
leg_distance = (Leg -> Double)
-> (Leg -> Double -> Leg) -> Lens Leg Leg Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Double
distance :: Double
$sel:distance:Leg' :: Leg -> Double
distance} -> Double
distance) (\s :: Leg
s@Leg' {} Double
a -> Leg
s {$sel:distance:Leg' :: Double
distance = Double
a} :: Leg)
leg_durationSeconds :: Lens.Lens' Leg Prelude.Double
leg_durationSeconds :: (Double -> f Double) -> Leg -> f Leg
leg_durationSeconds = (Leg -> Double)
-> (Leg -> Double -> Leg) -> Lens Leg Leg Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Double
durationSeconds :: Double
$sel:durationSeconds:Leg' :: Leg -> Double
durationSeconds} -> Double
durationSeconds) (\s :: Leg
s@Leg' {} Double
a -> Leg
s {$sel:durationSeconds:Leg' :: Double
durationSeconds = Double
a} :: Leg)
leg_endPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double)
leg_endPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg
leg_endPosition = (Leg -> Sensitive (NonEmpty Double))
-> (Leg -> Sensitive (NonEmpty Double) -> Leg)
-> Lens
Leg Leg (Sensitive (NonEmpty Double)) (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Sensitive (NonEmpty Double)
endPosition :: Sensitive (NonEmpty Double)
$sel:endPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
endPosition} -> Sensitive (NonEmpty Double)
endPosition) (\s :: Leg
s@Leg' {} Sensitive (NonEmpty Double)
a -> Leg
s {$sel:endPosition:Leg' :: Sensitive (NonEmpty Double)
endPosition = Sensitive (NonEmpty Double)
a} :: Leg) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> Leg -> f Leg)
-> ((NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Leg
-> f Leg
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
leg_startPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double)
leg_startPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg
leg_startPosition = (Leg -> Sensitive (NonEmpty Double))
-> (Leg -> Sensitive (NonEmpty Double) -> Leg)
-> Lens
Leg Leg (Sensitive (NonEmpty Double)) (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Sensitive (NonEmpty Double)
startPosition :: Sensitive (NonEmpty Double)
$sel:startPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
startPosition} -> Sensitive (NonEmpty Double)
startPosition) (\s :: Leg
s@Leg' {} Sensitive (NonEmpty Double)
a -> Leg
s {$sel:startPosition:Leg' :: Sensitive (NonEmpty Double)
startPosition = Sensitive (NonEmpty Double)
a} :: Leg) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> Leg -> f Leg)
-> ((NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Leg
-> f Leg
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
leg_steps :: Lens.Lens' Leg [Step]
leg_steps :: ([Step] -> f [Step]) -> Leg -> f Leg
leg_steps = (Leg -> [Step])
-> (Leg -> [Step] -> Leg) -> Lens Leg Leg [Step] [Step]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {[Step]
steps :: [Step]
$sel:steps:Leg' :: Leg -> [Step]
steps} -> [Step]
steps) (\s :: Leg
s@Leg' {} [Step]
a -> Leg
s {$sel:steps:Leg' :: [Step]
steps = [Step]
a} :: Leg) (([Step] -> f [Step]) -> Leg -> f Leg)
-> (([Step] -> f [Step]) -> [Step] -> f [Step])
-> ([Step] -> f [Step])
-> Leg
-> f Leg
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Step] -> f [Step]) -> [Step] -> f [Step]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON Leg where
parseJSON :: Value -> Parser Leg
parseJSON =
String -> (Object -> Parser Leg) -> Value -> Parser Leg
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Leg"
( \Object
x ->
Maybe LegGeometry
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg
Leg'
(Maybe LegGeometry
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg)
-> Parser (Maybe LegGeometry)
-> Parser
(Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LegGeometry)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Geometry")
Parser
(Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg)
-> Parser Double
-> Parser
(Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Distance")
Parser
(Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg)
-> Parser Double
-> Parser
(Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double) -> [Step] -> Leg)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DurationSeconds")
Parser
(Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double) -> [Step] -> Leg)
-> Parser (Sensitive (NonEmpty Double))
-> Parser (Sensitive (NonEmpty Double) -> [Step] -> Leg)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive (NonEmpty Double))
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EndPosition")
Parser (Sensitive (NonEmpty Double) -> [Step] -> Leg)
-> Parser (Sensitive (NonEmpty Double)) -> Parser ([Step] -> Leg)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive (NonEmpty Double))
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StartPosition")
Parser ([Step] -> Leg) -> Parser [Step] -> Parser Leg
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Step])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Steps" Parser (Maybe [Step]) -> [Step] -> Parser [Step]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Step]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Leg
instance Prelude.NFData Leg