Skip to content

Commit 130e76e

Browse files
committed
drasil-system: Prefer accessing fields with lenses.
1 parent d3d9532 commit 130e76e

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

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

Lines changed: 4 additions & 5 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
181+
oldcodeSpec sys@SI.SI{ SI._sys = sysIdea
182182
, SI._authors = as
183-
, SI._instModels = ims
184-
, SI._dataDefns = ddefs
185183
, SI._configFiles = cfp
186184
, SI._inputs = ins
187185
, SI._outputs = outs
188186
, SI._constraints = cs
189187
, SI._constants = cnsts
190188
, SI._systemdb = db } chs ms =
191-
let n = programName sys
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ mkDocDesc sys@SI{_inputs = is, _systemdb = db} = map sec where
139139

140140
scsSub :: SCSSub -> DL.SCSSub
141141
scsSub Assumptions = DL.Assumptions $ fromConcInsDB assumpDom
142-
scsSub (TMs s f) = DL.TMs s f $ _theoryModels sys
143-
scsSub (GDs s f dd) = DL.GDs s f (_genDefns sys) dd
144-
scsSub (DDs s f dd) = DL.DDs s f (_dataDefns sys) dd
145-
scsSub (IMs s f dd) = DL.IMs s f (_instModels sys) 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
146146
scsSub (Constraints s c) = DL.Constraints s c
147147
scsSub (CorrSolnPpties c cs) = DL.CorrSolnPpties c cs
148148

code/drasil-gen/lib/Language/Drasil/TypeCheck.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import Data.Either (isRight, rights)
99
import Control.Lens ((^.))
1010
import Data.Bifunctor (second)
1111
import Data.List (partition)
12-
import System.Drasil (System(SI, _instModels, _dataDefns, _systemdb))
12+
import System.Drasil (System, HasSystem (instModels, dataDefns, systemdb))
1313

1414
typeCheckSI :: System -> IO ()
15-
typeCheckSI
16-
SI{_instModels = ims, _dataDefns = dds, _systemdb = chks}
17-
= do
15+
typeCheckSI sys = do
16+
let ims = sys ^. instModels
17+
dds = sys ^. dataDefns
18+
chks = sys ^. systemdb
1819
-- build a variable context (a map of UIDs to "Space"s [types])
1920
let cxt = M.map (\(dict, _) -> dict ^. typ) (symbolTable chks)
2021

0 commit comments

Comments
 (0)