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
-> [DefinedQuantityDict]
-> [ConceptChunk]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
forall q c.
(Quantity q, MayHaveUnit q, Concept 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)
   ([] :: [DefinedQuantityDict]) ([] :: [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 = DefinedQuantityDict -> NP -> ModelExpr -> ModelQDef
forall c e.
(Quantity c, MayHaveUnit c) =>
c -> NP -> e -> QDefinition e
mkQuantDef' DefinedQuantityDict
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 = DefinedQuantityDict -> Sentence
tModDesc DefinedQuantityDict
isSafeLoad

pbIsSafe :: TheoryModel
pbIsSafe :: TheoryModel
pbIsSafe = ModelKind ModelExpr
-> [DefinedQuantityDict]
-> [ConceptChunk]
-> [ModelQDef]
-> [ModelExpr]
-> [ModelQDef]
-> [DecRef]
-> String
-> [Sentence]
-> TheoryModel
forall q c.
(Quantity q, MayHaveUnit q, Concept 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) 
  ([] :: [DefinedQuantityDict]) ([] :: [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 = DefinedQuantityDict -> NP -> ModelExpr -> ModelQDef
forall c e.
(Quantity c, MayHaveUnit c) =>
c -> NP -> e -> QDefinition e
mkQuantDef' DefinedQuantityDict
isSafeProb (String -> NP
nounPhraseSP String
"Safety Probability") ModelExpr
PExpr
pbIsSafeExpr

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

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

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