{-# LANGUAGE GADTs #-}
-- | Defines core types for use with the Drasil document language ("Drasil.DocumentLanguage").
module Drasil.DocumentLanguage.Core where

import Drasil.DocumentLanguage.Definitions (Fields)
import Drasil.DocumentLanguage.TraceabilityMatrix (TraceViewCat)
import Language.Drasil hiding (Manual, Verb) -- Manual - Citation name conflict. FIXME: Move to different namespace
import Theory.Drasil (DataDefinition, GenDefn, InstanceModel, TheoryModel)


import Data.Generics.Multiplate (Multiplate(multiplate, mkPlate))

-- | Type synonym for clarity.
type System = Sentence
-- | Type synonym for clarity.
type DocKind = Sentence

-- * Document Types

-- | A document description is made up of document sections.
type DocDesc = [DocSection]

-- | Document sections are either Reference, Introduction, or Specific
-- System Description sections (for now!).
data DocSection = TableOfContents
                | RefSec RefSec
                | IntroSec IntroSec
                | StkhldrSec StkhldrSec
                | GSDSec GSDSec
                | SSDSec SSDSec
                | ReqrmntSec ReqrmntSec
                | LCsSec LCsSec
                | UCsSec UCsSec
                | TraceabilitySec TraceabilitySec
                | AuxConstntSec AuxConstntSec
                | Bibliography
                | AppndxSec AppndxSec
                | OffShelfSolnsSec OffShelfSolnsSec

-- ** Reference Material Section

-- | Reference section. Contents are top level followed by a list of subsections.
data RefSec = RefProg Contents [RefTab]

-- | Reference subsections (tables) made out of units or symbols (can be customized).
data RefTab where
  -- | Default table of units.
  TUnits :: RefTab
  -- | Customized introduction.
  TUnits' :: [TUIntro] -> ([UnitDefn] -> LabelledContent) -> RefTab
  -- | Adds an introduction for a table of symbols.
  TSymb :: [TSIntro] -> RefTab
  -- | Allows Lens functions in addition to an introduction for a table of symbols.
  TSymb' :: LFunc -> [TSIntro] -> RefTab
  -- | Default.
  TAandA :: RefTab
  -- add more here

-- | For creating a table of symbols introduction
data TSIntro = TypogConvention [TConvention] -- ^ Typographic conventions used.
             | SymbOrder -- ^ Symbol ordering (defaults to alphabetical).
             | SymbConvention [Literature] -- ^ Symbol conventions match specified literature.
             | TSPurpose -- ^ Purpose of the Table of Symbols.
             | VectorUnits -- ^ Definition of vector components.

-- | Possible typographic conventions.
data TConvention = Vector Emphasis -- ^ How vectors are emphasized.
                 | Verb Sentence -- ^ Verbatim for specialized conventions.

-- | How to handle emphasis of words.
data Emphasis = Bold
              | Italics

instance Show Emphasis where
  show :: Emphasis -> String
show Emphasis
Bold = String
"bold"
  show Emphasis
Italics = String
"italics"

-- | Types of literature.
data Literature = Lit Topic -- ^ Literature (with a Topic).
                | Doc Topic -- ^ Existing documentation for (singular topic).
                | Doc' Topic -- ^ Existing documentation for (plural version of topic).
                | Manual Topic -- ^ Manual.

-- | Type synonym for clarity.
type Topic = IdeaDict

-- | For creating the table of units introduction.
data TUIntro = System -- ^ System of units (defaults to SI).
             | Derived -- ^ Sentence about derived units being used alongside SI.
             | TUPurpose -- ^ Purpose of the table of units.

-- | Lens (lookup) functions (currently for TSymb).
data LFunc where
  Term :: LFunc
  Defn :: LFunc
  TermExcept :: [DefinedQuantityDict] -> LFunc
  DefnExcept :: [DefinedQuantityDict] -> LFunc
  TAD :: LFunc -- ^ Term and Definition.

-- ** Introduction Section

-- | Introduction section. Contents are top level followed by a list of
-- subsections.
data IntroSec = IntroProg Sentence Sentence [IntroSub]
  -- ^ Temporary, will be modified once we've figured out more about the section.

-- | Introduction subsections.
data IntroSub where
  -- | Describes purpose of the system.
  IPurpose :: [Sentence] -> IntroSub
  -- | Describes scope of the system.
  IScope   :: Sentence -> IntroSub
  -- | Describes characteristics of the system.
  IChar   :: [Sentence] -> [Sentence] -> [Sentence] -> IntroSub
  -- | Organises the section.
  IOrgSec  :: CI -> Section -> Sentence -> IntroSub

-- ** Stakeholders Section

-- | Stakeholders section (wraps stakeholders subsections 'StkhldrSub').
newtype StkhldrSec = StkhldrProg [StkhldrSub]

-- | Stakeholders subsections.
data StkhldrSub where
  -- | May have a client.
  Client :: CI -> Sentence -> StkhldrSub 
  -- | May have a customer.
  Cstmr  :: CI -> StkhldrSub 

-- ** General System Description Section

-- | General System Description section (wraps 'GSDSub' subsections).
newtype GSDSec = GSDProg [GSDSub]

-- | General System Description subsections.
data GSDSub where
  -- | System context.
  SysCntxt   :: [Contents] -> GSDSub --FIXME: partially automate
  -- | User characteristics.
  UsrChars   :: [Contents] -> GSDSub 
  -- | System constraints.
  SystCons   :: [Contents] -> [Section] -> GSDSub 

-- ** Specific System Description Section

-- | Specific System Description section. Contains a list of subsections ('SSDSub').
newtype SSDSec = SSDProg [SSDSub]

-- | Specific System Description subsections.
data SSDSub where
  -- | System description problems.
  SSDProblem :: ProblemDescription -> SSDSub
  -- | Solution characteristics specification.
  SSDSolChSpec :: SolChSpec -> SSDSub

-- | Problem Description section. Contains an intro or title,
-- 'Section's, and problem description subsections ('PDSub').
data ProblemDescription where
  PDProg :: Sentence -> [Section] -> [PDSub] -> ProblemDescription

-- | Problem Description subsections.
data PDSub where
  -- | Terms and definitions.
  TermsAndDefs :: Concept c => Maybe Sentence -> [c] -> PDSub
  -- | Physical system description.
  PhySysDesc :: Idea a => a -> [Sentence] -> LabelledContent -> [Contents] -> PDSub
  -- | Goals.
  Goals :: [Sentence] -> [ConceptInstance] -> PDSub

-- | Solution Characteristics Specification section. Contains a list of subsections ('SCSSub').
data SolChSpec where
  SCSProg :: [SCSSub] -> SolChSpec

-- | Solution Characteristics Specification subsections.
data SCSSub where
  -- | Assumptions.
  Assumptions    :: [ConceptInstance] -> SCSSub
  -- | Theory Models.
  TMs            :: [Sentence] -> Fields  -> [TheoryModel] -> SCSSub
  -- | General Definitions.
  GDs            :: [Sentence] -> Fields  -> [GenDefn] -> DerivationDisplay -> SCSSub
  -- | Data Definitions.
  DDs            :: [Sentence] -> Fields  -> [DataDefinition] -> DerivationDisplay -> SCSSub -- (FIXME: Need DD intro).
  -- | Instance Models.
  IMs            :: [Sentence] -> Fields  -> [InstanceModel] -> DerivationDisplay -> SCSSub
  -- | Constraints.
  Constraints    :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) => Sentence -> [c] -> SCSSub 
  --                  Sentence -> [LabelledContent] Fields  -> [UncertainWrapper] -> [ConstrainedChunk] -> SCSSub --FIXME: temporary definition?
  --FIXME: Work in Progress ^
  -- | Properties of a correct solution.
  CorrSolnPpties :: (Quantity c, Constrained c) => [c] -> [Contents] -> SCSSub

