casa-reoc-0.1.0.0: src/ReOC/Data/RegulatoryAction.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
-- The checks of inheritance (inheritRegulatoryAction') have a constraint that their body does not use, by design.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
-- | The data type @RegulatoryAction'@: regulatory action taken against the applicant or nominated personnel (CASA Form 101-02, questions 25 and 26).
module ReOC.Data.RegulatoryAction (
RegulatoryAction' (..),
RegulatoryAction'Like (..),
lawNamesRegulatoryAction',
RegulatoryAction,
UnfilledRegulatoryAction,
mkUnfilledRegulatoryAction,
InheritRegulatoryAction',
inheritRegulatoryAction',
) where
import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import Data.Text (Text)
import Data.Time.Calendar (Day)
import ReOC.Name.ActionDate (ActionDateLike (..))
import ReOC.Name.ActionDetails (ActionDetailsLike (..))
import ReOC.Name.AuthorisationAction (AuthorisationActionLike (..))
import ReOC.Name.ReocSuspendedOrCancelled (ReocSuspendedOrCancelledLike (..))
import ReOC.Name.TypeOfAction (TypeOfActionLike (..))
import ReOC.Primitive.FormText (FormLine, FormLines)
-- | Regulatory action taken against the applicant or nominated personnel (CASA Form 101-02, questions 25 and 26). Its valid form is @RegulatoryAction@, and its unfilled form @UnfilledRegulatoryAction@.
data RegulatoryAction' a1 a2 a3 a4 a5 = RegulatoryAction' a1 a2 a3 a4 a5
deriving (Eq, Ord, Show)
-- | The name of the data type @RegulatoryAction'@.
class RegulatoryAction'Like p f x x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' | x -> a1 a2 a3 a4 a5 where
regulatoryAction' ::
Optic p f x x' (RegulatoryAction' a1 a2 a3 a4 a5) (RegulatoryAction' a1' a2' a3' a4' a5')
-- | Identity
instance (x' ~ RegulatoryAction' a1' a2' a3' a4' a5') => RegulatoryAction'Like p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' where
regulatoryAction' = id
-- | Lens
instance (p ~ (->), Functor f, x' ~ RegulatoryAction' a1' a2 a3 a4 a5) => ReocSuspendedOrCancelledLike p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a1 a1' where
reocSuspendedOrCancelled f (RegulatoryAction' x1 x2 x3 x4 x5) = fmap (\x1' -> RegulatoryAction' x1' x2 x3 x4 x5) (f x1)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RegulatoryAction' a1 a2' a3 a4 a5) => TypeOfActionLike p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a2 a2' where
typeOfAction f (RegulatoryAction' x1 x2 x3 x4 x5) = fmap (\x2' -> RegulatoryAction' x1 x2' x3 x4 x5) (f x2)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RegulatoryAction' a1 a2 a3' a4 a5) => AuthorisationActionLike p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a3 a3' where
authorisationAction f (RegulatoryAction' x1 x2 x3 x4 x5) = fmap (\x3' -> RegulatoryAction' x1 x2 x3' x4 x5) (f x3)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RegulatoryAction' a1 a2 a3 a4' a5) => ActionDateLike p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a4 a4' where
actionDate f (RegulatoryAction' x1 x2 x3 x4 x5) = fmap (\x4' -> RegulatoryAction' x1 x2 x3 x4' x5) (f x4)
-- | Lens
instance (p ~ (->), Functor f, x' ~ RegulatoryAction' a1 a2 a3 a4 a5') => ActionDetailsLike p f (RegulatoryAction' a1 a2 a3 a4 a5) x' a5 a5' where
actionDetails f (RegulatoryAction' x1 x2 x3 x4 x5) = fmap (RegulatoryAction' x1 x2 x3 x4) (f x5)
{- | Rebuilds a value from the name of each field or constructor.
Laws:
> lawNamesRegulatoryAction' == id
-}
lawNamesRegulatoryAction' :: RegulatoryAction' a1 a2 a3 a4 a5 -> RegulatoryAction' a1 a2 a3 a4 a5
lawNamesRegulatoryAction' s =
RegulatoryAction'
(view (cloneLens reocSuspendedOrCancelled) s)
(view (cloneLens typeOfAction) s)
(view (cloneLens authorisationAction) s)
(view (cloneLens actionDate) s)
(view (cloneLens actionDetails) s)
-- | A valid @RegulatoryAction'@.
type RegulatoryAction = RegulatoryAction' Bool FormLine FormLine Day (FormLines 4)
-- | An unfilled @RegulatoryAction'@: each field holds what has been entered, if anything, to be checked by @fillRegulatoryAction@.
type UnfilledRegulatoryAction = RegulatoryAction' (Maybe Bool) (Maybe Text) (Maybe Text) (Maybe Day) (Maybe Text)
-- | An unfilled @RegulatoryAction'@ with nothing entered.
mkUnfilledRegulatoryAction :: UnfilledRegulatoryAction
mkUnfilledRegulatoryAction =
RegulatoryAction'
Nothing
Nothing
Nothing
Nothing
Nothing
-- | The classes that a data type holding @RegulatoryAction'@ in one field, or in one or more constructors, inherits.
type InheritRegulatoryAction' s a1 a2 a3 a4 a5 =
( RegulatoryAction'Like (->) (Const ()) s s a1 a1 a2 a2 a3 a3 a4 a4 a5 a5
, ReocSuspendedOrCancelledLike (->) (Const ()) s s a1 a1
, TypeOfActionLike (->) (Const ()) s s a2 a2
, AuthorisationActionLike (->) (Const ()) s s a3 a3
, ActionDateLike (->) (Const ()) s s a4 a4
, ActionDetailsLike (->) (Const ()) s s a5 a5
)
-- | Checks that a data type inherits every class of @InheritRegulatoryAction'@.
inheritRegulatoryAction' :: (InheritRegulatoryAction' s a1 a2 a3 a4 a5) => proxy s -> ()
inheritRegulatoryAction' _ = ()