packages feed

casa-reoc-0.1.0.0: src/ReOC/Data/Policies.hs

{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
-- The checks of inheritance (inheritPolicies') have a constraint that their body does not use, by design.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

-- | The data type @Policies'@: the limits that the operator sets in its operations manual.
module ReOC.Data.Policies (
  Policies' (..),
  Policies'Like (..),
  lawNamesPolicies',
  Policies,
  UnfilledPolicies,
  mkUnfilledPolicies,
  InheritPolicies',
  inheritPolicies',
) where

import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import Numeric.Natural (Natural)
import ReOC.Data.BackupInterval (BackupInterval)
import ReOC.Name.AlcoholHours (AlcoholHoursLike (..))
import ReOC.Name.BackupFrequency (BackupFrequencyLike (..))
import ReOC.Name.BatteryReserve (BatteryReserveLike (..))
import ReOC.Name.CheckingMonths (CheckingMonthsLike (..))
import ReOC.Name.DutyHours (DutyHoursLike (..))
import ReOC.Name.IndependentReviewYears (IndependentReviewYearsLike (..))
import ReOC.Name.InspectionHours (InspectionHoursLike (..))
import ReOC.Name.InspectionMonths (InspectionMonthsLike (..))
import ReOC.Name.RecencyDays (RecencyDaysLike (..))
import ReOC.Name.RecencyFlights (RecencyFlightsLike (..))
import ReOC.Name.RefresherMonths (RefresherMonthsLike (..))
import ReOC.Name.RestHours (RestHoursLike (..))
import ReOC.Primitive.Percentage (Percentage)
import ReOC.Primitive.Positive (Positive)

-- | The limits that the operator sets in its operations manual. Its valid form is @Policies@, and its unfilled form @UnfilledPolicies@.
data Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 = Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12
  deriving (Eq, Ord, Show)

-- | The name of the data type @Policies'@.
class Policies'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
  policies' ::
    Optic p f x x' (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) (Policies' a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12')

-- | Identity
instance (x' ~ Policies' a1' a2' a3' a4' a5' a6' a7' a8' a9' a10' a11' a12') => Policies'Like p f (Policies' 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
  policies' = id

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1' a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => RecencyFlightsLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a1 a1' where
  recencyFlights f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x1' -> Policies' x1' x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x1)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2' a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => RecencyDaysLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a2 a2' where
  recencyDays f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x2' -> Policies' x1 x2' x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x2)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3' a4 a5 a6 a7 a8 a9 a10 a11 a12) => RefresherMonthsLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a3 a3' where
  refresherMonths f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x3' -> Policies' x1 x2 x3' x4 x5 x6 x7 x8 x9 x10 x11 x12) (f x3)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4' a5 a6 a7 a8 a9 a10 a11 a12) => AlcoholHoursLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a4 a4' where
  alcoholHours f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x4' -> Policies' x1 x2 x3 x4' x5 x6 x7 x8 x9 x10 x11 x12) (f x4)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5' a6 a7 a8 a9 a10 a11 a12) => RestHoursLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a5 a5' where
  restHours f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x5' -> Policies' x1 x2 x3 x4 x5' x6 x7 x8 x9 x10 x11 x12) (f x5)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6' a7 a8 a9 a10 a11 a12) => DutyHoursLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a6 a6' where
  dutyHours f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x6' -> Policies' x1 x2 x3 x4 x5 x6' x7 x8 x9 x10 x11 x12) (f x6)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7' a8 a9 a10 a11 a12) => InspectionMonthsLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a7 a7' where
  inspectionMonths f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x7' -> Policies' x1 x2 x3 x4 x5 x6 x7' x8 x9 x10 x11 x12) (f x7)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7 a8' a9 a10 a11 a12) => InspectionHoursLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a8 a8' where
  inspectionHours f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x8' -> Policies' x1 x2 x3 x4 x5 x6 x7 x8' x9 x10 x11 x12) (f x8)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9' a10 a11 a12) => BatteryReserveLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a9 a9' where
  batteryReserve f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x9' -> Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9' x10 x11 x12) (f x9)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10' a11 a12) => BackupFrequencyLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a10 a10' where
  backupFrequency f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x10' -> Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10' x11 x12) (f x10)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11' a12) => IndependentReviewYearsLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a11 a11' where
  independentReviewYears f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (\x11' -> Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11' x12) (f x11)

-- | Lens
instance (p ~ (->), Functor f, x' ~ Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12') => CheckingMonthsLike p f (Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) x' a12 a12' where
  checkingMonths f (Policies' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) = fmap (Policies' 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:

> lawNamesPolicies' == id
-}
lawNamesPolicies' :: Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 -> Policies' a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12
lawNamesPolicies' s =
  Policies'
    (view (cloneLens recencyFlights) s)
    (view (cloneLens recencyDays) s)
    (view (cloneLens refresherMonths) s)
    (view (cloneLens alcoholHours) s)
    (view (cloneLens restHours) s)
    (view (cloneLens dutyHours) s)
    (view (cloneLens inspectionMonths) s)
    (view (cloneLens inspectionHours) s)
    (view (cloneLens batteryReserve) s)
    (view (cloneLens backupFrequency) s)
    (view (cloneLens independentReviewYears) s)
    (view (cloneLens checkingMonths) s)

-- | A valid @Policies'@.
type Policies = Policies' Positive Positive Positive Positive Positive Positive Positive Positive Percentage BackupInterval Positive Positive

-- | An unfilled @Policies'@: each field holds what has been entered, if anything, to be checked by @fillPolicies@.
type UnfilledPolicies = Policies' (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe Natural) (Maybe BackupInterval) (Maybe Natural) (Maybe Natural)

-- | An unfilled @Policies'@ with nothing entered.
mkUnfilledPolicies :: UnfilledPolicies
mkUnfilledPolicies =
  Policies'
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing

-- | The classes that a data type holding @Policies'@ in one field, or in one or more constructors, inherits.
type InheritPolicies' s a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 =
  ( Policies'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
  , RecencyFlightsLike (->) (Const ()) s s a1 a1
  , RecencyDaysLike (->) (Const ()) s s a2 a2
  , RefresherMonthsLike (->) (Const ()) s s a3 a3
  , AlcoholHoursLike (->) (Const ()) s s a4 a4
  , RestHoursLike (->) (Const ()) s s a5 a5
  , DutyHoursLike (->) (Const ()) s s a6 a6
  , InspectionMonthsLike (->) (Const ()) s s a7 a7
  , InspectionHoursLike (->) (Const ()) s s a8 a8
  , BatteryReserveLike (->) (Const ()) s s a9 a9
  , BackupFrequencyLike (->) (Const ()) s s a10 a10
  , IndependentReviewYearsLike (->) (Const ()) s s a11 a11
  , CheckingMonthsLike (->) (Const ()) s s a12 a12
  )

-- | Checks that a data type inherits every class of @InheritPolicies'@.
inheritPolicies' :: (InheritPolicies' s a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12) => proxy s -> ()
inheritPolicies' _ = ()