-- | Choose whether to show or hide the derivation of an expression.
data DerivationDisplay = ShowDerivation
                       | HideDerivation

-- ** Requirements Section

-- | Requirements section. Contains a list of subsections ('ReqsSub').
newtype ReqrmntSec = ReqsProg [ReqsSub]

-- | Requirements subsections. 
data ReqsSub where
  -- | Functional requirements. LabelledContent needed for tables.  
  FReqsSub'   :: [ConceptInstance] -> [LabelledContent] -> ReqsSub
  -- | Functional requirements. LabelledContent needed for tables.
  FReqsSub    :: [ConceptInstance] -> [LabelledContent] -> ReqsSub
  -- | Non-functional requirements.
  NonFReqsSub :: [ConceptInstance] -> ReqsSub

-- ** Likely Changes Section

-- | Likely Changes section.
newtype LCsSec = LCsProg [ConceptInstance]

-- ** Unlikely Changes Section

-- | Unlikely Changes section.
newtype UCsSec = UCsProg [ConceptInstance]

-- ** Traceability Section

-- | Traceability Matices and Graphs section. Contains configurations ('TraceConfig').
newtype TraceabilitySec = TraceabilityProg [TraceConfig]

-- | Traceability Matices and Graphs configurations.
data TraceConfig = TraceConfig UID [Sentence] Sentence [TraceViewCat] [TraceViewCat]

