{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
module Data.Aviation.C172.WB.C172AircraftArms(
C172AircraftArms(..)
, HasC172AircraftArms(..)
, bewC172AircraftArms
, zfwMoment
, ffwMoment
, ufwMoment
, totalC172Moment
) where
import Control.Applicative(Applicative((<*>), pure))
import Control.Category((.))
import Control.Lens(makeClassy, lens, (^.), (.~), (&))
import Data.Aviation.C172.WB.C172Arms(C172Arms, HasC172Arms(c172Arms), fuel, c172ArmsPOH)
import Data.Aviation.Units(Pounds(pounds))
import Data.Aviation.WB(ArmStatic)
import Data.Aviation.WB.Arm(Arm, HasArmStatic, staticArm)
import Data.Aviation.WB.Weight(HasWeight(weight))
import Data.Aviation.WB.Moment(Moment, momentX)
import Data.Eq(Eq)
import Data.Foldable(Foldable(foldr))
import Data.Functor(Functor(fmap), (<$>))
import Data.Ord(Ord)
import Data.Traversable(Traversable(traverse))
import Prelude(Show)
data C172AircraftArms a =
C172AircraftArms {
C172AircraftArms a -> a
_basicEmptyWeight ::
a
, C172AircraftArms a -> C172Arms a
c172Arms_ ::
C172Arms a
}
deriving (C172AircraftArms a -> C172AircraftArms a -> Bool
(C172AircraftArms a -> C172AircraftArms a -> Bool)
-> (C172AircraftArms a -> C172AircraftArms a -> Bool)
-> Eq (C172AircraftArms a)
forall a. Eq a => C172AircraftArms a -> C172AircraftArms a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c/= :: forall a. Eq a => C172AircraftArms a -> C172AircraftArms a -> Bool
== :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c== :: forall a. Eq a => C172AircraftArms a -> C172AircraftArms a -> Bool
Eq, Eq (C172AircraftArms a)
Eq (C172AircraftArms a)
-> (C172AircraftArms a -> C172AircraftArms a -> Ordering)
-> (C172AircraftArms a -> C172AircraftArms a -> Bool)
-> (C172AircraftArms a -> C172AircraftArms a -> Bool)
-> (C172AircraftArms a -> C172AircraftArms a -> Bool)
-> (C172AircraftArms a -> C172AircraftArms a -> Bool)
-> (C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a)
-> (C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a)
-> Ord (C172AircraftArms a)
C172AircraftArms a -> C172AircraftArms a -> Bool
C172AircraftArms a -> C172AircraftArms a -> Ordering
C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
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 a. Ord a => Eq (C172AircraftArms a)
forall a. Ord a => C172AircraftArms a -> C172AircraftArms a -> Bool
forall a.
Ord a =>
C172AircraftArms a -> C172AircraftArms a -> Ordering
forall a.
Ord a =>
C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
min :: C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
$cmin :: forall a.
Ord a =>
C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
max :: C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
$cmax :: forall a.
Ord a =>
C172AircraftArms a -> C172AircraftArms a -> C172AircraftArms a
>= :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c>= :: forall a. Ord a => C172AircraftArms a -> C172AircraftArms a -> Bool
> :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c> :: forall a. Ord a => C172AircraftArms a -> C172AircraftArms a -> Bool
<= :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c<= :: forall a. Ord a => C172AircraftArms a -> C172AircraftArms a -> Bool
< :: C172AircraftArms a -> C172AircraftArms a -> Bool
$c< :: forall a. Ord a => C172AircraftArms a -> C172AircraftArms a -> Bool
compare :: C172AircraftArms a -> C172AircraftArms a -> Ordering
$ccompare :: forall a.
Ord a =>
C172AircraftArms a -> C172AircraftArms a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (C172AircraftArms a)
Ord, Int -> C172AircraftArms a -> ShowS
[C172AircraftArms a] -> ShowS
C172AircraftArms a -> String
(Int -> C172AircraftArms a -> ShowS)
-> (C172AircraftArms a -> String)
-> ([C172AircraftArms a] -> ShowS)
-> Show (C172AircraftArms a)
forall a. Show a => Int -> C172AircraftArms a -> ShowS
forall a. Show a => [C172AircraftArms a] -> ShowS
forall a. Show a => C172AircraftArms a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [C172AircraftArms a] -> ShowS
$cshowList :: forall a. Show a => [C172AircraftArms a] -> ShowS
show :: C172AircraftArms a -> String
$cshow :: forall a. Show a => C172AircraftArms a -> String
showsPrec :: Int -> C172AircraftArms a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> C172AircraftArms a -> ShowS
Show)
makeClassy ''C172AircraftArms
instance HasC172Arms (C172AircraftArms a) a where
c172Arms :: (C172Arms a -> f (C172Arms a))
-> C172AircraftArms a -> f (C172AircraftArms a)
c172Arms =
(C172AircraftArms a -> C172Arms a)
-> (C172AircraftArms a -> C172Arms a -> C172AircraftArms a)
-> Lens' (C172AircraftArms a) (C172Arms a)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens
(\(C172AircraftArms a
_ C172Arms a
c) -> C172Arms a
c)
(\(C172AircraftArms a
c C172Arms a
_) C172Arms a
a -> a -> C172Arms a -> C172AircraftArms a
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms a
c C172Arms a
a)
instance Functor C172AircraftArms where
fmap :: (a -> b) -> C172AircraftArms a -> C172AircraftArms b
fmap a -> b
k (C172AircraftArms a
c C172Arms a
x) =
b -> C172Arms b -> C172AircraftArms b
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms (a -> b
k a
c) ((a -> b) -> C172Arms a -> C172Arms b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
k C172Arms a
x)
instance Applicative C172AircraftArms where
pure :: a -> C172AircraftArms a
pure a
a =
a -> C172Arms a -> C172AircraftArms a
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms a
a (a -> C172Arms a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a)
C172AircraftArms a -> b
c1 C172Arms (a -> b)
c2 <*> :: C172AircraftArms (a -> b)
-> C172AircraftArms a -> C172AircraftArms b
<*> C172AircraftArms a
x1 C172Arms a
x2 =
b -> C172Arms b -> C172AircraftArms b
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms (a -> b
c1 a
x1) (C172Arms (a -> b)
c2 C172Arms (a -> b) -> C172Arms a -> C172Arms b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> C172Arms a
x2)
instance Foldable C172AircraftArms where
foldr :: (a -> b -> b) -> b -> C172AircraftArms a -> b
foldr a -> b -> b
k b
z (C172AircraftArms a
c C172Arms a
x) =
a -> b -> b
k a
c ((a -> b -> b) -> b -> C172Arms a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
k b
z C172Arms a
x)
instance Traversable C172AircraftArms where
traverse :: (a -> f b) -> C172AircraftArms a -> f (C172AircraftArms b)
traverse a -> f b
k (C172AircraftArms a
c C172Arms a
x) =
b -> C172Arms b -> C172AircraftArms b
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms (b -> C172Arms b -> C172AircraftArms b)
-> f b -> f (C172Arms b -> C172AircraftArms b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
k a
c f (C172Arms b -> C172AircraftArms b)
-> f (C172Arms b) -> f (C172AircraftArms b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> f b) -> C172Arms a -> f (C172Arms b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
k C172Arms a
x
bewC172AircraftArms ::
ArmStatic
-> C172AircraftArms Arm
bewC172AircraftArms :: ArmStatic -> C172AircraftArms Arm
bewC172AircraftArms ArmStatic
a =
Arm -> C172Arms Arm -> C172AircraftArms Arm
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms
(ArmStatic -> Arm
staticArm ArmStatic
a)
C172Arms Arm
c172ArmsPOH
zfwMoment ::
C172AircraftArms Moment
-> C172AircraftArms Moment
zfwMoment :: C172AircraftArms Moment -> C172AircraftArms Moment
zfwMoment C172AircraftArms Moment
x =
C172AircraftArms Moment
x C172AircraftArms Moment
-> (C172AircraftArms Moment -> C172AircraftArms Moment)
-> C172AircraftArms Moment
forall a b. a -> (a -> b) -> b
& (Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment)
forall c a. HasC172Arms c a => Lens' c a
fuel ((Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> ((Weight -> Identity Weight) -> Moment -> Identity Moment)
-> (Weight -> Identity Weight)
-> C172AircraftArms Moment
-> Identity (C172AircraftArms Moment)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Weight -> Identity Weight) -> Moment -> Identity Moment
forall c. HasWeight c => Lens' c Weight
weight ((Weight -> Identity Weight)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> Weight -> C172AircraftArms Moment -> C172AircraftArms Moment
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Rational
0 Rational -> Getting Weight Rational Weight -> Weight
forall s a. s -> Getting a s a -> a
^. Getting Weight Rational Weight
forall a. Pounds a => Iso' Rational a
pounds
ffwMoment ::
C172AircraftArms Moment
-> C172AircraftArms Moment
ffwMoment :: C172AircraftArms Moment -> C172AircraftArms Moment
ffwMoment C172AircraftArms Moment
x =
C172AircraftArms Moment
x C172AircraftArms Moment
-> (C172AircraftArms Moment -> C172AircraftArms Moment)
-> C172AircraftArms Moment
forall a b. a -> (a -> b) -> b
& (Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment)
forall c a. HasC172Arms c a => Lens' c a
fuel ((Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> ((Weight -> Identity Weight) -> Moment -> Identity Moment)
-> (Weight -> Identity Weight)
-> C172AircraftArms Moment
-> Identity (C172AircraftArms Moment)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Weight -> Identity Weight) -> Moment -> Identity Moment
forall c. HasWeight c => Lens' c Weight
weight ((Weight -> Identity Weight)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> Weight -> C172AircraftArms Moment -> C172AircraftArms Moment
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Rational
336 Rational -> Getting Weight Rational Weight -> Weight
forall s a. s -> Getting a s a -> a
^. Getting Weight Rational Weight
forall a. Pounds a => Iso' Rational a
pounds
ufwMoment ::
C172AircraftArms Moment
-> C172AircraftArms Moment
ufwMoment :: C172AircraftArms Moment -> C172AircraftArms Moment
ufwMoment C172AircraftArms Moment
x =
C172AircraftArms Moment
x C172AircraftArms Moment
-> (C172AircraftArms Moment -> C172AircraftArms Moment)
-> C172AircraftArms Moment
forall a b. a -> (a -> b) -> b
& (Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment)
forall c a. HasC172Arms c a => Lens' c a
fuel ((Moment -> Identity Moment)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> ((Weight -> Identity Weight) -> Moment -> Identity Moment)
-> (Weight -> Identity Weight)
-> C172AircraftArms Moment
-> Identity (C172AircraftArms Moment)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Weight -> Identity Weight) -> Moment -> Identity Moment
forall c. HasWeight c => Lens' c Weight
weight ((Weight -> Identity Weight)
-> C172AircraftArms Moment -> Identity (C172AircraftArms Moment))
-> Weight -> C172AircraftArms Moment -> C172AircraftArms Moment
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Rational
18 Rational -> Getting Weight Rational Weight -> Weight
forall s a. s -> Getting a s a -> a
^. Getting Weight Rational Weight
forall a. Pounds a => Iso' Rational a
pounds
totalC172Moment ::
(HasWeight w, HasArmStatic s) =>
w
-> C172Arms w
-> C172AircraftArms s
-> C172AircraftArms Moment
totalC172Moment :: w -> C172Arms w -> C172AircraftArms s -> C172AircraftArms Moment
totalC172Moment w
bew C172Arms w
wt C172AircraftArms s
am =
C172AircraftArms w -> C172AircraftArms s -> C172AircraftArms Moment
forall w s (f :: * -> *).
(HasWeight w, HasArmStatic s, Applicative f) =>
f w -> f s -> f Moment
momentX (w -> C172Arms w -> C172AircraftArms w
forall a. a -> C172Arms a -> C172AircraftArms a
C172AircraftArms w
bew C172Arms w
wt) C172AircraftArms s
am