packages feed

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

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

-- | The data type @TrainingMaterial'@: rePL training: the chief RePL instructor and the courses, at most 9 (CASA Form 101-02, questions 13 to 18, 29 and 30), and the arrangements of the RePL training manual.
module ReOC.Data.TrainingMaterial (
  TrainingMaterial' (..),
  TrainingMaterial'Like (..),
  lawNamesTrainingMaterial',
  TrainingMaterial,
  UnfilledTrainingMaterial,
  mkUnfilledTrainingMaterial,
  InheritTrainingMaterial',
  inheritTrainingMaterial',
) where

import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import ReOC.Data.CRINominee (CRINominee, UnfilledCRINominee)
import ReOC.Data.OperationalExperience (OperationalExperience, UnfilledOperationalExperience)
import ReOC.Data.OtherReOCRoles (OtherReOCRoles, UnfilledOtherReOCRoles)
import ReOC.Data.RePLHolding (RePLHolding, UnfilledRePLHolding)
import ReOC.Data.TeachingQualification (TeachingQualification, UnfilledTeachingQualification)
import ReOC.Data.TrainingArrangements (TrainingArrangements, UnfilledTrainingArrangements, mkUnfilledTrainingArrangements)
import ReOC.Data.TrainingCourse (TrainingCourse, UnfilledTrainingCourse)
import ReOC.Name.CriNominee (CriNomineeLike (..))
import ReOC.Name.CriOtherReOCRoles (CriOtherReOCRolesLike (..))
import ReOC.Name.OperationalExperience (OperationalExperienceLike (..))
import ReOC.Name.RePLHolding (RePLHoldingLike (..))
import ReOC.Name.TeachingQualification (TeachingQualificationLike (..))
import ReOC.Name.TrainingArrangements (TrainingArrangementsLike (..))
import ReOC.Name.TrainingCourses (TrainingCoursesLike (..))
import ReOC.Primitive.Some (Some)

-- | RePL training: the chief RePL instructor and the courses, at most 9 (CASA Form 101-02, questions 13 to 18, 29 and 30), and the arrangements of the RePL training manual. Its valid form is @TrainingMaterial@, and its unfilled form @UnfilledTrainingMaterial@.
data TrainingMaterial' a1 a2 a3 a4 a5 a6 a7 = TrainingMaterial' a1 a2 a3 a4 a5 a6 a7
  deriving (Eq, Ord, Show)

-- | The name of the data type @TrainingMaterial'@.
class TrainingMaterial'Like p f x x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' | x -> a1 a2 a3 a4 a5 a6 a7 where
  trainingMaterial' ::
    Optic p f x x' (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) (TrainingMaterial' a1' a2' a3' a4' a5' a6' a7')

-- | Identity
instance (x' ~ TrainingMaterial' a1' a2' a3' a4' a5' a6' a7') => TrainingMaterial'Like p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' where
  trainingMaterial' = id

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1' a2 a3 a4 a5 a6 a7) => CriNomineeLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a1 a1' where
  criNominee f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x1' -> TrainingMaterial' x1' x2 x3 x4 x5 x6 x7) (f x1)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2' a3 a4 a5 a6 a7) => RePLHoldingLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a2 a2' where
  rePLHolding f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x2' -> TrainingMaterial' x1 x2' x3 x4 x5 x6 x7) (f x2)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2 a3' a4 a5 a6 a7) => TeachingQualificationLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a3 a3' where
  teachingQualification f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x3' -> TrainingMaterial' x1 x2 x3' x4 x5 x6 x7) (f x3)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2 a3 a4' a5 a6 a7) => OperationalExperienceLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a4 a4' where
  operationalExperience f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x4' -> TrainingMaterial' x1 x2 x3 x4' x5 x6 x7) (f x4)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2 a3 a4 a5' a6 a7) => CriOtherReOCRolesLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a5 a5' where
  criOtherReOCRoles f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x5' -> TrainingMaterial' x1 x2 x3 x4 x5' x6 x7) (f x5)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2 a3 a4 a5 a6' a7) => TrainingCoursesLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a6 a6' where
  trainingCourses f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (\x6' -> TrainingMaterial' x1 x2 x3 x4 x5 x6' x7) (f x6)

-- | Lens
instance (p ~ (->), Functor f, x' ~ TrainingMaterial' a1 a2 a3 a4 a5 a6 a7') => TrainingArrangementsLike p f (TrainingMaterial' a1 a2 a3 a4 a5 a6 a7) x' a7 a7' where
  trainingArrangements f (TrainingMaterial' x1 x2 x3 x4 x5 x6 x7) = fmap (TrainingMaterial' x1 x2 x3 x4 x5 x6) (f x7)

{- | Rebuilds a value from the name of each field or constructor.

Laws:

> lawNamesTrainingMaterial' == id
-}
lawNamesTrainingMaterial' :: TrainingMaterial' a1 a2 a3 a4 a5 a6 a7 -> TrainingMaterial' a1 a2 a3 a4 a5 a6 a7
lawNamesTrainingMaterial' s =
  TrainingMaterial'
    (view (cloneLens criNominee) s)
    (view (cloneLens rePLHolding) s)
    (view (cloneLens teachingQualification) s)
    (view (cloneLens operationalExperience) s)
    (view (cloneLens criOtherReOCRoles) s)
    (view (cloneLens trainingCourses) s)
    (view (cloneLens trainingArrangements) s)

-- | A valid @TrainingMaterial'@.
type TrainingMaterial = TrainingMaterial' CRINominee RePLHolding TeachingQualification OperationalExperience OtherReOCRoles (Some 9 TrainingCourse) TrainingArrangements

-- | An unfilled @TrainingMaterial'@: each field holds what has been entered, if anything, to be checked by @fillTrainingMaterial@.
type UnfilledTrainingMaterial = TrainingMaterial' (Maybe UnfilledCRINominee) (Maybe UnfilledRePLHolding) (Maybe UnfilledTeachingQualification) (Maybe UnfilledOperationalExperience) (Maybe UnfilledOtherReOCRoles) [UnfilledTrainingCourse] UnfilledTrainingArrangements

-- | An unfilled @TrainingMaterial'@ with nothing entered.
mkUnfilledTrainingMaterial :: UnfilledTrainingMaterial
mkUnfilledTrainingMaterial =
  TrainingMaterial'
    Nothing
    Nothing
    Nothing
    Nothing
    Nothing
    []
    mkUnfilledTrainingArrangements

-- | The classes that a data type holding @TrainingMaterial'@ in one field, or in one or more constructors, inherits.
type InheritTrainingMaterial' s a1 a2 a3 a4 a5 a6 a7 =
  ( TrainingMaterial'Like (->) (Const ()) s s a1 a1 a2 a2 a3 a3 a4 a4 a5 a5 a6 a6 a7 a7
  , CriNomineeLike (->) (Const ()) s s a1 a1
  , RePLHoldingLike (->) (Const ()) s s a2 a2
  , TeachingQualificationLike (->) (Const ()) s s a3 a3
  , OperationalExperienceLike (->) (Const ()) s s a4 a4
  , CriOtherReOCRolesLike (->) (Const ()) s s a5 a5
  , TrainingCoursesLike (->) (Const ()) s s a6 a6
  , TrainingArrangementsLike (->) (Const ()) s s a7 a7
  )

-- | Checks that a data type inherits every class of @InheritTrainingMaterial'@.
inheritTrainingMaterial' :: (InheritTrainingMaterial' s a1 a2 a3 a4 a5 a6 a7) => proxy s -> ()
inheritTrainingMaterial' _ = ()