getTraceConfigUID :: TraceConfig -> UID
getTraceConfigUID :: TraceConfig -> UID
getTraceConfigUID (TraceConfig UID
a [Sentence]
_ Sentence
_ [TraceViewCat]
_ [TraceViewCat]
_) = UID
a

-- ** Off-The-Shelf Solutions Section

-- | Off-The-Shelf Solutions section.
newtype OffShelfSolnsSec = OffShelfSolnsProg [Contents]

-- ** Values of Auxiliary Constants Section

-- | Values of Auxiliary Constants section.
data AuxConstntSec = AuxConsProg CI [ConstQDef]

-- ** Appendix Section

-- | Appendix section.
newtype AppndxSec = AppndxProg [Contents]

-- * Multiplate Definition and Type

-- | Holds all of the different kinds of sections. Defines as a plate with an applicative functor.
data DLPlate f = DLPlate {
  forall (f :: * -> *). DLPlate f -> DocSection -> f DocSection
docSec :: DocSection -> f DocSection,
  forall (f :: * -> *). DLPlate f -> RefSec -> f RefSec
refSec :: RefSec -> f RefSec,
  forall (f :: * -> *). DLPlate f -> IntroSec -> f IntroSec
introSec :: IntroSec -> f IntroSec,
  forall (f :: * -> *). DLPlate f -> IntroSub -> f IntroSub
introSub :: IntroSub -> f IntroSub,
  forall (f :: * -> *). DLPlate f -> StkhldrSec -> f StkhldrSec
stkSec :: StkhldrSec -> f StkhldrSec,
  forall (f :: * -> *). DLPlate f -> StkhldrSub -> f StkhldrSub
stkSub :: StkhldrSub -> f StkhldrSub,
  forall (f :: * -> *). DLPlate f -> GSDSec -> f GSDSec
gsdSec :: GSDSec -> f GSDSec,
  forall (f :: * -> *). DLPlate f -> GSDSub -> f GSDSub
gsdSub :: GSDSub -> f GSDSub,
  forall (f :: * -> *). DLPlate f -> SSDSec -> f SSDSec
ssdSec :: SSDSec -> f SSDSec,
  forall (f :: * -> *). DLPlate f -> SSDSub -> f SSDSub
ssdSub :: SSDSub -> f SSDSub,
  forall (f :: * -> *).
DLPlate f -> ProblemDescription -> f ProblemDescription
pdSec :: ProblemDescription -> f ProblemDescription,
  forall (f :: * -> *). DLPlate f -> PDSub -> f PDSub
pdSub :: PDSub -> f PDSub,
  forall (f :: * -> *). DLPlate f -> SCSSub -> f SCSSub
scsSub :: SCSSub -> f SCSSub,
  forall (f :: * -> *). DLPlate f -> ReqrmntSec -> f ReqrmntSec
reqSec :: ReqrmntSec -> f ReqrmntSec,
  forall (f :: * -> *). DLPlate f -> ReqsSub -> f ReqsSub
reqSub :: ReqsSub -> f ReqsSub,
  forall (f :: * -> *). DLPlate f -> LCsSec -> f LCsSec
lcsSec :: LCsSec -> f LCsSec,
  forall (f :: * -> *). DLPlate f -> UCsSec -> f UCsSec
ucsSec :: UCsSec -> f UCsSec,
  forall (f :: * -> *).
DLPlate f -> TraceabilitySec -> f TraceabilitySec
traceSec :: TraceabilitySec -> f TraceabilitySec,
  forall (f :: * -> *).
DLPlate f -> OffShelfSolnsSec -> f OffShelfSolnsSec
offShelfSec :: OffShelfSolnsSec -> f OffShelfSolnsSec,
  forall (f :: * -> *). DLPlate f -> AuxConstntSec -> f AuxConstntSec
auxConsSec :: AuxConstntSec -> f AuxConstntSec,
  forall (f :: * -> *). DLPlate f -> AppndxSec -> f AppndxSec
appendSec :: AppndxSec -> f AppndxSec
}

