casa-reoc-0.1.0.0: src/ReOC/Data/Company.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
-- The checks of inheritance (inheritCompany') have a constraint that their body does not use, by design.
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
-- | The data type @Company'@: the proprietary company that applies for, and holds, the ReOC. Its legal name is its name followed by "Pty Ltd", which must fit question 1 of the form.
module ReOC.Data.Company (
Company' (..),
Company'Like (..),
lawNamesCompany',
Company,
UnfilledCompany,
mkCompany,
mkUnfilledCompany,
InheritCompany',
inheritCompany',
) where
import Control.Lens (Optic, cloneLens, view)
import Data.Functor.Const (Const)
import Data.Text (Text)
import ReOC.Data.Address (Address, UnfilledAddress, mkUnfilledAddress)
import ReOC.Data.OperationalHeadquarters (OperationalHeadquarters, UnfilledOperationalHeadquarters)
import ReOC.Name.Abn (AbnLike (..))
import ReOC.Name.Arn (ArnLike (..))
import ReOC.Name.BusinessName (BusinessNameLike (..))
import ReOC.Name.CompanyName (CompanyNameLike (..))
import ReOC.Name.EmailAddress (EmailAddressLike (..))
import ReOC.Name.OperationalHeadquarters (OperationalHeadquartersLike (..))
import ReOC.Name.PhoneNumber (PhoneNumberLike (..))
import ReOC.Name.RegisteredOffice (RegisteredOfficeLike (..))
import ReOC.Primitive.ABN (ABN)
import ReOC.Primitive.ARN (ARN)
import ReOC.Primitive.EmailAddress (EmailAddress)
import ReOC.Primitive.FormText (FormFont (..), FormLine, FormText)
import ReOC.Primitive.PhoneNumber (PhoneNumber)
-- | The proprietary company that applies for, and holds, the ReOC. Its legal name is its name followed by "Pty Ltd", which must fit question 1 of the form. Its valid form is @Company@, and its unfilled form @UnfilledCompany@.
data Company' a1 a2 a3 a4 a5 a6 a7 a8 = Company' a1 a2 a3 a4 a5 a6 a7 a8
deriving (Eq, Ord, Show)
-- | The name of the data type @Company'@.
class Company'Like p f x x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' a8 a8' | x -> a1 a2 a3 a4 a5 a6 a7 a8 where
company' ::
Optic p f x x' (Company' a1 a2 a3 a4 a5 a6 a7 a8) (Company' a1' a2' a3' a4' a5' a6' a7' a8')
-- | Identity
instance (x' ~ Company' a1' a2' a3' a4' a5' a6' a7' a8') => Company'Like p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a1 a1' a2 a2' a3 a3' a4 a4' a5 a5' a6 a6' a7 a7' a8 a8' where
company' = id
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1' a2 a3 a4 a5 a6 a7 a8) => CompanyNameLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a1 a1' where
companyName f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x1' -> Company' x1' x2 x3 x4 x5 x6 x7 x8) (f x1)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2' a3 a4 a5 a6 a7 a8) => AbnLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a2 a2' where
abn f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x2' -> Company' x1 x2' x3 x4 x5 x6 x7 x8) (f x2)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3' a4 a5 a6 a7 a8) => ArnLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a3 a3' where
arn f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x3' -> Company' x1 x2 x3' x4 x5 x6 x7 x8) (f x3)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3 a4' a5 a6 a7 a8) => RegisteredOfficeLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a4 a4' where
registeredOffice f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x4' -> Company' x1 x2 x3 x4' x5 x6 x7 x8) (f x4)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3 a4 a5' a6 a7 a8) => OperationalHeadquartersLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a5 a5' where
operationalHeadquarters f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x5' -> Company' x1 x2 x3 x4 x5' x6 x7 x8) (f x5)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3 a4 a5 a6' a7 a8) => PhoneNumberLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a6 a6' where
phoneNumber f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x6' -> Company' x1 x2 x3 x4 x5 x6' x7 x8) (f x6)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3 a4 a5 a6 a7' a8) => EmailAddressLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a7 a7' where
emailAddress f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (\x7' -> Company' x1 x2 x3 x4 x5 x6 x7' x8) (f x7)
-- | Lens
instance (p ~ (->), Functor f, x' ~ Company' a1 a2 a3 a4 a5 a6 a7 a8') => BusinessNameLike p f (Company' a1 a2 a3 a4 a5 a6 a7 a8) x' a8 a8' where
businessName f (Company' x1 x2 x3 x4 x5 x6 x7 x8) = fmap (Company' x1 x2 x3 x4 x5 x6 x7) (f x8)
{- | Rebuilds a value from the name of each field or constructor.
Laws:
> lawNamesCompany' == id
-}
lawNamesCompany' :: Company' a1 a2 a3 a4 a5 a6 a7 a8 -> Company' a1 a2 a3 a4 a5 a6 a7 a8
lawNamesCompany' s =
Company'
(view (cloneLens companyName) s)
(view (cloneLens abn) s)
(view (cloneLens arn) s)
(view (cloneLens registeredOffice) s)
(view (cloneLens operationalHeadquarters) s)
(view (cloneLens phoneNumber) s)
(view (cloneLens emailAddress) s)
(view (cloneLens businessName) s)
-- | A valid @Company'@.
type Company = Company' (FormText 'Narrow 185 1) ABN ARN Address OperationalHeadquarters PhoneNumber EmailAddress (Maybe FormLine)
-- | An unfilled @Company'@: each field holds what has been entered, if anything, to be checked by @fillCompany@.
type UnfilledCompany = Company' (Maybe Text) (Maybe Text) (Maybe Text) UnfilledAddress (Maybe UnfilledOperationalHeadquarters) (Maybe Text) (Maybe Text) (Maybe Text)
-- | Builds a valid @Company'@ with every @Maybe@ field @Nothing@ and every list (or @AtMost@) field empty.
mkCompany :: FormText 'Narrow 185 1 -> ABN -> ARN -> Address -> OperationalHeadquarters -> PhoneNumber -> EmailAddress -> Company
mkCompany x1 x2 x3 x4 x5 x6 x7 = Company' x1 x2 x3 x4 x5 x6 x7 Nothing
-- | An unfilled @Company'@ with nothing entered.
mkUnfilledCompany :: UnfilledCompany
mkUnfilledCompany =
Company'
Nothing
Nothing
Nothing
mkUnfilledAddress
Nothing
Nothing
Nothing
Nothing
-- | The classes that a data type holding @Company'@ in one field, or in one or more constructors, inherits.
type InheritCompany' s a1 a2 a3 a4 a5 a6 a7 a8 =
( Company'Like (->) (Const ()) s s a1 a1 a2 a2 a3 a3 a4 a4 a5 a5 a6 a6 a7 a7 a8 a8
, CompanyNameLike (->) (Const ()) s s a1 a1
, AbnLike (->) (Const ()) s s a2 a2
, ArnLike (->) (Const ()) s s a3 a3
, RegisteredOfficeLike (->) (Const ()) s s a4 a4
, OperationalHeadquartersLike (->) (Const ()) s s a5 a5
, PhoneNumberLike (->) (Const ()) s s a6 a6
, EmailAddressLike (->) (Const ()) s s a7 a7
, BusinessNameLike (->) (Const ()) s s a8 a8
)
-- | Checks that a data type inherits every class of @InheritCompany'@.
inheritCompany' :: (InheritCompany' s a1 a2 a3 a4 a5 a6 a7 a8) => proxy s -> ()
inheritCompany' _ = ()