{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TemplateHaskell #-} module Data.Aviation.WB.Arm.ArmRangeUpper( ArmRangeUpper , HasArmRangeUpper(..) , HasArmRangeUppers(..) , SetArmRangeUpper(..) , HasArmRangeUpper0(..) ) where import Control.Category((.)) import Control.Lens(Lens', Traversal', Setter', makeClassy, iso) import Data.Aviation.Units(Inches(inches), Centimetres(centimetres), Thouinches(thouinches)) import Data.Eq(Eq) import Data.Maybe(Maybe) import Data.Monoid(Monoid(mempty, mappend)) import Data.Ord(Ord) import Data.Ratio((%)) import Data.Semigroup(Semigroup((<>))) import Numeric.Lens(dividing, multiplying) import Prelude(Show, Rational, (+)) newtype ArmRangeUpper = ArmRangeUpper Rational deriving (ArmRangeUpper -> ArmRangeUpper -> Bool (ArmRangeUpper -> ArmRangeUpper -> Bool) -> (ArmRangeUpper -> ArmRangeUpper -> Bool) -> Eq ArmRangeUpper forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: ArmRangeUpper -> ArmRangeUpper -> Bool $c/= :: ArmRangeUpper -> ArmRangeUpper -> Bool == :: ArmRangeUpper -> ArmRangeUpper -> Bool $c== :: ArmRangeUpper -> ArmRangeUpper -> Bool Eq, Eq ArmRangeUpper Eq ArmRangeUpper -> (ArmRangeUpper -> ArmRangeUpper -> Ordering) -> (ArmRangeUpper -> ArmRangeUpper -> Bool) -> (ArmRangeUpper -> ArmRangeUpper -> Bool) -> (ArmRangeUpper -> ArmRangeUpper -> Bool) -> (ArmRangeUpper -> ArmRangeUpper -> Bool) -> (ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper) -> (ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper) -> Ord ArmRangeUpper ArmRangeUpper -> ArmRangeUpper -> Bool ArmRangeUpper -> ArmRangeUpper -> Ordering ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper 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 min :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper $cmin :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper max :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper $cmax :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper >= :: ArmRangeUpper -> ArmRangeUpper -> Bool $c>= :: ArmRangeUpper -> ArmRangeUpper -> Bool > :: ArmRangeUpper -> ArmRangeUpper -> Bool $c> :: ArmRangeUpper -> ArmRangeUpper -> Bool <= :: ArmRangeUpper -> ArmRangeUpper -> Bool $c<= :: ArmRangeUpper -> ArmRangeUpper -> Bool < :: ArmRangeUpper -> ArmRangeUpper -> Bool $c< :: ArmRangeUpper -> ArmRangeUpper -> Bool compare :: ArmRangeUpper -> ArmRangeUpper -> Ordering $ccompare :: ArmRangeUpper -> ArmRangeUpper -> Ordering $cp1Ord :: Eq ArmRangeUpper Ord, Int -> ArmRangeUpper -> ShowS [ArmRangeUpper] -> ShowS ArmRangeUpper -> String (Int -> ArmRangeUpper -> ShowS) -> (ArmRangeUpper -> String) -> ([ArmRangeUpper] -> ShowS) -> Show ArmRangeUpper forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [ArmRangeUpper] -> ShowS $cshowList :: [ArmRangeUpper] -> ShowS show :: ArmRangeUpper -> String $cshow :: ArmRangeUpper -> String showsPrec :: Int -> ArmRangeUpper -> ShowS $cshowsPrec :: Int -> ArmRangeUpper -> ShowS Show) makeClassy ''ArmRangeUpper class HasArmRangeUppers a where armRangeUppers :: Traversal' a ArmRangeUpper instance HasArmRangeUppers ArmRangeUpper where armRangeUppers :: (ArmRangeUpper -> f ArmRangeUpper) -> ArmRangeUpper -> f ArmRangeUpper armRangeUppers = (ArmRangeUpper -> f ArmRangeUpper) -> ArmRangeUpper -> f ArmRangeUpper forall c. HasArmRangeUpper c => Lens' c ArmRangeUpper armRangeUpper class SetArmRangeUpper a where setArmRangeUpper :: Setter' a ArmRangeUpper instance SetArmRangeUpper ArmRangeUpper where setArmRangeUpper :: (ArmRangeUpper -> f ArmRangeUpper) -> ArmRangeUpper -> f ArmRangeUpper setArmRangeUpper = (ArmRangeUpper -> f ArmRangeUpper) -> ArmRangeUpper -> f ArmRangeUpper forall c. HasArmRangeUpper c => Lens' c ArmRangeUpper armRangeUpper class HasArmRangeUpper0 a where armRangeUpper0 :: Lens' a (Maybe ArmRangeUpper) instance Inches ArmRangeUpper where inches :: p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) inches = (Rational -> ArmRangeUpper) -> (ArmRangeUpper -> Rational) -> Iso' Rational ArmRangeUpper forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b iso Rational -> ArmRangeUpper ArmRangeUpper (\(ArmRangeUpper Rational x) -> Rational x) instance Thouinches ArmRangeUpper where thouinches :: p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) thouinches = Rational -> Iso' Rational Rational forall a. (Fractional a, Eq a) => a -> Iso' a a multiplying Rational 1000 (p Rational (f Rational) -> p Rational (f Rational)) -> (p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational)) -> p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) forall a. Inches a => Iso' Rational a inches instance Centimetres ArmRangeUpper where centimetres :: p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) centimetres = Rational -> Iso' Rational Rational forall a. (Fractional a, Eq a) => a -> Iso' a a dividing (Integer 254 Integer -> Integer -> Rational forall a. Integral a => a -> a -> Ratio a % Integer 100) (p Rational (f Rational) -> p Rational (f Rational)) -> (p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational)) -> p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . p ArmRangeUpper (f ArmRangeUpper) -> p Rational (f Rational) forall a. Inches a => Iso' Rational a inches instance Semigroup ArmRangeUpper where <> :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper (<>) = ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper forall a. Monoid a => a -> a -> a mappend instance Monoid ArmRangeUpper where mempty :: ArmRangeUpper mempty = Rational -> ArmRangeUpper ArmRangeUpper Rational 0 ArmRangeUpper Rational w1 mappend :: ArmRangeUpper -> ArmRangeUpper -> ArmRangeUpper `mappend` ArmRangeUpper Rational w2 = Rational -> ArmRangeUpper ArmRangeUpper (Rational w1 Rational -> Rational -> Rational forall a. Num a => a -> a -> a + Rational w2)