-- | Holds boilerplate code to make getting sections easier.
instance Multiplate DLPlate where
  multiplate :: forall (f :: * -> *). Applicative f => DLPlate f -> DLPlate f
multiplate DLPlate f
p = forall (f :: * -> *).
(DocSection -> f DocSection)
-> (RefSec -> f RefSec)
-> (IntroSec -> f IntroSec)
-> (IntroSub -> f IntroSub)
-> (StkhldrSec -> f StkhldrSec)
-> (StkhldrSub -> f StkhldrSub)
-> (GSDSec -> f GSDSec)
-> (GSDSub -> f GSDSub)
-> (SSDSec -> f SSDSec)
-> (SSDSub -> f SSDSub)
-> (ProblemDescription -> f ProblemDescription)
-> (PDSub -> f PDSub)
-> (SCSSub -> f SCSSub)
-> (ReqrmntSec -> f ReqrmntSec)
-> (ReqsSub -> f ReqsSub)
-> (LCsSec -> f LCsSec)
-> (UCsSec -> f UCsSec)
-> (TraceabilitySec -> f TraceabilitySec)
-> (OffShelfSolnsSec -> f OffShelfSolnsSec)
-> (AuxConstntSec -> f AuxConstntSec)
-> (AppndxSec -> f AppndxSec)
-> DLPlate f
DLPlate DocSection -> f DocSection
ds forall {f :: * -> *}. Applicative f => RefSec -> f RefSec
res IntroSec -> f IntroSec
intro forall {f :: * -> *}. Applicative f => IntroSub -> f IntroSub
intro' StkhldrSec -> f StkhldrSec
stk forall {f :: * -> *}. Applicative f => StkhldrSub -> f StkhldrSub
stk' GSDSec -> f GSDSec
gs forall {f :: * -> *}. Applicative f => GSDSub -> f GSDSub
gs' SSDSec -> f SSDSec
ss SSDSub -> f SSDSub
ss' ProblemDescription -> f ProblemDescription
pd forall {f :: * -> *}. Applicative f => PDSub -> f PDSub
pd' forall {f :: * -> *}. Applicative f => SCSSub -> f SCSSub
sc
    ReqrmntSec -> f ReqrmntSec
rs forall {f :: * -> *}. Applicative f => ReqsSub -> f ReqsSub
rs' forall {f :: * -> *}. Applicative f => LCsSec -> f LCsSec
lcp forall {f :: * -> *}. Applicative f => UCsSec -> f UCsSec
ucp forall {f :: * -> *}.
Applicative f =>
TraceabilitySec -> f TraceabilitySec
ts forall {f :: * -> *}.
Applicative f =>
OffShelfSolnsSec -> f OffShelfSolnsSec
es forall {f :: * -> *}.
Applicative f =>
AuxConstntSec -> f AuxConstntSec
acs forall {f :: * -> *}. Applicative f => AppndxSec -> f AppndxSec
aps where
    ds :: DocSection -> f DocSection
