Skip to content

Commit 71fd055

Browse files
Merge pull request #4290 from JacquesCarette/rmAllInDBF
Remove `allInDB` function in favour routing TMs, GDs, etc. through `System`.
2 parents 6e50c60 + 130e76e commit 71fd055

File tree

17 files changed

+265
-233
lines changed

17 files changed

+265
-233
lines changed

code/drasil-code/lib/Language/Drasil/CodeSpec.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,21 @@ codeSpec si chs ms = CS {
178178
-- This function extracts various components (e.g., inputs, outputs, constraints, etc.)
179179
-- from 'System' to populate the 'OldCodeSpec' structure.
180180
oldcodeSpec :: SI.System -> Choices -> [Mod] -> OldCodeSpec
181-
oldcodeSpec SI.SI{ SI._sys = sys
182-
, SI._authors = as
183-
, SI._instModels = ims
184-
, SI._datadefs = ddefs
185-
, SI._configFiles = cfp
186-
, SI._inputs = ins
187-
, SI._outputs = outs
188-
, SI._constraints = cs
189-
, SI._constants = cnsts
190-
, SI._systemdb = db } chs ms =
191-
let n = programName sys
181+
oldcodeSpec sys@SI.SI{ SI._sys = sysIdea
182+
, SI._authors = as
183+
, SI._configFiles = cfp
184+
, SI._inputs = ins
185+
, SI._outputs = outs
186+
, SI._constraints = cs
187+
, SI._constants = cnsts
188+
, SI._systemdb = db } chs ms =
189+
let ddefs = sys ^. dataDefns
190+
n = programName sysIdea
192191
inputs' = map quantvar ins
193192
const' = map qtov (filter ((`Map.notMember` conceptMatch (maps chs)) . (^. uid))
194193
cnsts)
195194
derived = map qtov $ getDerivedInputs ddefs inputs' const' db
196-
rels = (map qtoc (getEqModQdsFromIm ims ++ mapMaybe qdEFromDD ddefs) \\ derived)
195+
rels = (map qtoc (getEqModQdsFromIm (sys ^. instModels) ++ mapMaybe qdEFromDD ddefs) \\ derived)
197196
++ mapODE (getODE $ extLibs chs)
198197
-- TODO: When we have better DEModels, we should be deriving our ODE information
199198
-- directly from the instance models (ims) instead of directly from the choices.

code/drasil-docLang/lib/Drasil/DocDecl.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ data ReqsSub where
106106

