module Drasil.GlassBR.TMods (tMods, pbIsSafe, lrIsSafe) where

import Language.Drasil
import Theory.Drasil (TheoryModel, tm, equationalModel')

import Drasil.GlassBR.References (astm2009)
import Drasil.GlassBR.Unitals (isSafeLoad, isSafeProb, pbTolfail, probFail,
  tmDemand, tmLRe)

{--}

tMods :: [TheoryModel]
tMods :: [TheoryModel]
tMods = [TheoryModel
pbIsSafe, TheoryModel
lrIsSafe]

-- FIXME: This is a hack to see if TheoryModel printing will work. This chunk
-- needs to be updated properly.
-- this is the new function but it still uses the lrIsSafeRC,
-- so basically we have to combine the old function with the new function
-- glass_concept :: [ConceptInstance]
-- glass_concept = []


lrIsSafe :: TheoryModel
lrIsSafe :: TheoryModel
lrIsSafe = ModelKind ModelExpr
-> [QuantityDict]
-> [ConceptChunk]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
forall q c.
(Quantity q, MayHaveUnit q, Concept c) =>
ModelKind ModelExpr
-> [q]
-> [c]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
tm (ModelQDef -> ModelKind ModelExpr
forall e. QDefinition e -> ModelKind e
equationalModel' ModelQDef
lrIsSafeQD)
   [QuantityDict -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
isSafeLoad, UnitalChunk -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw UnitalChunk
tmLRe, UnitalChunk -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw UnitalChunk
tmDemand] ([] :: [ConceptChunk])
   [ModelQDef
lrIsSafeQD] [] [] [Citation -> DecRef
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] 
   String
"isSafeLoad" [Sentence
lrIsSafeDesc]

lrIsSafeQD :: ModelQDef
lrIsSafeQD :: ModelQDef
lrIsSafeQD = QuantityDict -> NP -> ModelExpr -> ModelQDef
forall c e.
(Quantity c, MayHaveUnit c) =>
c -> NP -> e -> QDefinition e
mkQuantDef' QuantityDict
isSafeLoad (String -> NP
nounPhraseSP String
"Safety Load") ModelExpr
PExpr
lrIsSafeExpr

lrIsSafeExpr :: PExpr
lrIsSafeExpr :: PExpr
lrIsSafeExpr = UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
tmLRe r -> r -> r
forall r. ExprC r => r -> r -> r
$> UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
tmDemand

lrIsSafeDesc :: Sentence
lrIsSafeDesc :: Sentence
lrIsSafeDesc = QuantityDict -> Sentence
tModDesc QuantityDict
isSafeLoad

pbIsSafe :: TheoryModel
pbIsSafe :: TheoryModel
pbIsSafe = ModelKind ModelExpr
-> [QuantityDict]
-> [ConceptChunk]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
forall q c.
(Quantity q, MayHaveUnit q, Concept c) =>
ModelKind ModelExpr
-> [q]
-> [c]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
tm (ModelQDef -> ModelKind ModelExpr
forall e. QDefinition e -> ModelKind e
equationalModel' ModelQDef
pbIsSafeQD) 
  [QuantityDict -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
isSafeProb, ConstrainedChunk -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw ConstrainedChunk
probFail, ConstrainedChunk -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw ConstrainedChunk
pbTolfail] ([] :: [ConceptChunk])
  [ModelQDef
pbIsSafeQD] [] [] [Citation -> DecRef
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009]
  String
"isSafeProb" [Sentence
pbIsSafeDesc]

pbIsSafeQD :: ModelQDef
pbIsSafeQD :: ModelQDef
pbIsSafeQD = QuantityDict -> NP -> ModelExpr -> ModelQDef
forall c e.
(Quantity c, MayHaveUnit c) =>
c -> NP -> e -> QDefinition e
mkQuantDef' QuantityDict
isSafeProb (String -> NP
nounPhraseSP String
"Safety Probability") ModelExpr
PExpr
pbIsSafeExpr

pbIsSafeExpr :: PExpr
pbIsSafeExpr :: PExpr
pbIsSafeExpr = ConstrainedChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrainedChunk
probFail r -> r -> r
forall r. ExprC r => r -> r -> r
$< ConstrainedChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrainedChunk
pbTolfail

pbIsSafeDesc :: Sentence
pbIsSafeDesc :: Sentence
pbIsSafeDesc = QuantityDict -> Sentence
tModDesc QuantityDict
isSafeProb

tModDesc :: QuantityDict -> Sentence
tModDesc :: QuantityDict -> Sentence
tModDesc QuantityDict
main = String -> Sentence
S String
"If" Sentence -> Sentence -> Sentence
+:+. (QuantityDict -> Sentence
forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
main Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"the structure is considered safe")