ds DocSection
TableOfContents = forall (f :: * -> *) a. Applicative f => a -> f a
pure DocSection
TableOfContents
    ds (RefSec RefSec
x) = RefSec -> DocSection
RefSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> RefSec -> f RefSec
refSec DLPlate f
p RefSec
x
    ds (IntroSec IntroSec
x) = IntroSec -> DocSection
IntroSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> IntroSec -> f IntroSec
introSec DLPlate f
p IntroSec
x
    ds (StkhldrSec StkhldrSec
x) = StkhldrSec -> DocSection
StkhldrSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> StkhldrSec -> f StkhldrSec
stkSec DLPlate f
p StkhldrSec
x
    ds (GSDSec GSDSec
x) = GSDSec -> DocSection
GSDSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> GSDSec -> f GSDSec
gsdSec DLPlate f
p GSDSec
x
    ds (SSDSec SSDSec
x) = SSDSec -> DocSection
SSDSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> SSDSec -> f SSDSec
ssdSec DLPlate f
p SSDSec
x
    ds (ReqrmntSec ReqrmntSec
x) = ReqrmntSec -> DocSection
ReqrmntSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> ReqrmntSec -> f ReqrmntSec
reqSec DLPlate f
p ReqrmntSec
x
    ds (LCsSec LCsSec
x) = LCsSec -> DocSection
LCsSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> LCsSec -> f LCsSec
lcsSec DLPlate f
p LCsSec
x
    ds (UCsSec UCsSec
x) = UCsSec -> DocSection
UCsSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> UCsSec -> f UCsSec
ucsSec DLPlate f
p UCsSec
x
    ds (TraceabilitySec TraceabilitySec
x) = TraceabilitySec -> DocSection
TraceabilitySec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *).
DLPlate f -> TraceabilitySec -> f TraceabilitySec
traceSec DLPlate f
p TraceabilitySec
x
    ds (OffShelfSolnsSec OffShelfSolnsSec
x) = OffShelfSolnsSec -> DocSection
OffShelfSolnsSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *).
DLPlate f -> OffShelfSolnsSec -> f OffShelfSolnsSec
offShelfSec DLPlate f
p OffShelfSolnsSec
x
    ds (AuxConstntSec AuxConstntSec
x) = AuxConstntSec -> DocSection
AuxConstntSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> AuxConstntSec -> f AuxConstntSec
auxConsSec DLPlate f
p AuxConstntSec
x
    ds (AppndxSec AppndxSec
x) = AppndxSec -> DocSection
AppndxSec forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *). DLPlate f -> AppndxSec -> f AppndxSec
appendSec DLPlate f
p AppndxSec
x
    ds DocSection
Bibliography = forall (f :: * -> *) a. Applicative f => a -> f a
pure DocSection
Bibliography

    res :: RefSec -> f RefSec
res (RefProg Contents
c [RefTab]
x) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Contents -> [RefTab] -> RefSec
RefProg Contents
c [RefTab]
x
    intro :: IntroSec -> f IntroSec
intro (IntroProg Sentence
s1 Sentence
s2 [IntroSub]
progs) = Sentence -> Sentence -> [IntroSub] -> IntroSec
IntroProg Sentence
s1 Sentence
s2 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> IntroSub -> f IntroSub
introSub DLPlate f
p) [IntroSub]
progs
    intro' :: IntroSub -> f IntroSub
intro' (IPurpose [Sentence]
s) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence] -> IntroSub
IPurpose [Sentence]
s
    intro' (IScope Sentence
s) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Sentence -> IntroSub
IScope Sentence
s
    intro' (IChar [Sentence]
s1 [Sentence]
s2 [Sentence]
s3) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence] -> [Sentence] -> [Sentence] -> IntroSub
IChar [Sentence]
s1 [Sentence]
s2 [Sentence]
s3
    intro' (IOrgSec CI
c Section
sect Sentence
s2) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ CI -> Section -> Sentence -> IntroSub
IOrgSec CI
c Section
sect Sentence
s2
    stk :: StkhldrSec -> f StkhldrSec
stk (StkhldrProg [StkhldrSub]
progs) = [StkhldrSub] -> StkhldrSec
StkhldrProg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> StkhldrSub -> f StkhldrSub
stkSub DLPlate f
p) [StkhldrSub]
progs
    stk' :: StkhldrSub -> f StkhldrSub
stk' (Client CI
c Sentence
s) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ CI -> Sentence -> StkhldrSub
Client CI
c Sentence
s
    stk' (Cstmr CI
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure (CI -> StkhldrSub
Cstmr CI
c)
    gs :: GSDSec -> f GSDSec
gs (GSDProg [GSDSub]
x) = [GSDSub] -> GSDSec
GSDProg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> GSDSub -> f GSDSub
gsdSub DLPlate f
p) [GSDSub]
x
    gs' :: GSDSub -> f GSDSub
gs' (SysCntxt [Contents]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> GSDSub
SysCntxt [Contents]
c
    gs' (UsrChars [Contents]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> GSDSub
UsrChars [Contents]
c
    gs' (SystCons [Contents]
