casa-reoc-0.1.0.0: src/ReOC/Data/ChiefPilot.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
-- The checks of inheritance (inheritChiefPilot') have a constraint that their body does not use, by design.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
-- | The data type @ChiefPilot'@: the nominated chief remote pilot (CASA Form 101-02, questions 8 to 11).
module ReOC.Data.ChiefPilot (
ChiefPilot' (..),
ChiefPilot'Like (..),
lawNamesChiefPilot',
ChiefPilot,
UnfilledChiefPilot,
mkUnfilledChiefPilot,
InheritChiefPilot',
inheritChiefPilot',
) where
import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import Data.Text (Text)
import ReOC.Data.CRPNominee (CRPNominee, UnfilledCRPNominee)
import ReOC.Data.OtherReOCRoles (OtherReOCRoles, UnfilledOtherReOCRoles)
import ReOC.Data.RadioQualification (RadioQualification)
import ReOC.Data.RePLOrigin (RePLOrigin, UnfilledRePLOrigin)
import ReOC.Name.CrpNominee (CrpNomineeLike (..))
import ReOC.Name.OtherReOCRoles (OtherReOCRolesLike (..))
import ReOC.Name.Radio (RadioLike (..))
import ReOC.Name.RePLOrigin (RePLOriginLike (..))
import ReOC.Name.RpaHistory (RpaHistoryLike (..))
import ReOC.Primitive.FormText (FormLines)
-- | The nominated chief remote pilot (CASA Form 101-02, questions 8 to 11). Its valid form is @ChiefPilot@, and its unfilled form @UnfilledChiefPilot@.
data ChiefPilot' a1 a2 a3 a4 a5 = ChiefPilot' a1 a2 a3 a4 a5
deriving (Eq, Ord, Show)
-- | The name of the data type @ChiefPilot'@.
class ChiefPilot'Like p f x x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' | x -> a1 a2 a3 a4 a5 where
chiefPilot' ::
Optic p f x x' (ChiefPilot' a1 a2 a3 a4 a5) (ChiefPilot' a1' a2' a3' a4' a5')
-- | Identity
instance (x' ~ ChiefPilot' a1' a2' a3' a4' a5') => ChiefPilot'Like p f (ChiefPilot' a1 a2 a3 a4 a5) x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' where
chiefPilot' = id
-- | Lens
instance (p ~ (->), Functor f, x' ~ ChiefPilot' a1' a2 a3 a4 a5) => CrpNomineeLike p f (ChiefPilot' a1 a2 a3 a4 a5) x' a1 a1' where
crpNominee f (ChiefPilot' x1 x2 x3 x4 x5) = fmap (\x1' -> ChiefPilot' x1' x2 x3 x4 x5) (f x1)
-- | Lens
instance (p ~ (->), Functor f, x' ~ ChiefPilot' a1 a2' a3 a4 a5) => RePLOriginLike p f (ChiefPilot' a1 a2 a3 a4 a5) x' a2 a2' where
rePLOrigin f (ChiefPilot' x1 x2 x3 x4 x5) = fmap (\x2' -> ChiefPilot' x1 x2' x3 x4 x5) (f x2)
-- | Lens
instance (p ~ (->), Functor f, x' ~ ChiefPilot' a1 a2 a3' a4 a5) => RpaHistoryLike p f (ChiefPilot' a1 a2 a3 a4 a5) x' a3 a3' where
rpaHistory f (ChiefPilot' x1 x2 x3 x4 x5) = fmap (\x3' -> ChiefPilot' x1 x2 x3' x4 x5) (f x3)
-- | Lens
instance (p ~ (->), Functor f, x' ~ ChiefPilot' a1 a2 a3 a4' a5) => OtherReOCRolesLike p f (ChiefPilot' a1 a2 a3 a4 a5) x' a4 a4' where
otherReOCRoles f (ChiefPilot' x1 x2 x3 x4 x5) = fmap (\x4' -> ChiefPilot' x1 x2 x3 x4' x5) (f x4)
-- | Lens
instance (p ~ (->), Functor f, x' ~ ChiefPilot' a1 a2 a3 a4 a5') => RadioLike p f (ChiefPilot' a1 a2 a3 a4 a5) x' a5 a5' where
radio f (ChiefPilot' x1 x2 x3 x4 x5) = fmap (ChiefPilot' x1 x2 x3 x4) (f x5)
{- | Rebuilds a value from the name of each field or constructor.
Laws:
> lawNamesChiefPilot' == id
-}
lawNamesChiefPilot' :: ChiefPilot' a1 a2 a3 a4 a5 -> ChiefPilot' a1 a2 a3 a4 a5
lawNamesChiefPilot' s =
ChiefPilot'
(view (cloneLens crpNominee) s)
(view (cloneLens rePLOrigin) s)
(view (cloneLens rpaHistory) s)
(view (cloneLens otherReOCRoles) s)
(view (cloneLens radio) s)
-- | A valid @ChiefPilot'@.
type ChiefPilot = ChiefPilot' CRPNominee RePLOrigin (FormLines 8) OtherReOCRoles RadioQualification
-- | An unfilled @ChiefPilot'@: each field holds what has been entered, if anything, to be checked by @fillChiefPilot@.
type UnfilledChiefPilot = ChiefPilot' (Maybe UnfilledCRPNominee) (Maybe UnfilledRePLOrigin) (Maybe Text) (Maybe UnfilledOtherReOCRoles) (Maybe RadioQualification)
-- | An unfilled @ChiefPilot'@ with nothing entered.
mkUnfilledChiefPilot :: UnfilledChiefPilot
mkUnfilledChiefPilot =
ChiefPilot'
Nothing
Nothing
Nothing
Nothing
Nothing
-- | The classes that a data type holding @ChiefPilot'@ in one field, or in one or more constructors, inherits.
type InheritChiefPilot' s a1 a2 a3 a4 a5 =
( ChiefPilot'Like (->) (Const ()) s s a1 a1 a2 a2 a3 a3 a4 a4 a5 a5
, CrpNomineeLike (->) (Const ()) s s a1 a1
, RePLOriginLike (->) (Const ()) s s a2 a2
, RpaHistoryLike (->) (Const ()) s s a3 a3
, OtherReOCRolesLike (->) (Const ()) s s a4 a4
, RadioLike (->) (Const ()) s s a5 a5
)
-- | Checks that a data type inherits every class of @InheritChiefPilot'@.
inheritChiefPilot' :: (InheritChiefPilot' s a1 a2 a3 a4 a5) => proxy s -> ()
inheritChiefPilot' _ = ()