{-# LANGUAGE LambdaCase, Rank2Types #-}
module Drasil.SRS.ExtractDocDesc (
getDocDesc, egetDocDesc,
sentencePlate,
extractUnits
) where
import Control.Lens((^.))
import Data.Functor.Constant (Constant(Constant))
import Data.Generics.Multiplate (appendPlate, foldFor, purePlate, preorderFold)
import Data.Maybe (maybeToList, mapMaybe)
import Drasil.Database (ChunkDB, HasUID (..), findOrErr)
import Language.Drasil (Sentence, Definition(..), ModelExpr, HasAdditionalNotes(..),
Express(express), DefinedQuantityDict, UnitDefn, Quantity, MayHaveUnit(..), IsUnit(..))
import Language.Drasil.Document (HasContents, Section(Section), SecCons(..),
sentToExp, extractSents, extractSents', extractMExprs, getSec)
import Theory.Drasil (Derivation(..), MayHaveDerivation(..))
import Drasil.SRS.DocumentLanguage.Core
import Drasil.SRS.GetChunks (resolveAllVars)
import Drasil.SRS.Sections.SpecificSystemDescription (inDataConstTbl, outDataConstTbl)
secConPlate :: Monoid b => (forall a. HasContents a => [a] -> b) ->
([Section] -> b) -> DLPlate (Constant b)
secConPlate :: forall b.
Monoid b =>
(forall a. HasContents a => [a] -> b)
-> ([Section] -> b) -> DLPlate (Constant b)
secConPlate forall a. HasContents a => [a] -> b
mCon [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 = Constant <$> \(RefProg Contents
c [RefTab]
_) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents
c],
introSub = Constant <$> \case
(IOrgSec CI
_ Section
s Maybe Sentence
_) -> [Section] -> b
mSec [Section
s]
IntroSub
_ -> b
forall a. Monoid a => a
mempty,
gsdSub = Constant <$> \case
(SysCntxt [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
(UsrChars [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c
(SystCons [Contents]
c [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 = Constant <$> \(PDProg Sentence
_ [Section]
s [PDSub]
_) -> [Section] -> b
mSec [Section]
s,
pdSub = Constant <$> \case
(TermsAndDefs Maybe Sentence
_ [c]
_) -> b
forall a. Monoid a => a
mempty
(PhySysDesc a
_ [Sentence]
_ LabelledContent
lc [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 [Sentence]
_ [ConceptInstance]
_) -> b
forall a. Monoid a => a
mempty,
scsSub = Constant <$> \case
(Constraints Sentence
_ [c]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [[c] -> LabelledContent
forall c.
(HasUncertainty c, Quantity c, Constrained c, HasReasVal c,
MayHaveRationale c, MayHaveUnit c) =>
[c] -> LabelledContent
inDataConstTbl [c]
c]
(CorrSolnPpties [c]
c [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
SCSSub
_ -> b
forall a. Monoid a => a
mempty,
reqSub = Constant <$> \case
(FReqsSub [ConceptInstance]
_ [LabelledContent]
c) -> [LabelledContent] -> b
forall a. HasContents a => [a] -> b
mCon [LabelledContent]
c
(NonFReqsSub [ConceptInstance]
_) -> b
forall a. Monoid a => a
mempty,
offShelfSec = Constant <$> \(OffShelfSolnsProg [Contents]
c) -> [Contents] -> b
forall a. HasContents a => [a] -> b
mCon [Contents]
c,
appendSec = Constant <$> \(AppndxProg [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]
extractMExprs)
((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 = Constant <$> \case
(TMs [Sentence]
_ Fields
_ [TheoryModel]
t) -> [TheoryModel] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [TheoryModel]
t
(DDs [Sentence]
_ Fields
_ [DataDefinition]
d DerivationDisplay
_) -> [DataDefinition] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [DataDefinition]
d
(GDs [Sentence]
_ Fields
_ [GenDefn]
g DerivationDisplay
_) -> [GenDefn] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [GenDefn]
g
(IMs [Sentence]
_ Fields
_ [InstanceModel]
i DerivationDisplay
_) -> [InstanceModel] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [InstanceModel]
i
SCSSub
_ -> [],
auxConsSec = Constant <$> \(AuxConsProg CI
_ [ConstQDef]
qdef) -> [ConstQDef] -> [ModelExpr]
forall a. Express a => [a] -> [ModelExpr]
go [ConstQDef]
qdef
}) where
go :: Express a => [a] -> [ModelExpr]
go :: forall a. Express a => [a] -> [ModelExpr]
go = (a -> ModelExpr) -> [a] -> [ModelExpr]
forall a b. (a -> b) -> [a] -> [b]
map a -> ModelExpr
forall c. Express c => c -> ModelExpr
express
fmGetDocDesc :: DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc :: forall a. DLPlate (Constant [a]) -> DocDesc -> [a]
fmGetDocDesc 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 DLPlate f -> DocSection -> f DocSection
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 Sentence
_ [SecCons]
sc Reference
_ ) = (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 Section
s) = Section -> [ModelExpr]
egetSec Section
s
egetSecCon (Con Contents
c) = Contents -> [ModelExpr]
forall a. HasContents a => a -> [ModelExpr]
extractMExprs Contents
c
sentencePlate :: Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate :: forall a. Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate [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]
forall a. HasContents a => [a] -> [Sentence]
extractSents') (([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 = Constant . f <$> \(IntroProg Sentence
s1 Sentence
s2 [IntroSub]
s3) -> [Sentence
s1, Sentence
s2] [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ (IntroSub -> [Sentence]) -> [IntroSub] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap IntroSub -> [Sentence]
getIntroSub [IntroSub]
s3,
introSub = Constant . f <$> \case
(IPurpose [Sentence]
s) -> [Sentence]
s
(IScope Sentence
s) -> [Sentence
s]
(IChar [Sentence]
s1 [Sentence]
s2 [Sentence]
s3) -> [[Sentence]] -> [Sentence]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Sentence]
s1, [Sentence]
s2, [Sentence]
s3]
(IOrgSec CI
_ Section
s1 Maybe Sentence
s2) -> Maybe Sentence -> [Sentence]
forall a. Maybe a -> [a]
maybeToList Maybe Sentence
s2 [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ Section -> [Sentence]
getSec Section
s1,
stkSub = Constant . f <$> \case
(Client CI
_ Sentence
s) -> [Sentence
s]
(Cstmr CI
_) -> [],
pdSec = Constant . f <$> \(PDProg Sentence
s [Section]
secs [PDSub]
pds) -> Sentence
s Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: (Section -> [Sentence]) -> [Section] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Section -> [Sentence]
getSec [Section]
secs [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ (PDSub -> [Sentence]) -> [PDSub] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap PDSub -> [Sentence]
getPDSub [PDSub]
pds,
pdSub = Constant . f <$> \case
(TermsAndDefs Maybe Sentence
Nothing [c]
cs) -> [c] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [c]
cs
(TermsAndDefs (Just Sentence
s) [c]
cs) -> Sentence
s Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [c] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [c]
cs
(PhySysDesc a
_ [Sentence]
s LabelledContent
lc [Contents]
cs) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ LabelledContent -> [Sentence]
forall a. HasContents a => a -> [Sentence]
extractSents LabelledContent
lc [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Contents] -> [Sentence]
forall a. HasContents a => [a] -> [Sentence]
extractSents' [Contents]
cs
(Goals [Sentence]
s [ConceptInstance]
c) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
scsSub = Constant . f <$> \case
(Assumptions [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c
(TMs [Sentence]
s Fields
_ [TheoryModel]
t) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [TheoryModel] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [TheoryModel]
t [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [TheoryModel] -> [Sentence]
forall a. HasAdditionalNotes a => [a] -> [Sentence]
notes [TheoryModel]
t
(DDs [Sentence]
s Fields
_ [DataDefinition]
d DerivationDisplay
_) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [DataDefinition] -> [Sentence]
forall a. MayHaveDerivation 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 [Sentence]
s Fields
_ [GenDefn]
d DerivationDisplay
_) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [GenDefn] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [GenDefn]
d [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [GenDefn] -> [Sentence]
forall a. MayHaveDerivation 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 [Sentence]
s Fields
_ [InstanceModel]
d DerivationDisplay
_) -> [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [InstanceModel] -> [Sentence]
forall a. MayHaveDerivation 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 Sentence
s [c]
_) -> [Sentence
s]
(CorrSolnPpties [c]
_ [Contents]
cs) -> [Contents] -> [Sentence]
forall a. HasContents a => [a] -> [Sentence]
extractSents' [Contents]
cs,
reqSub = Constant . f <$> \case
(FReqsSub [ConceptInstance]
c [LabelledContent]
lcs) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [LabelledContent] -> [Sentence]
forall a. HasContents a => [a] -> [Sentence]
extractSents' [LabelledContent]
lcs
(NonFReqsSub [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
lcsSec = Constant . f <$> \(LCsProg [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
ucsSec = Constant . f <$> \(UCsProg [ConceptInstance]
c) -> [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c,
traceSec = Constant . f <$> \(TraceabilityProg [TraceConfig]
progs) ->
(TraceConfig -> [Sentence]) -> [TraceConfig] -> [Sentence]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(TraceConfig UID
_ [Sentence]
ls Sentence
s [TraceViewCat]
_ [TraceViewCat]
_) -> Sentence
s Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [Sentence]
ls) [TraceConfig]
progs,
auxConsSec = Constant . f <$> \(AuxConsProg CI
_ [ConstQDef]
qdef) -> [ConstQDef] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConstQDef]
qdef
} where
def :: Definition a => [a] -> [Sentence]
def :: forall a. Definition a => [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
Lens' a Sentence
defn)
getIntroSub :: IntroSub -> [Sentence]
getIntroSub :: IntroSub -> [Sentence]
getIntroSub (IPurpose [Sentence]
ss) = [Sentence]
ss
getIntroSub (IScope Sentence
s) = [Sentence
s]
getIntroSub (IChar [Sentence]
s1 [Sentence]
s2 [Sentence]
s3) = [Sentence]
s1 [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Sentence]
s2 [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Sentence]
s3
getIntroSub (IOrgSec CI
_ Section
s1 Maybe Sentence
s2) = Maybe Sentence -> [Sentence]
forall a. Maybe a -> [a]
maybeToList Maybe Sentence
s2 [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ Section -> [Sentence]
getSec Section
s1
der :: MayHaveDerivation a => [a] -> [Sentence]
der :: forall a. MayHaveDerivation a => [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. MayHaveDerivation c => Lens' c (Maybe Derivation)
Lens' a (Maybe Derivation)
derivations))
getDerivSent :: Maybe Derivation -> [Sentence]
getDerivSent :: Maybe Derivation -> [Sentence]
getDerivSent Maybe Derivation
Nothing = []
getDerivSent (Just (Derivation Sentence
h [Sentence]
s)) = Sentence
h Sentence -> [Sentence] -> [Sentence]
forall a. a -> [a] -> [a]
: [Sentence]
s
notes :: HasAdditionalNotes a => [a] -> [Sentence]
notes :: forall a. HasAdditionalNotes a => [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]
Lens' a [Sentence]
getNotes)
getPDSub :: PDSub -> [Sentence]
getPDSub :: PDSub -> [Sentence]
getPDSub (TermsAndDefs Maybe Sentence
ms [c]
c) = [c] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [c]
c [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Sentence]
-> (Sentence -> [Sentence]) -> Maybe Sentence -> [Sentence]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Sentence -> [Sentence]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Sentence
ms
getPDSub (PhySysDesc a
_ [Sentence]
s LabelledContent
lc [Contents]
cs) = [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ LabelledContent -> [Sentence]
forall a. HasContents a => a -> [Sentence]
extractSents LabelledContent
lc [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [Contents] -> [Sentence]
forall a. HasContents a => [a] -> [Sentence]
extractSents' [Contents]
cs
getPDSub (Goals [Sentence]
s [ConceptInstance]
c) = [Sentence]
s [Sentence] -> [Sentence] -> [Sentence]
forall a. [a] -> [a] -> [a]
++ [ConceptInstance] -> [Sentence]
forall a. Definition a => [a] -> [Sentence]
def [ConceptInstance]
c
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)
extractUnits :: DocDesc -> ChunkDB -> [UnitDefn]
DocDesc
dd ChunkDB
cdb = ChunkDB -> [DefinedQuantityDict] -> [UnitDefn]
forall c. Quantity c => ChunkDB -> [c] -> [UnitDefn]
collectUnitDeps ChunkDB
cdb ([DefinedQuantityDict] -> [UnitDefn])
-> [DefinedQuantityDict] -> [UnitDefn]
forall a b. (a -> b) -> a -> b
$ [Sentence] -> [ModelExpr] -> ChunkDB -> [DefinedQuantityDict]
resolveAllVars (DocDesc -> [Sentence]
getDocDesc DocDesc
dd) (DocDesc -> [ModelExpr]
egetDocDesc DocDesc
dd) ChunkDB
cdb
collectUnitDeps :: Quantity c => ChunkDB -> [c] -> [UnitDefn]
collectUnitDeps :: forall c. Quantity c => ChunkDB -> [c] -> [UnitDefn]
collectUnitDeps ChunkDB
db = (UID -> UnitDefn) -> [UID] -> [UnitDefn]
forall a b. (a -> b) -> [a] -> [b]
map (UID -> ChunkDB -> UnitDefn
forall a. Typeable a => UID -> ChunkDB -> a
`findOrErr` ChunkDB
db) ([UID] -> [UnitDefn]) -> ([c] -> [UID]) -> [c] -> [UnitDefn]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UnitDefn -> [UID]) -> [UnitDefn] -> [UID]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap UnitDefn -> [UID]
forall u. IsUnit u => u -> [UID]
getUnits ([UnitDefn] -> [UID]) -> ([c] -> [UnitDefn]) -> [c] -> [UID]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c -> Maybe UnitDefn) -> [c] -> [UnitDefn]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (ChunkDB -> c -> Maybe UnitDefn
forall c. HasUID c => ChunkDB -> c -> Maybe UnitDefn
getUnitLup ChunkDB
db)
getUnitLup :: HasUID c => ChunkDB -> c -> Maybe UnitDefn
getUnitLup :: forall c. HasUID c => ChunkDB -> c -> Maybe UnitDefn
getUnitLup ChunkDB
m c
c = DefinedQuantityDict -> Maybe UnitDefn
forall u. MayHaveUnit u => u -> Maybe UnitDefn
getUnit (UID -> ChunkDB -> DefinedQuantityDict
forall a. Typeable a => UID -> ChunkDB -> a
findOrErr (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid) ChunkDB
m :: DefinedQuantityDict)