casa-reoc-0.1.0.0: src/ReOC/Data/RPAType.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
-- The checks of inheritance (inheritRPAType') have a constraint that their body does not use, by design.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
-- | The data type @RPAType'@: a type of RPA, with the facts and type-specific procedures that the operations manual gives for it. Its short name (such as "DJI Mavic 3 Pro") names it in prose and on the form, and must fit the cell of question 27 for its make and model.
module ReOC.Data.RPAType (
RPAType' (..),
RPAType'Like (..),
lawNamesRPAType',
RPAType,
UnfilledRPAType,
mkRPAType,
mkUnfilledRPAType,
InheritRPAType',
inheritRPAType',
) where
import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import Data.List.NonEmpty (NonEmpty)
import Data.Text (Text)
import Numeric.Natural (Natural)
import ReOC.Data.EmergencyAction (EmergencyAction, UnfilledEmergencyAction)
import ReOC.Data.FlightTermination (FlightTermination, UnfilledFlightTermination)
import ReOC.Data.RPACategory (RPACategory)
import ReOC.Data.Transponder (Transponder)
import ReOC.Name.BatteryWarnings (BatteryWarningsLike (..))
import ReOC.Name.BeforeFlight (BeforeFlightLike (..))
import ReOC.Name.Category (CategoryLike (..))
import ReOC.Name.EmergencyActions (EmergencyActionsLike (..))
import ReOC.Name.FlightTermination (FlightTerminationLike (..))
import ReOC.Name.InspectionItems (InspectionItemsLike (..))
import ReOC.Name.MaximumGrossWeight (MaximumGrossWeightLike (..))
import ReOC.Name.RpaMake (RpaMakeLike (..))
import ReOC.Name.RpaModel (RpaModelLike (..))
import ReOC.Name.ShortName (ShortNameLike (..))
import ReOC.Name.TransponderCarriage (TransponderCarriageLike (..))
import ReOC.Name.UserManual (UserManualLike (..))
import ReOC.Primitive.FormText (FormFont (..), FormText)
import ReOC.Primitive.GrossWeight (GrossWeight)
import ReOC.Primitive.Text1 (Text1)
-- | A type of RPA, with the facts and type-specific procedures that the operations manual gives for it. Its short name (such as "DJI Mavic 3 Pro") names it in prose and on the form, and must fit the cell of question 27 for its make and model. Its valid form is @RPAType@, and its unfilled form @UnfilledRPAType@.
data RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 = RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12
deriving (Eq, Ord, Show)
-- | The name of the data type @RPAType'@.
class RPAType'Like p f x x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' a8 a8' a9 a9' a10 a10' a11 a11' a12 a12' | x -> a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 where
rpaType' ::
Optic p f x x' (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) (RPAType' a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12')
-- | Identity
instance (x' ~ RPAType' a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12') => RPAType'Like p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' a8 a8' a9 a9' a10 a10' a11 a11' a12 a12' where
rpaType' = id
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1' a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => RpaMakeLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a1 a1' where
rpaMake f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x1' -> RPAType' x1' x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x1)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2' a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => RpaModelLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a2 a2' where
rpaModel f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x2' -> RPAType' x1 x2' x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x2)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3' a4 a5 a6 a7 a8 a9 a10 a11 a12) => ShortNameLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a3 a3' where
shortName f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x3' -> RPAType' x1 x2 x3' x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x3)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4' a5 a6 a7 a8 a9 a10 a11 a12) => CategoryLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a4 a4' where
category f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x4' -> RPAType' x1 x2 x3 x4' x5 x6 x7 x8 x9 x10 x11 x12) (f x4)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5' a6 a7 a8 a9 a10 a11 a12) => MaximumGrossWeightLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a5 a5' where
maximumGrossWeight f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x5' -> RPAType' x1 x2 x3 x4 x5' x6 x7 x8 x9 x10 x11 x12) (f x5)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6' a7 a8 a9 a10 a11 a12) => UserManualLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a6 a6' where
userManual f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x6' -> RPAType' x1 x2 x3 x4 x5 x6' x7 x8 x9 x10 x11 x12) (f x6)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7' a8 a9 a10 a11 a12) => TransponderCarriageLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a7 a7' where
transponderCarriage f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x7' -> RPAType' x1 x2 x3 x4 x5 x6 x7' x8 x9 x10 x11 x12) (f x7)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7 a8' a9 a10 a11 a12) => FlightTerminationLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a8 a8' where
flightTermination f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x8' -> RPAType' x1 x2 x3 x4 x5 x6 x7 x8' x9 x10 x11 x12) (f x8)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9' a10 a11 a12) => InspectionItemsLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a9 a9' where
inspectionItems f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x9' -> RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9' x10 x11 x12) (f x9)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10' a11 a12) => BeforeFlightLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a10 a10' where
beforeFlight f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x10' -> RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10' x11 x12) (f x10)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11' a12) => BatteryWarningsLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a11 a11' where
batteryWarnings f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x11' -> RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11' x12) (f x11)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12') => EmergencyActionsLike p f (RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a12 a12' where
emergencyActions f (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) (f x12)
{- | Rebuilds a value from the name of each field or constructor.
Laws:
> lawNamesRPAType' == id
-}
lawNamesRPAType' :: RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 -> RPAType' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12
lawNamesRPAType' s =
RPAType'
(view (cloneLens rpaMake) s)
(view (cloneLens rpaModel) s)
(view (cloneLens shortName) s)
(view (cloneLens category) s)
(view (cloneLens maximumGrossWeight) s)
(view (cloneLens userManual) s)
(view (cloneLens transponderCarriage) s)
(view (cloneLens flightTermination) s)
(view (cloneLens inspectionItems) s)
(view (cloneLens beforeFlight) s)
(view (cloneLens batteryWarnings) s)
(view (cloneLens emergencyActions) s)
-- | A valid @RPAType'@.
type RPAType = RPAType' Text1 Text1 (FormText 'Narrow 84 1) RPACategory GrossWeight Text1 Transponder FlightTermination (NonEmpty Text1) [Text1] (Maybe Text1) [EmergencyAction]
-- | An unfilled @RPAType'@: each field holds what has been entered, if anything, to be checked by @fillRPAType@.
type UnfilledRPAType = RPAType' (Maybe Text) (Maybe Text) (Maybe Text) (Maybe RPACategory) (Maybe Natural) (Maybe Text) (Maybe Transponder) (Maybe UnfilledFlightTermination) [Text] [Text] (Maybe Text) [UnfilledEmergencyAction]
-- | Builds a valid @RPAType'@ with every @Maybe@ field @Nothing@ and every list (or @AtMost@) field empty.
mkRPAType :: Text1 -> Text1 -> FormText 'Narrow 84 1 -> RPACategory -> GrossWeight -> Text1 -> Transponder -> FlightTermination -> NonEmpty Text1 -> RPAType
mkRPAType x1 x2 x3 x4 x5 x6 x7 x8 x9 = RPAType' x1 x2 x3 x4 x5 x6 x7 x8 x9 [] Nothing []
-- | An unfilled @RPAType'@ with nothing entered.
mkUnfilledRPAType :: UnfilledRPAType
mkUnfilledRPAType =
RPAType'
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
Nothing
[]
[]
Nothing
[]
-- | The classes that a data type holding @RPAType'@ in one field, or in one or more constructors, inherits.
type InheritRPAType' s a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
( RPAType'Like (->) (Const ()) s s a1 a1 a2 a2 a3 a3 a4 a4 a5 a5 a6 a6 a7 a7 a8 a8 a9 a9 a10 a10 a11 a11 a12 a12
, RpaMakeLike (->) (Const ()) s s a1 a1
, RpaModelLike (->) (Const ()) s s a2 a2
, ShortNameLike (->) (Const ()) s s a3 a3
, CategoryLike (->) (Const ()) s s a4 a4
, MaximumGrossWeightLike (->) (Const ()) s s a5 a5
, UserManualLike (->) (Const ()) s s a6 a6
, TransponderCarriageLike (->) (Const ()) s s a7 a7
, FlightTerminationLike (->) (Const ()) s s a8 a8
, InspectionItemsLike (->) (Const ()) s s a9 a9
, BeforeFlightLike (->) (Const ()) s s a10 a10
, BatteryWarningsLike (->) (Const ()) s s a11 a11
, EmergencyActionsLike (->) (Const ()) s s a12 a12
)
-- | Checks that a data type inherits every class of @InheritRPAType'@.
inheritRPAType' :: (InheritRPAType' s a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => proxy s -> ()
inheritRPAType' _ = ()