c [Section]
s) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> [Section] -> GSDSub
SystCons [Contents]
c [Section]
s
    ss :: SSDSec -> f SSDSec
ss (SSDProg [SSDSub]
progs) = [SSDSub] -> SSDSec
SSDProg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> SSDSub -> f SSDSub
ssdSub DLPlate f
p) [SSDSub]
progs
    ss' :: SSDSub -> f SSDSub
ss' (SSDProblem ProblemDescription
prog) = ProblemDescription -> SSDSub
SSDProblem forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *).
DLPlate f -> ProblemDescription -> f ProblemDescription
pdSec DLPlate f
p ProblemDescription
prog
    ss' (SSDSolChSpec (SCSProg [SCSSub]
spec)) = SolChSpec -> SSDSub
SSDSolChSpec forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SCSSub] -> SolChSpec
SCSProg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> SCSSub -> f SCSSub
scsSub DLPlate f
p) [SCSSub]
spec
    pd :: ProblemDescription -> f ProblemDescription
pd (PDProg Sentence
s [Section]
sect [PDSub]
progs) = Sentence -> [Section] -> [PDSub] -> ProblemDescription
PDProg Sentence
s [Section]
sect forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> PDSub -> f PDSub
pdSub DLPlate f
p) [PDSub]
progs
    pd' :: PDSub -> f PDSub
pd' (TermsAndDefs Maybe Sentence
s [c]
cs) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall c. Concept c => Maybe Sentence -> [c] -> PDSub
TermsAndDefs Maybe Sentence
s [c]
cs
    pd' (Goals [Sentence]
s [ConceptInstance]
ci) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence] -> [ConceptInstance] -> PDSub
Goals [Sentence]
s [ConceptInstance]
ci
    pd' (PhySysDesc a
nm [Sentence]
s LabelledContent
lc [Contents]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall c.
Idea c =>
c -> [Sentence] -> LabelledContent -> [Contents] -> PDSub
PhySysDesc a
nm [Sentence]
s LabelledContent
lc [Contents]
c
    sc :: SCSSub -> f SCSSub
sc (Assumptions [ConceptInstance]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ConceptInstance] -> SCSSub
Assumptions [ConceptInstance]
c)
    sc (TMs [Sentence]
s Fields
f [TheoryModel]
t) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence] -> Fields -> [TheoryModel] -> SCSSub
TMs [Sentence]
s Fields
f [TheoryModel]
t
    sc (GDs [Sentence]
s Fields
f [GenDefn]
g DerivationDisplay
d) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence] -> Fields -> [GenDefn] -> DerivationDisplay -> SCSSub
GDs [Sentence]
s Fields
f [GenDefn]
g DerivationDisplay
d
    sc (DDs [Sentence]
s Fields
f [DataDefinition]
dd DerivationDisplay
d) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence]
-> Fields -> [DataDefinition] -> DerivationDisplay -> SCSSub
DDs [Sentence]
s Fields
f [DataDefinition]
dd DerivationDisplay
d
    sc (IMs [Sentence]
s Fields
f [InstanceModel]
i DerivationDisplay
d) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Sentence]
-> Fields -> [InstanceModel] -> DerivationDisplay -> SCSSub
IMs [Sentence]
s Fields
f [InstanceModel]
i DerivationDisplay
d 
    sc (Constraints Sentence
s [c]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall c.
(HasUncertainty c, Quantity c, Constrained c, HasReasVal c,
 MayHaveUnit c) =>
Sentence -> [c] -> SCSSub
Constraints Sentence
s [c]
c
    sc (CorrSolnPpties [c]
c [Contents]
cs) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall c.
(Quantity c, Constrained c) =>
[c] -> [Contents] -> SCSSub
CorrSolnPpties [c]
c [Contents]
cs
    rs :: ReqrmntSec -> f ReqrmntSec
rs (ReqsProg [ReqsSub]
reqs) = [ReqsSub] -> ReqrmntSec
ReqsProg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *). DLPlate f -> ReqsSub -> f ReqsSub
reqSub DLPlate f
p) [ReqsSub]
reqs
    rs' :: ReqsSub -> f ReqsSub
rs' (FReqsSub [ConceptInstance]
ci [LabelledContent]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [ConceptInstance] -> [LabelledContent] -> ReqsSub
FReqsSub [ConceptInstance]
ci [LabelledContent]
con
    rs' (FReqsSub' [ConceptInstance]