107107
-- | Creates the document description (translates 'SRSDecl' into a more usable form for generating documents).
108108
mkDocDesc :: System -> SRSDecl -> DocDesc
109-
mkDocDesc SI{_inputs = is, _systemdb = db} = map sec where
109+
mkDocDesc sys@SI{_inputs = is, _systemdb = db} = map sec where
110110
sec :: DocSection -> DL.DocSection
111111
sec TableOfContents = DL.TableOfContents
112112
sec (RefSec r) = DL.RefSec r
@@ -122,28 +122,32 @@ mkDocDesc SI{_inputs = is, _systemdb = db} = map sec where
122122
sec Bibliography = DL.Bibliography
123123
sec (AppndxSec a) = DL.AppndxSec a
124124
sec (OffShelfSolnsSec e) = DL.OffShelfSolnsSec e
125+
125126
reqSec :: ReqsSub -> DL.ReqsSub
126127
reqSec (FReqsSub d t) = DL.FReqsSub (fullReqs is d $ fromConcInsDB funcReqDom) (fullTables is t)
127128
reqSec (FReqsSub' t) = DL.FReqsSub' (fromConcInsDB funcReqDom) t
128129
reqSec NonFReqsSub = DL.NonFReqsSub $ fromConcInsDB nonFuncReqDom
130+
129131
ssdSec :: SSDSub -> DL.SSDSub
130132
ssdSec (SSDProblem (PDProg s ls p)) = DL.SSDProblem $ DL.PDProg s ls $ map pdSub p
131133
ssdSec (SSDSolChSpec (SCSProg scs)) = DL.SSDSolChSpec $ DL.SCSProg $ map scsSub scs
134+
132135
pdSub :: PDSub -> DL.PDSub
133136
pdSub (TermsAndDefs s c) = DL.TermsAndDefs s c
134137
pdSub (PhySysDesc i s lc c) = DL.PhySysDesc i s lc c
135138
pdSub (Goals s) = DL.Goals s $ fromConcInsDB goalStmtDom
139+
136140
scsSub :: SCSSub -> DL.SCSSub
137141
scsSub Assumptions = DL.Assumptions $ fromConcInsDB assumpDom
138-
scsSub (TMs s f) = DL.TMs s f $ allInDB theoryModelTable
139-
scsSub (GDs s f dd) = DL.GDs s f (allInDB gendefTable) dd
140-
scsSub (DDs s f dd) = DL.DDs s f (allInDB dataDefnTable) dd
141-
scsSub (IMs s f dd) = DL.IMs s f (allInDB insmodelTable) dd
142+
scsSub (TMs s f) = DL.TMs s f (sys ^. theoryModels)
143+
scsSub (GDs s f dd) = DL.GDs s f (sys ^. genDefns) dd
144+
scsSub (DDs s f dd) = DL.DDs s f (sys ^. dataDefns) dd
145+
scsSub (IMs s f dd) = DL.IMs s f (sys ^. instModels) dd
142146
scsSub (Constraints s c) = DL.Constraints s c
143147
scsSub (CorrSolnPpties c cs) = DL.CorrSolnPpties c cs
148+
144149
expandFromDB :: ([a] -> [a]) -> Getting (UMap a) ChunkDB (UMap a) -> [a]
145150
expandFromDB f = f . asOrderedList . (db ^.)
146-
allInDB :: Getting (UMap a) ChunkDB (UMap a) -> [a]
147-
allInDB = expandFromDB id
151+
148152
fromConcInsDB :: Concept c => c -> [ConceptInstance]
149153
fromConcInsDB c = expandFromDB (filter (\x -> sDom (cdom x) == c ^. uid)) conceptinsTable

code/drasil-example/dblpend/lib/Drasil/DblPend/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,24 @@ mkSRS = [TableOfContents, -- This creates the Table of Contents
106106

107107
si :: System
108108
si = SI {
109-
_sys = progName,
110-
_kind = Specification,
111-
_authors = [dong],
112-
_purpose = [purp],
113-
_background = [background],
114-
_motivation = [motivation],
115-
_scope = [scope],
116-
_quants = symbolsAll,
117-
_instModels = iMods,
118-
_datadefs = dataDefs,
119-
_configFiles = [],
120-
_inputs = inputs,
121-
_outputs = outputs,
122-
_constraints = inConstraints,
123-
_constants = constants,
124-
_systemdb = symbMap
109+
_sys = progName,
110+
_kind = Specification,
111+
_authors = [dong],
112+
_purpose = [purp],
113+
_background = [background],
114+
_motivation = [motivation],
115+
_scope = [scope],
116+
_quants = symbolsAll,
117+
_theoryModels = tMods,
118+
_genDefns = genDefns,
119+
_dataDefns = dataDefs,
120+
_instModels = iMods,
121+
_configFiles = [],
122+
_inputs = inputs,
123+
_outputs = outputs,
124+
_constraints = inConstraints,
125+
_constants = constants,
126+
_systemdb = symbMap
125127
}
126128

127129
purp :: Sentence

code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,28 @@ mkSRS = [TableOfContents,
9797

9898
si :: System
9999
si = SI {
100-
_sys = progName,
101-
_kind = Specification,
102-
_authors = [alex, luthfi, olu],
103-
_purpose = [purp],
104-
_background = [],
105-
_motivation = [],
106-
_scope = [],
100+
_sys = progName,
101+
_kind = Specification,
102+
_authors = [alex, luthfi, olu],
103+
_purpose = [purp],
104+
_background = [],
105+
_motivation = [],
106+
_scope = [],
107107
-- FIXME: The _quants field should be filled in with all the symbols, however
108108
-- #1658 is why this is empty, otherwise we end up with unused (and probably
109109
-- should be removed) symbols. But that's for another time. This is "fine"
110110
-- because _quants are only used relative to #1658.
111-
_quants = [] :: [QuantityDict], -- map qw iMods ++ map qw symbolsAll,
112-
_instModels = iMods,
113-
_datadefs = dataDefs,
114-
_configFiles = [],
115-
_inputs = inputSymbols,
116-
_outputs = outputSymbols,
117-
_constraints = inputConstraints,
118-
_constants = [],
119-
_systemdb = symbMap
111+
_quants = [] :: [QuantityDict],
112+
_theoryModels = tMods,
113+
_genDefns = generalDefns,
114+
_instModels = iMods,
115+
_dataDefns = dataDefs,
116+
_configFiles = [],
117+
_inputs = inputSymbols,
118+
_outputs = outputSymbols,
119+
_constraints = inputConstraints,
120+
_constants = [],
121+
_systemdb = symbMap
120122
}
121123

122124
purp :: Sentence

code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,24 @@ printSetting = piSys fullSI Equational defaultConfiguration
6060

6161
si :: System
6262
si = SI {
63-
_sys = progName,
64-
_kind = Specification,
65-
_authors = [nikitha, spencerSmith],
66-
_purpose = [purp],
67-
_background = [background],
68-
_motivation = [],
69-
_scope = [scope],
70-
_quants = symbolsForSymbolTable,
71-
_instModels = iMods,
72-
_datadefs = GB.dataDefs,
73-
_configFiles = configFp,
74-
_inputs = inputs,
75-
_outputs = outputs,
76-
_constraints = constrained,
77-
_constants = constants,
78-
_systemdb = symbMap
63+
_sys = progName,
64+
_kind = Specification,
65+
_authors = [nikitha, spencerSmith],
66+
_purpose = [purp],
67+
_background = [background],
68+
_motivation = [],
69+
_scope = [scope],
70+
_quants = symbolsForSymbolTable,
71+
_theoryModels = tMods,
72+
_genDefns = [],
73+
_instModels = iMods,
74+
_dataDefns = GB.dataDefs,
75+
_configFiles = configFp,
76+
_inputs = inputs,
77+
_outputs = outputs,
78+
_constraints = constrained,
79+
_constants = constants,
80+
_systemdb = symbMap
7981
}
8082
--FIXME: All named ideas, not just acronyms.
8183

code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ printSetting = piSys fullSI Equational defaultConfiguration
2727

2828
si :: System
2929
si = SI {
30-
_sys = progName,
31-
_kind = Specification,
32-
_authors = [spencerSmith],
33-
_quants = symbols,
34-
_purpose = [purp],
35-
_background = [],
36-
_motivation = [],
37-
_scope = [],
38-
_instModels = [], -- FIXME; empty _instModels
39-
_datadefs = dataDefs,
40-
_configFiles = [],
41-
_inputs = htInputs,
42-
_outputs = htOutputs,
43-
_constraints = [] :: [ConstrainedChunk],
44-
_constants = [],
45-
_systemdb = symbMap
30+
_sys = progName,
31+
_kind = Specification,
32+
_authors = [spencerSmith],
33+
_quants = symbols,
34+
_purpose = [purp],
35+
_background = [],
36+
_motivation = [],
37+
_scope = [],
38+
_theoryModels = [],
39+
_genDefns = [],
40+
_instModels = [],
41+
_dataDefns = dataDefs,
42+
_configFiles = [],
43+
_inputs = htInputs,
44+
_outputs = htOutputs,
45+
_constraints = [] :: [ConstrainedChunk],
46+
_constants = [],
47+
_systemdb = symbMap
4648
}
4749

4850
mkSRS :: SRSDecl

code/drasil-example/pdcontroller/lib/Drasil/PDController/Body.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ si = SI {
106106
_motivation = [motivation],
107107
_scope = [scope],
108108
_quants = symbolsAll,
109-
_datadefs = dataDefinitions,
109+
_theoryModels = theoreticalModels,
110+
_genDefns = genDefns,
110111
_instModels = instanceModels,
112+
_dataDefns = dataDefinitions,
111113
_configFiles = [],
112114
_inputs = inputs,
113115
_outputs = outputs,

code/drasil-example/projectile/lib/Drasil/Projectile/Body.hs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ scope = foldlSent_ [phraseNP (NP.the (analysis `ofA` twoD)),
121121

122122
externalLinkRef :: Reference
123123
externalLinkRef = makeURI "projectileSRSLink"
124-
"https://github.com/smiths/caseStudies/tree/master/CaseStudies/projectile"
124+
"https://github.com/smiths/caseStudies/tree/master/CaseStudies/projectile"
125125
(shortname' $ S "projectileSRSLink")
126126

127127
projectileExamples :: [Sentence]
@@ -132,22 +132,24 @@ projectileExamples = [S "ballistics" +:+ plural problem +:+ sParen (S "missiles"
132132

133133
si :: System
134134
si = SI {
135-
_sys = progName,
136-
_kind = Specification,
137-
_authors = [samCrawford, brooks, spencerSmith],
138-
_purpose = [purp],
139-
_background = [background],
140-
_motivation = [motivation],
141-
_scope = [scope],
142-
_quants = symbols,
143-
_instModels = iMods,
144-
_datadefs = dataDefs,
145-
_configFiles = [],
146-
_inputs = inputs,
147-
_outputs = outputs,
148-
_constraints = map cnstrw constrained,
149-
_constants = constants,
150-
_systemdb = symbMap
135+
_sys = progName,
136+
_kind = Specification,
137+
_authors = [samCrawford, brooks, spencerSmith],
138+
_purpose = [purp],
139+
_background = [background],
140+
_motivation = [motivation],
141+
_scope = [scope],
142+
_quants = symbols,
143+
_theoryModels = tMods,
144+
_genDefns = genDefns,
145+
_instModels = iMods,
146+
_dataDefns = dataDefs,
147+
_configFiles = [],
148+
_inputs = inputs,
149+
_outputs = outputs,
150+
_constraints = map cnstrw constrained,
151+
_constants = constants,
152+
_systemdb = symbMap
151153
}
152154

153155
purp :: Sentence

code/drasil-example/projectile/lib/Drasil/Projectile/Lesson/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ mkNB = [
4343

4444
si :: System
4545
si = SI {
46-
_sys = projectileMotion,
47-
_kind = Notebook,
48-
_authors = [spencerSmith],
49-
_purpose = [],
50-
_background = [],
51-
_motivation = [],
52-
_scope = [],
53-
_quants = [] :: [QuantityDict],
54-
_instModels = [],
55-
_datadefs = [],
56-
_configFiles = [],
57-
_inputs = [] :: [QuantityDict],
58-
_outputs = [] :: [QuantityDict],
59-
_constraints = [] :: [ConstrainedChunk],
60-
_constants = [] :: [ConstQDef],
61-
_systemdb = symbMap
46+
_sys = projectileMotion,
47+
_kind = Notebook,
48+
_authors = [spencerSmith],
49+
_purpose = [],
50+
_background = [],
51+
_motivation = [],
52+
_scope = [],
53+
_quants = [] :: [QuantityDict],
54+
_theoryModels = [],
55+
_genDefns = [],
56+
_instModels = [],
57+
_dataDefns = [],
58+
_configFiles = [],
59+
_inputs = [] :: [QuantityDict],
60+
_outputs = [] :: [QuantityDict],
61+
_constraints = [] :: [ConstrainedChunk],
62+
_constants = [] :: [ConstQDef],
63+
_systemdb = symbMap
6264
}
6365

6466
symbMap :: ChunkDB

code/drasil-example/sglpend/lib/Drasil/SglPend/Body.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,24 @@ mkSRS = [TableOfContents, -- This creates the Table of Contents
102102

103103
si :: System
104104
si = SI {
105-
_sys = progName,
106-
_kind = Specification,
107-
_authors = [olu],
108-
_purpose = [purp],
109-
_background = [],
110-
_scope = [],
111-
_motivation = [],
112-
_quants = symbols,
113-
_instModels = iMods,
114-
_datadefs = dataDefs,
115-
_configFiles = [],
116-
_inputs = inputs,
117-
_outputs = outputs,
118-
_constraints = inConstraints,
119-
_constants = [] :: [ConstQDef],
120-
_systemdb = symbMap
105+
_sys = progName,
106+
_kind = Specification,
107+
_authors = [olu],
108+
_purpose = [purp],
109+
_background = [],
110+
_scope = [],
111+
_motivation = [],
112+
_quants = symbols,
113+
_theoryModels = tMods,
114+
_genDefns = genDefns,
115+
_instModels = iMods,
116+
_dataDefns = dataDefs,
117+
_configFiles = [],
118+
_inputs = inputs,
119+
_outputs = outputs,
120+
_constraints = inConstraints,
121+
_constants = [] :: [ConstQDef],
122+
_systemdb = symbMap
121123
}
122124

123125
purp :: Sentence

0 commit comments

Comments
 (0)