{-# LANGUAGE LambdaCase, Rank2Types #-}
module Drasil.ExtractDocDesc (getDocDesc, egetDocDesc, sentencePlate) where
import Control.Lens((^.))
import Drasil.DocumentLanguage.Core
import Drasil.Sections.SpecificSystemDescription (inDataConstTbl, outDataConstTbl)
import Language.Drasil hiding (Manual, Verb)
import Theory.Drasil
import Data.List(transpose)
import Data.Functor.Constant (Constant(Constant))
import Data.Generics.Multiplate (appendPlate, foldFor, purePlate, preorderFold)
secConPlate :: Monoid b => (forall a. HasContents a => [a] -> b) ->
([Section] -> b) -> DLPlate (Constant b)
secConPlate :: (forall a. HasContents a => [a] -> b)
-> ([Section] -> b) -> DLPlate (Constant b)
secConPlate mCon :: forall a. HasContents a => [a] -> b
mCon mSec :: [Section] -> b
mSec = DLPlate (Constant b) -> DLPlate (Constant b)
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o)
preorderFold (DLPlate (Constant b) -> DLPlate (Constant b))
-> DLPlate (Constant b) -> DLPlate (Constant b)
forall a b. (a -> b) -> a -> b
$ DLPlate (Constant b)
forall (p :: (* -> *) -> *) (f :: * -> *).
(Multiplate p, Applicative f) =>
p f
purePlate {
refSec :: RefSec -> Constant b RefSec
refSec = b -> Constant b RefSec
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b RefSec)
-> (RefSec -> b) -> RefSec -> Constant b RefSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(RefProg c :: Contents
c _) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents
c],
introSub :: IntroSub -> Constant b IntroSub
introSub = b -> Constant b IntroSub
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b IntroSub)
-> (IntroSub -> b) -> IntroSub -> Constant b IntroSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(IOrgSec _ _ s :: Section
s _) -> [Section] -> b
mSec [Section
s]
_ -> b
forall a. Monoid a => a
mempty,
gsdSub :: GSDSub -> Constant b GSDSub
gsdSub = b -> Constant b GSDSub
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b GSDSub)
-> (GSDSub -> b) -> GSDSub -> Constant b GSDSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(SysCntxt c :: [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
(UsrChars c :: [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
(SystCons c :: [Contents]
c s :: [Section]
s) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` [Section] -> b
mSec [Section]
s,
pdSec :: ProblemDescription -> Constant b ProblemDescription
pdSec = b -> Constant b ProblemDescription
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b ProblemDescription)
-> (ProblemDescription -> b)
-> ProblemDescription
-> Constant b ProblemDescription
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(PDProg _ s :: [Section]
s _) -> [Section] -> b
mSec [Section]
s,
pdSub :: PDSub -> Constant b PDSub
pdSub = b -> Constant b PDSub
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b PDSub)
-> (PDSub -> b) -> PDSub -> Constant b PDSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(TermsAndDefs _ _) -> b
forall a. Monoid a => a
mempty
(PhySysDesc _ _ lc :: LabelledContent
lc c :: [Contents]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [LabelledContent
lc] b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
(Goals _ _) -> b
forall a. Monoid a => a
mempty,
scsSub :: SCSSub -> Constant b SCSSub
scsSub = b -> Constant b SCSSub
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b SCSSub)
-> (SCSSub -> b) -> SCSSub -> Constant b SCSSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(Constraints _ c :: [c]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [[c] -> LabelledContent
forall c.
(HasUncertainty c, Quantity c, Constrained c, HasReasVal c,
MayHaveUnit c) =>
[c] -> LabelledContent
inDataConstTbl [c]
c]
(CorrSolnPpties c :: [c]
c cs :: [Contents]
cs) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [[c] -> LabelledContent
forall c. (Quantity c, Constrained c) => [c] -> LabelledContent
outDataConstTbl [c]
c] b -> b -> b
forall a. Monoid a => a -> a -> a
`mappend` [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
cs
_ -> b
forall a. Monoid a => a
mempty,
reqSub :: ReqsSub -> Constant b ReqsSub
reqSub = b -> Constant b ReqsSub
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b ReqsSub)
-> (ReqsSub -> b) -> ReqsSub -> Constant b ReqsSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(FReqsSub' _ c :: [LabelledContent]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [LabelledContent]
c
(FReqsSub _ c :: [LabelledContent]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [LabelledContent]
c
(NonFReqsSub _) -> b
forall a. Monoid a => a
mempty,
offShelfSec :: OffShelfSolnsSec -> Constant b OffShelfSolnsSec
offShelfSec = b -> Constant b OffShelfSolnsSec
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b OffShelfSolnsSec)
-> (OffShelfSolnsSec -> b)
-> OffShelfSolnsSec
-> Constant b OffShelfSolnsSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(OffShelfSolnsProg c :: [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c,
appendSec :: AppndxSec -> Constant b AppndxSec
appendSec = b -> Constant b AppndxSec
forall k a (b :: k). a -> Constant a b
Constant (b -> Constant b AppndxSec)
-> (AppndxSec -> b) -> AppndxSec -> Constant b AppndxSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(AppndxProg c :: [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
}
exprPlate :: DLPlate (Constant [ModelExpr])
exprPlate :: DLPlate (Constant [ModelExpr])
exprPlate = ([Sentence] -> [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall a. Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate ((Sentence -> [ModelExpr]) -> [Sentence] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Sentence -> [ModelExpr]
sentToExp) DLPlate (Constant [ModelExpr])
-> DLPlate (Constant [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o) -> p (Constant o)
`appendPlate` (forall a. HasContents a => [a] -> [ModelExpr])
-> ([Section] -> [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall b.
Monoid b =>
(forall a. HasContents a => [a] -> b)
-> ([Section] -> b) -> DLPlate (Constant b)
secConPlate ((a -> [ModelExpr]) -> [a] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap a -> [ModelExpr]
forall a. HasContents a => a -> [ModelExpr]
egetCon')
((Section -> [ModelExpr]) -> [Section] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Section -> [ModelExpr]
egetSec) DLPlate (Constant [ModelExpr])
-> DLPlate (Constant [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o) -> p (Constant o)
`appendPlate` (DLPlate (Constant [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o)
preorderFold (DLPlate (Constant [ModelExpr]) -> DLPlate (Constant [ModelExpr]))
-> DLPlate (Constant [ModelExpr]) -> DLPlate (Constant [ModelExpr])
forall a b. (a -> b) -> a -> b
$ DLPlate (Constant [ModelExpr])
forall (p :: (* -> *) -> *) (f :: * -> *).
(Multiplate p, Applicative f) =>
p f
purePlate {
scsSub :: SCSSub -> Constant [ModelExpr] SCSSub
scsSub = [ModelExpr] -> Constant [ModelExpr] SCSSub
forall k a (b :: k). a -> Constant a b
Constant ([ModelExpr] -> Constant [ModelExpr] SCSSub)
-> (SCSSub -> [ModelExpr]) -> SCSSub -> Constant [ModelExpr] SCSSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(TMs _ _ t :: [TheoryModel]
t) -> [TheoryModel] -> [ModelExpr]
goTM [TheoryModel]
t
(DDs _ _ d :: [DataDefinition]
d _) -> [DataDefinition] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [DataDefinition]
d
(GDs _ _ g :: [GenDefn]
g _) -> [GenDefn] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [GenDefn]
g
(IMs _ _ i :: [InstanceModel]
i _) -> [InstanceModel] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [InstanceModel]
i
_ -> [],
auxConsSec :: AuxConstntSec -> Constant [ModelExpr] AuxConstntSec
auxConsSec = [ModelExpr] -> Constant [ModelExpr] AuxConstntSec
forall k a (b :: k). a -> Constant a b
Constant ([ModelExpr] -> Constant [ModelExpr] AuxConstntSec)
-> (AuxConstntSec -> [ModelExpr])
-> AuxConstntSec
-> Constant [ModelExpr] AuxConstntSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(AuxConsProg _ qdef :: [ConstQDef]
qdef) -> [ConstQDef] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [ConstQDef]
qdef
}) where
go :: Express a => [a] -> [ModelExpr]
go :: [a] -> [ModelExpr]
go = (a -> ModelExpr) -> [a] -> [ModelExpr]
forall a b. (a -> b) -> [a] -> [b]
map a -> ModelExpr
forall c. Express c => c -> ModelExpr
express
goTM :: [TheoryModel] -> [ModelExpr]
goTM :: [TheoryModel] -> [ModelExpr]
goTM = (TheoryModel -> [ModelExpr]) -> [TheoryModel] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\x :: TheoryModel
x -> [ModelQDef] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go (TheoryModel
x TheoryModel
-> Getting [ModelQDef] TheoryModel [ModelQDef] -> [ModelQDef]
forall s a. s -> Getting a s a -> a
^. Getting [ModelQDef] TheoryModel [ModelQDef]
forall t. Theory t => Lens' t [ModelQDef]
defined_quant)
[ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ TheoryModel
x TheoryModel
-> Getting [ModelExpr] TheoryModel [ModelExpr] -> [ModelExpr]
forall s a. s -> Getting a s a -> a
^. Getting [ModelExpr] TheoryModel [ModelExpr]
forall t. Theory t => Lens' t [ModelExpr]
invariants
[ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [ModelExpr] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go ((ModelQDef -> ModelExpr) -> [ModelQDef] -> [ModelExpr]
forall a b. (a -> b) -> [a] -> [b]
map (ModelQDef -> Getting ModelExpr ModelQDef ModelExpr -> ModelExpr
forall s a. s -> Getting a s a -> a
^. Getting ModelExpr ModelQDef ModelExpr
forall (c :: * -> *) e. DefiningExpr c => Lens' (c e) e
defnExpr) (TheoryModel
x TheoryModel
-> Getting [ModelQDef] TheoryModel [ModelQDef] -> [ModelQDef]
forall s a. s -> Getting a s a -> a
^. Getting [ModelQDef] TheoryModel [ModelQDef]
forall t. Theory t => Lens' t [ModelQDef]
defined_quant [ModelQDef] -> [ModelQDef] -> [ModelQDef]
forall a. [a] -> [a] -> [a]
++ TheoryModel
x TheoryModel
-> Getting [ModelQDef] TheoryModel [ModelQDef] -> [ModelQDef]
forall s a. s -> Getting a s a -> a
^. Getting [ModelQDef] TheoryModel [ModelQDef]
forall t. Theory t => Lens' t [ModelQDef]
defined_fun))
[ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [TheoryModel] -> [ModelExpr]
goTM (TheoryModel
x TheoryModel
-> Getting [TheoryModel] TheoryModel [TheoryModel] -> [TheoryModel]
forall s a. s -> Getting a s a -> a
^. Getting [TheoryModel] TheoryModel [TheoryModel]
forall t. Theory t => Lens' t [TheoryModel]
valid_context))
sentToExp :: Sentence -> [ModelExpr]
sentToExp :: Sentence -> [ModelExpr]
sentToExp ((:+:) s1 :: Sentence
s1 s2 :: Sentence
s2) = Sentence -> [ModelExpr]
sentToExp Sentence
s1 [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ Sentence -> [ModelExpr]
sentToExp Sentence
s2
sentToExp (E e :: ModelExpr
e) = [ModelExpr
e]
sentToExp _ = []
fmGetDocDesc :: DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc :: DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc p :: DLPlate (Constant [a])
p = (DocSection -> [a]) -> DocDesc -> [a]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Projector DLPlate DocSection
-> DLPlate (Constant [a]) -> DocSection -> [a]
forall (p :: (* -> *) -> *) a o.
Multiplate p =>
Projector p a -> p (Constant o) -> a -> o
foldFor Projector DLPlate DocSection
docSec DLPlate (Constant [a])
p)
egetDocDesc :: DocDesc -> [ModelExpr]
egetDocDesc :: DocDesc -> [ModelExpr]
egetDocDesc = DLPlate (Constant [ModelExpr]) -> DocDesc -> [ModelExpr]
forall a. DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc DLPlate (Constant [ModelExpr])
exprPlate
egetSec :: Section -> [ModelExpr]
egetSec :: Section -> [ModelExpr]
egetSec (Section _ sc :: [SecCons]
sc _ ) = (SecCons -> [ModelExpr]) -> [SecCons] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap SecCons -> [ModelExpr]
egetSecCon [SecCons]
sc
egetSecCon :: SecCons -> [ModelExpr]
egetSecCon :: SecCons -> [ModelExpr]
egetSecCon (Sub s :: Section
s) = Section -> [ModelExpr]
egetSec Section
s
egetSecCon (Con c :: Contents
c) = Contents -> [ModelExpr]
forall a. HasContents a => a -> [ModelExpr]
egetCon' Contents
c
egetCon' :: HasContents a => a -> [ModelExpr]
egetCon' :: a -> [ModelExpr]
egetCon' = RawContent -> [ModelExpr]
egetCon (RawContent -> [ModelExpr])
-> (a -> RawContent) -> a -> [ModelExpr]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Getting RawContent a RawContent -> RawContent
forall s a. s -> Getting a s a -> a
^. Getting RawContent a RawContent
forall c. HasContents c => Lens' c RawContent
accessContents)
egetCon :: RawContent -> [ModelExpr]
egetCon :: RawContent -> [ModelExpr]
egetCon (EqnBlock e :: ModelExpr
e) = [ModelExpr
e]
egetCon (Defini _ []) = []
egetCon (Defini dt :: DType
dt (hd :: (Identifier, [Contents])
hd:tl :: [(Identifier, [Contents])]
tl)) = (Contents -> [ModelExpr]) -> [Contents] -> [ModelExpr]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Contents -> [ModelExpr]
forall a. HasContents a => a -> [ModelExpr]
egetCon' ((Identifier, [Contents]) -> [Contents]
forall a b. (a, b) -> b
snd (Identifier, [Contents])
hd) [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ RawContent -> [ModelExpr]
egetCon (DType -> [(Identifier, [Contents])] -> RawContent
Defini DType
dt [(Identifier, [Contents])]
tl)
egetCon _ = []
sentencePlate :: Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate :: ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate f :: [Sentence] -> a
f = DLPlate (Constant a)
-> DLPlate (Constant a) -> DLPlate (Constant a)
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o) -> p (Constant o)
appendPlate ((forall a. HasContents a => [a] -> a)
-> ([Section] -> a) -> DLPlate (Constant a)
forall b.
Monoid b =>
(forall a. HasContents a => [a] -> b)
-> ([Section] -> b) -> DLPlate (Constant b)
secConPlate ([Sentence] -> a
f ([Sentence] -> a) -> ([a] -> [Sentence]) -> [a] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> [Sentence]) -> [a] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap a -> [Sentence]
forall a. HasContents a => a -> [Sentence]
getCon') (([Section] -> a) -> DLPlate (Constant a))
-> ([Section] -> a) -> DLPlate (Constant a)
forall a b. (a -> b) -> a -> b
$ [Sentence] -> a
f ([Sentence] -> a) -> ([Section] -> [Sentence]) -> [Section] -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Section -> [Sentence]) -> [Section] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Section -> [Sentence]
getSec) (DLPlate (Constant a) -> DLPlate (Constant a))
-> DLPlate (Constant a) -> DLPlate (Constant a)
forall a b. (a -> b) -> a -> b
$
DLPlate (Constant a) -> DLPlate (Constant a)
forall (p :: (* -> *) -> *) o.
(Multiplate p, Monoid o) =>
p (Constant o) -> p (Constant o)
preorderFold (DLPlate (Constant a) -> DLPlate (Constant a))
-> DLPlate (Constant a) -> DLPlate (Constant a)
forall a b. (a -> b) -> a -> b
$ DLPlate (Constant a)
forall (p :: (* -> *) -> *) (f :: * -> *).
(Multiplate p, Applicative f) =>
p f
purePlate {
introSec :: IntroSec -> Constant a IntroSec
introSec = a -> Constant a IntroSec
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a IntroSec)
-> ([Sentence] -> a) -> [Sentence] -> Constant a IntroSec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a IntroSec)
-> (IntroSec -> [Sentence]) -> IntroSec -> Constant a IntroSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(IntroProg s1 :: Sentence
s1 s2 :: Sentence
s2 _) -> [Sentence
s1, Sentence
s2],
introSub :: IntroSub -> Constant a IntroSub
introSub = a -> Constant a IntroSub
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a IntroSub)
-> ([Sentence] -> a) -> [Sentence] -> Constant a IntroSub
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a IntroSub)
-> (IntroSub -> [Sentence]) -> IntroSub -> Constant a IntroSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(IPurpose s :: [Sentence]
s) -> [Sentence]
s
(IScope s :: Sentence
s) -> [Sentence
s]
(IChar s1 :: [Sentence]
s1 s2 :: [Sentence]
s2 s3 :: [Sentence]
s3) -> [[Sentence]] -> [Sentence]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Sentence]
s1, [Sentence]
s2, [Sentence]
s3]
(IOrgSec s1 :: Sentence
s1 _ _ s2 :: Sentence
s2) -> [Sentence
s1, Sentence
s2],
stkSub :: StkhldrSub -> Constant a StkhldrSub
stkSub = a -> Constant a StkhldrSub
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a StkhldrSub)
-> ([Sentence] -> a) -> [Sentence] -> Constant a StkhldrSub
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a StkhldrSub)
-> (StkhldrSub -> [Sentence])
-> StkhldrSub
-> Constant a StkhldrSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(Client _ s :: Sentence
s) -> [Sentence
s]
(Cstmr _) -> [],
pdSec :: ProblemDescription -> Constant a ProblemDescription
pdSec = a -> Constant a ProblemDescription
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a ProblemDescription)
-> ([Sentence] -> a) -> [Sentence] -> Constant a ProblemDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a ProblemDescription)
-> (ProblemDescription -> [Sentence])
-> ProblemDescription
-> Constant a ProblemDescription
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(PDProg s :: Sentence
s _ _) -> [Sentence
s],
pdSub :: PDSub -> Constant a PDSub
pdSub = a -> Constant a PDSub
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a PDSub)
-> ([Sentence] -> a) -> [Sentence] -> Constant a PDSub
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a PDSub)
-> (PDSub -> [Sentence]) -> PDSub -> Constant a PDSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(TermsAndDefs Nothing cs :: [c]
cs) -> [c] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [c]
cs
(TermsAndDefs (Just s :: Sentence
s) cs :: [c]
cs) -> Sentence
s Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [c] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [c]
cs
(PhySysDesc _ s :: [Sentence]
s _ _) -> [Sentence]
s
(Goals s :: [Sentence]
s c :: [ConceptInstance]
c) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
scsSub :: SCSSub -> Constant a SCSSub
scsSub = a -> Constant a SCSSub
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a SCSSub)
-> ([Sentence] -> a) -> [Sentence] -> Constant a SCSSub
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a SCSSub)
-> (SCSSub -> [Sentence]) -> SCSSub -> Constant a SCSSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(Assumptions c :: [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c
(TMs s :: [Sentence]
s _ t :: [TheoryModel]
t) -> let r :: [TheoryModel] -> [Sentence]
r = [Sentence] -> [Sentence] -> [Sentence]
forall a. Monoid a => a -> a -> a
mappend [Sentence]
s ([Sentence] -> [Sentence])
-> ([TheoryModel] -> [Sentence]) -> [TheoryModel] -> [Sentence]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TheoryModel -> [Sentence]) -> [TheoryModel] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\x :: TheoryModel
x -> [ConceptChunk] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def (TheoryModel
x TheoryModel
-> Getting [ConceptChunk] TheoryModel [ConceptChunk]
-> [ConceptChunk]
forall s a. s -> Getting a s a -> a
^. Getting [ConceptChunk] TheoryModel [ConceptChunk]
forall t. Theory t => Lens' t [ConceptChunk]
operations) [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++
[ModelQDef] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def (TheoryModel
x TheoryModel
-> Getting [ModelQDef] TheoryModel [ModelQDef] -> [ModelQDef]
forall s a. s -> Getting a s a -> a
^. Getting [ModelQDef] TheoryModel [ModelQDef]
forall t. Theory t => Lens' t [ModelQDef]
defined_quant) [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [TheoryModel] -> [Sentence]
forall a. HasAdditionalNotes a => [a] -> [Sentence]
notes [TheoryModel
x] [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++
[TheoryModel] -> [Sentence]
r (TheoryModel
x TheoryModel
-> Getting [TheoryModel] TheoryModel [TheoryModel] -> [TheoryModel]
forall s a. s -> Getting a s a -> a
^. Getting [TheoryModel] TheoryModel [TheoryModel]
forall t. Theory t => Lens' t [TheoryModel]
valid_context)) in [TheoryModel] -> [Sentence]
r [TheoryModel]
t
(DDs s :: [Sentence]
s _ d :: [DataDefinition]
d _) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [DataDefinition] -> [Sentence]
forall a. HasDerivation a => [a] -> [Sentence]
der [DataDefinition]
d [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [DataDefinition] -> [Sentence]
forall a. HasAdditionalNotes a => [a] -> [Sentence]
notes [DataDefinition]
d
(GDs s :: [Sentence]
s _ d :: [GenDefn]
d _) -> [GenDefn] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [GenDefn]
d [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [GenDefn] -> [Sentence]
forall a. HasDerivation a => [a] -> [Sentence]
der [GenDefn]
d [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [GenDefn] -> [Sentence]
forall a. HasAdditionalNotes a => [a] -> [Sentence]
notes [GenDefn]
d
(IMs s :: [Sentence]
s _ d :: [InstanceModel]
d _) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [InstanceModel] -> [Sentence]
forall a. HasDerivation a => [a] -> [Sentence]
der [InstanceModel]
d [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [InstanceModel] -> [Sentence]
forall a. HasAdditionalNotes a => [a] -> [Sentence]
notes [InstanceModel]
d
(Constraints s :: Sentence
s _) -> [Sentence
s]
(CorrSolnPpties _ _) -> [],
reqSub :: ReqsSub -> Constant a ReqsSub
reqSub = a -> Constant a ReqsSub
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a ReqsSub)
-> ([Sentence] -> a) -> [Sentence] -> Constant a ReqsSub
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a ReqsSub)
-> (ReqsSub -> [Sentence]) -> ReqsSub -> Constant a ReqsSub
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \case
(FReqsSub' c :: [ConceptInstance]
c _) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c
(FReqsSub c :: [ConceptInstance]
c _) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c
(NonFReqsSub c :: [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
lcsSec :: LCsSec -> Constant a LCsSec
lcsSec = a -> Constant a LCsSec
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a LCsSec)
-> ([Sentence] -> a) -> [Sentence] -> Constant a LCsSec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a LCsSec)
-> (LCsSec -> [Sentence]) -> LCsSec -> Constant a LCsSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(LCsProg c :: [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
ucsSec :: UCsSec -> Constant a UCsSec
ucsSec = a -> Constant a UCsSec
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a UCsSec)
-> ([Sentence] -> a) -> [Sentence] -> Constant a UCsSec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a UCsSec)
-> (UCsSec -> [Sentence]) -> UCsSec -> Constant a UCsSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(UCsProg c :: [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
traceSec :: TraceabilitySec -> Constant a TraceabilitySec
traceSec = a -> Constant a TraceabilitySec
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a TraceabilitySec)
-> ([Sentence] -> a) -> [Sentence] -> Constant a TraceabilitySec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a TraceabilitySec)
-> (TraceabilitySec -> [Sentence])
-> TraceabilitySec
-> Constant a TraceabilitySec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(TraceabilityProg progs :: [TraceConfig]
progs) ->
(TraceConfig -> [Sentence]) -> [TraceConfig] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(TraceConfig _ ls :: [Sentence]
ls s :: Sentence
s _ _) -> Sentence
s Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [Sentence]
ls) [TraceConfig]
progs,
auxConsSec :: AuxConstntSec -> Constant a AuxConstntSec
auxConsSec = a -> Constant a AuxConstntSec
forall k a (b :: k). a -> Constant a b
Constant (a -> Constant a AuxConstntSec)
-> ([Sentence] -> a) -> [Sentence] -> Constant a AuxConstntSec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sentence] -> a
f ([Sentence] -> Constant a AuxConstntSec)
-> (AuxConstntSec -> [Sentence])
-> AuxConstntSec
-> Constant a AuxConstntSec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> \(AuxConsProg _ qdef :: [ConstQDef]
qdef) -> [ConstQDef] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConstQDef]
qdef
} where
def :: Definition a => [a] -> [Sentence]
def :: [a] -> [Sentence]
def = (a -> Sentence) -> [a] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map (a -> Getting Sentence a Sentence -> Sentence
forall s a. s -> Getting a s a -> a
^. Getting Sentence a Sentence
forall c. Definition c => Lens' c Sentence
defn)
der :: HasDerivation a => [a] -> [Sentence]
der :: [a] -> [Sentence]
der = (a -> [Sentence]) -> [a] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Maybe Derivation -> [Sentence]
getDerivSent (Maybe Derivation -> [Sentence])
-> (a -> Maybe Derivation) -> a -> [Sentence]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a
-> Getting (Maybe Derivation) a (Maybe Derivation)
-> Maybe Derivation
forall s a. s -> Getting a s a -> a
^. Getting (Maybe Derivation) a (Maybe Derivation)
forall c. HasDerivation c => Lens' c (Maybe Derivation)
derivations))
getDerivSent :: Maybe Derivation -> [Sentence]
getDerivSent :: Maybe Derivation -> [Sentence]
getDerivSent Nothing = []
getDerivSent (Just (Derivation h :: Sentence
h s :: [Sentence]
s)) = Sentence
h Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [Sentence]
s
notes :: HasAdditionalNotes a => [a] -> [Sentence]
notes :: [a] -> [Sentence]
notes = (a -> [Sentence]) -> [a] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (a -> Getting [Sentence] a [Sentence] -> [Sentence]
forall s a. s -> Getting a s a -> a
^. Getting [Sentence] a [Sentence]
forall c. HasAdditionalNotes c => Lens' c [Sentence]
getNotes)
getDocDesc :: DocDesc -> [Sentence]
getDocDesc :: DocDesc -> [Sentence]
getDocDesc = DLPlate (Constant [Sentence]) -> DocDesc -> [Sentence]
forall a. DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc (([Sentence] -> [Sentence]) -> DLPlate (Constant [Sentence])
forall a. Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate [Sentence] -> [Sentence]
forall a. a -> a
id)
getSec :: Section -> [Sentence]
getSec :: Section -> [Sentence]
getSec (Section t :: Sentence
t sc :: [SecCons]
sc _ ) = Sentence
t Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: (SecCons -> [Sentence]) -> [SecCons] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap SecCons -> [Sentence]
getSecCon [SecCons]
sc
getSecCon :: SecCons -> [Sentence]
getSecCon :: SecCons -> [Sentence]
getSecCon (Sub s :: Section
s) = Section -> [Sentence]
getSec Section
s
getSecCon (Con c :: Contents
c) = Contents -> [Sentence]
forall a. HasContents a => a -> [Sentence]
getCon' Contents
c
getCon' :: HasContents a => a -> [Sentence]
getCon' :: a -> [Sentence]
getCon' = RawContent -> [Sentence]
getCon (RawContent -> [Sentence]) -> (a -> RawContent) -> a -> [Sentence]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Getting RawContent a RawContent -> RawContent
forall s a. s -> Getting a s a -> a
^. Getting RawContent a RawContent
forall c. HasContents c => Lens' c RawContent
accessContents)
getCon :: RawContent -> [Sentence]
getCon :: RawContent -> [Sentence]
getCon (Table s1 :: [Sentence]
s1 s2 :: [[Sentence]]
s2 t :: Sentence
t _) = ([Sentence], [[Sentence]]) -> [Sentence]
isVar ([Sentence]
s1, [[Sentence]] -> [[Sentence]]
forall a. [[a]] -> [[a]]
transpose [[Sentence]]
s2) [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Sentence
t]
getCon (Paragraph s :: Sentence
s) = [Sentence
s]
getCon EqnBlock{} = []
getCon (DerivBlock h :: Sentence
h d :: [RawContent]
d) = Sentence
h Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: (RawContent -> [Sentence]) -> [RawContent] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap RawContent -> [Sentence]
getCon [RawContent]
d
getCon (Enumeration lst :: ListType
lst) = ListType -> [Sentence]
getLT ListType
lst
getCon (Figure l :: Sentence
l _ _) = [Sentence
l]
getCon (Bib bref :: BibRef
bref) = BibRef -> [Sentence]
forall c. HasFields c => [c] -> [Sentence]
getBib BibRef
bref
getCon (Graph [(s1 :: Sentence
s1, s2 :: Sentence
s2)] _ _ l :: Sentence
l) = [Sentence
s1, Sentence
s2, Sentence
l]
getCon Graph{} = []
getCon (Defini _ []) = []
getCon (Defini dt :: DType
dt (hd :: (Identifier, [Contents])
hd:fs :: [(Identifier, [Contents])]
fs)) = (Contents -> [Sentence]) -> [Contents] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Contents -> [Sentence]
forall a. HasContents a => a -> [Sentence]
getCon' ((Identifier, [Contents]) -> [Contents]
forall a b. (a, b) -> b
snd (Identifier, [Contents])
hd) [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ RawContent -> [Sentence]
getCon (DType -> [(Identifier, [Contents])] -> RawContent
Defini DType
dt [(Identifier, [Contents])]
fs)
isVar :: ([Sentence], [[Sentence]]) -> [Sentence]
isVar :: ([Sentence], [[Sentence]]) -> [Sentence]
isVar (S "Var" : _, hd1 :: [Sentence]
hd1 : _) = [Sentence]
hd1
isVar (_ : tl :: [Sentence]
tl, _ : tl1 :: [[Sentence]]
tl1) = ([Sentence], [[Sentence]]) -> [Sentence]
isVar ([Sentence]
tl, [[Sentence]]
tl1)
isVar ([], _) = []
isVar (_, []) = []
getBib :: (HasFields c) => [c] -> [Sentence]
getBib :: [c] -> [Sentence]
getBib a :: [c]
a = (CiteField -> Sentence) -> [CiteField] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map CiteField -> Sentence
getField ([CiteField] -> [Sentence]) -> [CiteField] -> [Sentence]
forall a b. (a -> b) -> a -> b
$ (c -> [CiteField]) -> [c] -> [CiteField]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (c -> Getting [CiteField] c [CiteField] -> [CiteField]
forall s a. s -> Getting a s a -> a
^. Getting [CiteField] c [CiteField]
forall c. HasFields c => Lens' c [CiteField]
getFields) [c]
a
getField :: CiteField -> Sentence
getField :: CiteField -> Sentence
getField (Address s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Author{} = Sentence
EmptyS
getField (BookTitle s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Chapter{} = Sentence
EmptyS
getField Edition{} = Sentence
EmptyS
getField Editor{} = Sentence
EmptyS
getField HowPublished{} = Sentence
EmptyS
getField (Institution s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField (Journal s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Month{} = Sentence
EmptyS
getField (Note s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Number{} = Sentence
EmptyS
getField (Organization s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Pages{} = Sentence
EmptyS
getField (Publisher s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField (School s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField (Series s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField (Title s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField (Type s :: Identifier
s) = Identifier -> Sentence
S Identifier
s
getField Volume{} = Sentence
EmptyS
getField Year{} = Sentence
EmptyS
getLT :: ListType -> [Sentence]
getLT :: ListType -> [Sentence]
getLT (Bullet it :: [(ItemType, Maybe Identifier)]
it) = ((ItemType, Maybe Identifier) -> [Sentence])
-> [(ItemType, Maybe Identifier)] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ItemType -> [Sentence]
getIL (ItemType -> [Sentence])
-> ((ItemType, Maybe Identifier) -> ItemType)
-> (ItemType, Maybe Identifier)
-> [Sentence]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ItemType, Maybe Identifier) -> ItemType
forall a b. (a, b) -> a
fst) [(ItemType, Maybe Identifier)]
it
getLT (Numeric it :: [(ItemType, Maybe Identifier)]
it) = ((ItemType, Maybe Identifier) -> [Sentence])
-> [(ItemType, Maybe Identifier)] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ItemType -> [Sentence]
getIL (ItemType -> [Sentence])
-> ((ItemType, Maybe Identifier) -> ItemType)
-> (ItemType, Maybe Identifier)
-> [Sentence]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ItemType, Maybe Identifier) -> ItemType
forall a b. (a, b) -> a
fst) [(ItemType, Maybe Identifier)]
it
getLT (Simple lp :: [ListTuple]
lp) = (ListTuple -> [Sentence]) -> [ListTuple] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ListTuple -> [Sentence]
getLP [ListTuple]
lp
getLT (Desc lp :: [ListTuple]
lp) = (ListTuple -> [Sentence]) -> [ListTuple] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ListTuple -> [Sentence]
getLP [ListTuple]
lp
getLT (Definitions lp :: [ListTuple]
lp) = (ListTuple -> [Sentence]) -> [ListTuple] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ListTuple -> [Sentence]
getLP [ListTuple]
lp
getLP :: ListTuple -> [Sentence]
getLP :: ListTuple -> [Sentence]
getLP (t :: Sentence
t, it :: ItemType
it, _) = Sentence
t Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: ItemType -> [Sentence]
getIL ItemType
it
getIL :: ItemType -> [Sentence]
getIL :: ItemType -> [Sentence]
getIL (Flat s :: Sentence
s) = [Sentence
s]
getIL (Nested h :: Sentence
h lt :: ListType
lt) = Sentence
h Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: ListType -> [Sentence]
getLT ListType
lt