ci [LabelledContent]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [ConceptInstance] -> [LabelledContent] -> ReqsSub
FReqsSub' [ConceptInstance]
ci [LabelledContent]
con
    rs' (NonFReqsSub [ConceptInstance]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [ConceptInstance] -> ReqsSub
NonFReqsSub [ConceptInstance]
c
    lcp :: LCsSec -> f LCsSec
lcp (LCsProg [ConceptInstance]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [ConceptInstance] -> LCsSec
LCsProg [ConceptInstance]
c
    ucp :: UCsSec -> f UCsSec
ucp (UCsProg [ConceptInstance]
c) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [ConceptInstance] -> UCsSec
UCsProg [ConceptInstance]
c
    ts :: TraceabilitySec -> f TraceabilitySec
ts (TraceabilityProg [TraceConfig]
progs) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [TraceConfig] -> TraceabilitySec
TraceabilityProg [TraceConfig]
progs
    es :: OffShelfSolnsSec -> f OffShelfSolnsSec
es (OffShelfSolnsProg [Contents]
contents) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> OffShelfSolnsSec
OffShelfSolnsProg [Contents]
contents
    acs :: AuxConstntSec -> f AuxConstntSec
acs (AuxConsProg CI
ci [ConstQDef]
qdef) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ CI -> [ConstQDef] -> AuxConstntSec
AuxConsProg CI
ci [ConstQDef]
qdef
    aps :: AppndxSec -> f AppndxSec
aps (AppndxProg [Contents]
con) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ [Contents] -> AppndxSec
AppndxProg [Contents]
con
  mkPlate :: forall (f :: * -> *).
(forall a. Projector DLPlate a -> a -> f a) -> DLPlate f
mkPlate forall a. Projector DLPlate a -> a -> f a
b = forall (f :: * -> *).
(DocSection -> f DocSection)
-> (RefSec -> f RefSec)
-> (IntroSec -> f IntroSec)
-> (IntroSub -> f IntroSub)
-> (StkhldrSec -> f StkhldrSec)
-> (StkhldrSub -> f StkhldrSub)
-> (GSDSec -> f GSDSec)
-> (GSDSub -> f GSDSub)
-> (SSDSec -> f SSDSec)
-> (SSDSub -> f SSDSub)
-> (ProblemDescription -> f ProblemDescription)
-> (PDSub -> f PDSub)
-> (SCSSub -> f SCSSub)
-> (ReqrmntSec -> f ReqrmntSec)
-> (ReqsSub -> f ReqsSub)
-> (LCsSec -> f LCsSec)
-> (UCsSec -> f UCsSec)
-> (TraceabilitySec -> f TraceabilitySec)
-> (OffShelfSolnsSec -> f OffShelfSolnsSec)
-> (AuxConstntSec -> f AuxConstntSec)
-> (AppndxSec -> f AppndxSec)
-> DLPlate f
DLPlate (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> DocSection -> f DocSection
docSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> RefSec -> f RefSec
refSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> IntroSec -> f IntroSec
introSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> IntroSub -> f IntroSub
introSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> StkhldrSec -> f StkhldrSec
stkSec)
    (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> StkhldrSub -> f StkhldrSub
stkSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> GSDSec -> f GSDSec
gsdSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> GSDSub -> f GSDSub
gsdSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> SSDSec -> f SSDSec
ssdSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> SSDSub -> f SSDSub
ssdSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *).
DLPlate f -> ProblemDescription -> f ProblemDescription
pdSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> PDSub -> f PDSub
pdSub)
    (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> SCSSub -> f SCSSub
scsSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> ReqrmntSec -> f ReqrmntSec
reqSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> ReqsSub -> f ReqsSub
reqSub) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> LCsSec -> f LCsSec
lcsSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> UCsSec -> f UCsSec
ucsSec)
    (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *).
DLPlate f -> TraceabilitySec -> f TraceabilitySec
traceSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *).
DLPlate f -> OffShelfSolnsSec -> f OffShelfSolnsSec
offShelfSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> AuxConstntSec -> f AuxConstntSec
auxConsSec) (forall a. Projector DLPlate a -> a -> f a
b forall (f :: * -> *). DLPlate f -> AppndxSec -> f AppndxSec
appendSec)