{-# LANGUAGE GADTs, TemplateHaskell #-}
{-# LANGUAGE InstanceSigs #-}
module Language.Drasil.CodeSpec where
import Prelude hiding (const)
import Control.Lens ((^.), makeLenses, Lens', makeClassyFor, set)
import Data.List (nub, (\\))
import qualified Data.Map as Map
import Data.Maybe (mapMaybe)
import Language.Drasil hiding (None)
import Language.Drasil.Display (Symbol(Variable))
import Drasil.Database (ChunkDB, UID, HasUID(..), insertAll)
import Drasil.Code.CodeExpr.Development (expr, eNamesRI, eDep)
import qualified Drasil.System as S
import Drasil.System (HasSystem(..), HasSystemMeta(..), programName)
import Theory.Drasil (DataDefinition, qdEFromDD, getEqModQdsFromIm)
import Utils.Drasil (subsetOf, RelativeFile)
import Drasil.Code.CodeVar (CodeChunk, CodeIdea(codeChunk), CodeVarChunk)
import Language.Drasil.Chunk.ConstraintMap (ConstraintCEMap, ConstraintCE, constraintMap)
import Language.Drasil.Chunk.CodeDefinition (CodeDefinition, qtov, qtoc, odeDef)
import Language.Drasil.Choices (Choices(..), Maps(..), ODE(..), ExtLib(..),
odeLibReqs, odeInfoReqs)
import Language.Drasil.Chunk.CodeBase (quantvar, codevars, varResolve)
import Language.Drasil.Mod (Func(..), FuncData(..), FuncDef(..), Mod(..), Name)
import Language.Drasil.ICOSolutionSearch (Def, solveExecOrder)
type Input = CodeVarChunk
type Output = CodeVarChunk
type Const = CodeDefinition
type Derived = CodeDefinition
type ConstantMap = Map.Map UID CodeDefinition
data OldCodeSpec = OldCodeSpec {
OldCodeSpec -> Name
_pName :: Name,
OldCodeSpec -> People
_authors :: People,
OldCodeSpec -> [CodeVarChunk]
_inputs :: [Input],
OldCodeSpec -> [CodeVarChunk]
_extInputs :: [Input],
OldCodeSpec -> [Const]
_derivedInputs :: [Derived],
OldCodeSpec -> [CodeVarChunk]
_outputs :: [Output],
OldCodeSpec -> [RelativeFile]
_configFiles :: [RelativeFile],
OldCodeSpec -> [Const]
_execOrder :: [Def],
OldCodeSpec -> ConstraintCEMap
_cMap :: ConstraintCEMap,
OldCodeSpec -> [Const]
_constants :: [Const],
OldCodeSpec -> ConstantMap
_constMap :: ConstantMap,
OldCodeSpec -> [Mod]
_mods :: [Mod],
OldCodeSpec -> ChunkDB
_systemdb :: ChunkDB
}
makeClassyFor "HasOldCodeSpec" "oldCodeSpec"
[ ("_pName", "pNameO")
, ("_authors", "authorsO")
, ("_inputs", "inputsO")
, ("_extInputs", "extInputsO")
, ("_derivedInputs", "derivedInputsO")
, ("_outputs", "outputsO")
, ("_configFiles", "configFilesO")
, ("_execOrder", "execOrderO")
, ("_cMap", "cMapO")
, ("_constants", "constantsO")
, ("_constMap", "constMapO")
, ("_mods", "modsO")
, ("_systemdb", "systemdbO")
] ''OldCodeSpec
data CodeSpec = CS {
CodeSpec -> System
_system' :: S.System,
CodeSpec -> OldCodeSpec
_oldCode :: OldCodeSpec
}
makeLenses ''CodeSpec
instance HasSystem CodeSpec where
system :: Lens' CodeSpec S.System
system :: Lens' CodeSpec System
system = (System -> f System) -> CodeSpec -> f CodeSpec
Lens' CodeSpec System
system'
instance HasSystemMeta CodeSpec where
systemMeta :: Lens' CodeSpec SystemMeta
systemMeta = (System -> f System) -> CodeSpec -> f CodeSpec
Lens' CodeSpec System
system' ((System -> f System) -> CodeSpec -> f CodeSpec)
-> ((SystemMeta -> f SystemMeta) -> System -> f System)
-> (SystemMeta -> f SystemMeta)
-> CodeSpec
-> f CodeSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SystemMeta -> f SystemMeta) -> System -> f System
forall c. HasSystemMeta c => Lens' c SystemMeta
Lens' System SystemMeta
systemMeta
instance HasOldCodeSpec CodeSpec where
oldCodeSpec :: Lens' CodeSpec OldCodeSpec
oldCodeSpec :: Lens' CodeSpec OldCodeSpec
oldCodeSpec = (OldCodeSpec -> f OldCodeSpec) -> CodeSpec -> f CodeSpec
Lens' CodeSpec OldCodeSpec
oldCode
assocToMap :: HasUID a => [a] -> Map.Map UID a
assocToMap :: forall a. HasUID a => [a] -> Map UID a
assocToMap = [(UID, a)] -> Map UID a
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UID, a)] -> Map UID a)
-> ([a] -> [(UID, a)]) -> [a] -> Map UID a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> (UID, a)) -> [a] -> [(UID, a)]
forall a b. (a -> b) -> [a] -> [b]
map (\a
x -> (a
x a -> Getting UID a UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID a UID
forall c. HasUID c => Getter c UID
Getter a UID
uid, a
x))
getODE :: [ExtLib] -> Maybe ODE
getODE :: [ExtLib] -> Maybe ODE
getODE [] = Maybe ODE
forall a. Maybe a
Nothing
getODE (Math ODE
ode: [ExtLib]
_) = ODE -> Maybe ODE
forall a. a -> Maybe a
Just ODE
ode
mapODE :: Maybe ODE -> [CodeDefinition]
mapODE :: Maybe ODE -> [Const]
mapODE Maybe ODE
Nothing = []
mapODE (Just ODE
ode) = (ODEInfo -> Const) -> [ODEInfo] -> [Const]
forall a b. (a -> b) -> [a] -> [b]
map ODEInfo -> Const
odeDef ([ODEInfo] -> [Const]) -> [ODEInfo] -> [Const]
forall a b. (a -> b) -> a -> b
$ ODE -> [ODEInfo]
odeInfo ODE
ode
codeSpec :: S.System -> Choices -> CodeSpec
codeSpec :: System -> Choices -> CodeSpec
codeSpec System
si Choices
chs = CS {
_system' :: System
_system' = System
si',
_oldCode :: OldCodeSpec
_oldCode = System -> Choices -> OldCodeSpec
oldcodeSpec System
si' Choices
chs
}
where
els :: [ExtLib]
els = Choices -> [ExtLib]
extLibs Choices
chs
libReqs :: [DefinedQuantityDict]
libReqs = (ExtLib -> [DefinedQuantityDict])
-> [ExtLib] -> [DefinedQuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ExtLib -> [DefinedQuantityDict]
odeLibReqs [ExtLib]
els
infoReqs :: [DefinedQuantityDict]
infoReqs = (ExtLib -> [DefinedQuantityDict])
-> [ExtLib] -> [DefinedQuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ExtLib -> [DefinedQuantityDict]
odeInfoReqs [ExtLib]
els
db' :: ChunkDB
db' = [DefinedQuantityDict] -> ChunkDB -> ChunkDB
forall a. TypeableChunk a => [a] -> ChunkDB -> ChunkDB
insertAll ([DefinedQuantityDict]
libReqs [DefinedQuantityDict]
-> [DefinedQuantityDict] -> [DefinedQuantityDict]
forall a. [a] -> [a] -> [a]
++ [DefinedQuantityDict]
infoReqs) (ChunkDB -> ChunkDB) -> ChunkDB -> ChunkDB
forall a b. (a -> b) -> a -> b
$ System
si System -> Getting ChunkDB System ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB System ChunkDB
forall c. HasSystemMeta c => Lens' c ChunkDB
Lens' System ChunkDB
systemdb
si' :: System
si' = ASetter System System ChunkDB ChunkDB
-> ChunkDB -> System -> System
forall s t a b. ASetter s t a b -> b -> s -> t
set ASetter System System ChunkDB ChunkDB
forall c. HasSystemMeta c => Lens' c ChunkDB
Lens' System ChunkDB
systemdb ChunkDB
db' System
si
oldcodeSpec :: S.System -> Choices -> OldCodeSpec
oldcodeSpec :: System -> Choices -> OldCodeSpec
oldcodeSpec sys :: System
sys@S.SI{ _inputs :: ()
S._inputs = [h]
ins
, _outputs :: ()
S._outputs = [i]
outs
, _constraints :: ()
S._constraints = [j]
cs
, _constants :: System -> [ConstQDef]
S._constants = [ConstQDef]
cnsts } Choices
chs =
let ddefs :: [DataDefinition]
ddefs = System
sys System
-> Getting [DataDefinition] System [DataDefinition]
-> [DataDefinition]
forall s a. s -> Getting a s a -> a
^. Getting [DataDefinition] System [DataDefinition]
forall c. HasSystem c => Lens' c [DataDefinition]
Lens' System [DataDefinition]
dataDefns
n :: Name
n = System
sys System -> Getting Name System Name -> Name
forall s a. s -> Getting a s a -> a
^. Getting Name System Name
forall c. HasSystem c => Lens' c Name
Lens' System Name
programName
db :: ChunkDB
db = System
sys System -> Getting ChunkDB System ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB System ChunkDB
forall c. HasSystemMeta c => Lens' c ChunkDB
Lens' System ChunkDB
systemdb
inputs' :: [CodeVarChunk]
inputs' = (h -> CodeVarChunk) -> [h] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map h -> CodeVarChunk
forall c.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> CodeVarChunk
quantvar [h]
ins
const' :: [Const]
const' = (ConstQDef -> Const) -> [ConstQDef] -> [Const]
forall a b. (a -> b) -> [a] -> [b]
map ConstQDef -> Const
forall e. CanGenCode e => QDefinition e -> Const
qtov ((ConstQDef -> Bool) -> [ConstQDef] -> [ConstQDef]
forall a. (a -> Bool) -> [a] -> [a]
filter ((UID -> Map UID [CodeConcept] -> Bool
forall k a. Ord k => k -> Map k a -> Bool
`Map.notMember` Maps -> Map UID [CodeConcept]
conceptMatch (Choices -> Maps
maps Choices
chs)) (UID -> Bool) -> (ConstQDef -> UID) -> ConstQDef -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ConstQDef -> Getting UID ConstQDef UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID ConstQDef UID
forall c. HasUID c => Getter c UID
Getter ConstQDef UID
uid))
[ConstQDef]
cnsts)
derived :: [Const]
derived = (QDefinition Expr -> Const) -> [QDefinition Expr] -> [Const]
forall a b. (a -> b) -> [a] -> [b]
map QDefinition Expr -> Const
forall e. CanGenCode e => QDefinition e -> Const
qtov ([QDefinition Expr] -> [Const]) -> [QDefinition Expr] -> [Const]
forall a b. (a -> b) -> a -> b
$ [DataDefinition]
-> [CodeVarChunk] -> [Const] -> ChunkDB -> [QDefinition Expr]
getDerivedInputs [DataDefinition]
ddefs [CodeVarChunk]
inputs' [Const]
const' ChunkDB
db
rels :: [Const]
rels = ((QDefinition Expr -> Const) -> [QDefinition Expr] -> [Const]
forall a b. (a -> b) -> [a] -> [b]
map QDefinition Expr -> Const
forall (q :: * -> *).
(Quantity (q Expr), MayHaveUnit (q Expr), DefiningExpr q,
Concept (q Expr)) =>
q Expr -> Const
qtoc ([InstanceModel] -> [QDefinition Expr]
getEqModQdsFromIm (System
sys System
-> Getting [InstanceModel] System [InstanceModel]
-> [InstanceModel]
forall s a. s -> Getting a s a -> a
^. Getting [InstanceModel] System [InstanceModel]
forall c. HasSystem c => Lens' c [InstanceModel]
Lens' System [InstanceModel]
instModels) [QDefinition Expr] -> [QDefinition Expr] -> [QDefinition Expr]
forall a. [a] -> [a] -> [a]
++ (DataDefinition -> Maybe (QDefinition Expr))
-> [DataDefinition] -> [QDefinition Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DataDefinition -> Maybe (QDefinition Expr)
qdEFromDD [DataDefinition]
ddefs) [Const] -> [Const] -> [Const]
forall a. Eq a => [a] -> [a] -> [a]
\\ [Const]
derived)
[Const] -> [Const] -> [Const]
forall a. [a] -> [a] -> [a]
++ Maybe ODE -> [Const]
mapODE ([ExtLib] -> Maybe ODE
getODE ([ExtLib] -> Maybe ODE) -> [ExtLib] -> Maybe ODE
forall a b. (a -> b) -> a -> b
$ Choices -> [ExtLib]
extLibs Choices
chs)
[Const] -> [Const] -> [Const]
forall a. [a] -> [a] -> [a]
++ (QDefinition Expr -> Const) -> [QDefinition Expr] -> [Const]
forall a b. (a -> b) -> [a] -> [b]
map QDefinition Expr -> Const
forall (q :: * -> *).
(Quantity (q Expr), MayHaveUnit (q Expr), DefiningExpr q,
Concept (q Expr)) =>
q Expr -> Const
qtoc (Choices -> [QDefinition Expr]
handWiredDefs Choices
chs)
outs' :: [CodeVarChunk]
outs' = (i -> CodeVarChunk) -> [i] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map i -> CodeVarChunk
forall c.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> CodeVarChunk
quantvar [i]
outs
allInputs :: [CodeVarChunk]
allInputs = [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub ([CodeVarChunk] -> [CodeVarChunk])
-> [CodeVarChunk] -> [CodeVarChunk]
forall a b. (a -> b) -> a -> b
$ [CodeVarChunk]
inputs' [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (Const -> CodeVarChunk) -> [Const] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map Const -> CodeVarChunk
forall c.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> CodeVarChunk
quantvar [Const]
derived
exOrder :: [Const]
exOrder = [Const] -> [CodeVarChunk] -> [CodeVarChunk] -> ChunkDB -> [Const]
solveExecOrder [Const]
rels ([CodeVarChunk]
allInputs [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (ConstQDef -> CodeVarChunk) -> [ConstQDef] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map ConstQDef -> CodeVarChunk
forall c.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> CodeVarChunk
quantvar [ConstQDef]
cnsts) [CodeVarChunk]
outs' ChunkDB
db
in OldCodeSpec {
_pName :: Name
_pName = Name
n,
_authors :: People
_authors = System
sys System -> Getting People System People -> People
forall s a. s -> Getting a s a -> a
^. Getting People System People
forall c. HasSystemMeta c => Lens' c People
Lens' System People
authors,
_inputs :: [CodeVarChunk]
_inputs = [CodeVarChunk]
allInputs,
_extInputs :: [CodeVarChunk]
_extInputs = [CodeVarChunk]
inputs',
_derivedInputs :: [Const]
_derivedInputs = [Const]
derived,
_outputs :: [CodeVarChunk]
_outputs = [CodeVarChunk]
outs',
_configFiles :: [RelativeFile]
_configFiles = Choices -> [RelativeFile]
defaultConfigFiles Choices
chs,
_execOrder :: [Const]
_execOrder = [Const]
exOrder,
_cMap :: ConstraintCEMap
_cMap = [j] -> ConstraintCEMap
forall c. (HasUID c, Constrained c) => [c] -> ConstraintCEMap
constraintMap [j]
cs,
_constants :: [Const]
_constants = [Const]
const',
_constMap :: ConstantMap
_constMap = [Const] -> ConstantMap
forall a. HasUID a => [a] -> Map UID a
assocToMap [Const]
const',
_mods :: [Mod]
_mods = Choices -> [Mod]
extraMods Choices
chs,
_systemdb :: ChunkDB
_systemdb = ChunkDB
db
}
asVC :: Func -> DefinedQuantityDict
asVC :: Func -> DefinedQuantityDict
asVC (FDef (FuncDef Name
n Name
d [ParameterChunk]
_ Space
_ Maybe Name
_ [FuncStmt]
_)) = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit (Name -> NP -> Name -> ConceptChunk
dcc Name
n (Name -> NP
nounPhraseSP Name
n) Name
d) (Name -> Symbol
Variable Name
n) Space
Real
asVC (FDef (CtorDef Name
n Name
d [ParameterChunk]
_ [Initializer]
_ [FuncStmt]
_)) = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit (Name -> NP -> Name -> ConceptChunk
dcc Name
n (Name -> NP
nounPhraseSP Name
n) Name
d) (Name -> Symbol
Variable Name
n) Space
Real
asVC (FData (FuncData Name
n Name
d DataDesc
_)) = ConceptChunk -> Symbol -> Space -> DefinedQuantityDict
dqdNoUnit (Name -> NP -> Name -> ConceptChunk
dcc Name
n (Name -> NP
nounPhraseSP Name
n) Name
d) (Name -> Symbol
Variable Name
n) Space
Real
funcUID :: Func -> UID
funcUID :: Func -> UID
funcUID Func
f = Func -> DefinedQuantityDict
asVC Func
f DefinedQuantityDict -> Getting UID DefinedQuantityDict UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID DefinedQuantityDict UID
forall c. HasUID c => Getter c UID
Getter DefinedQuantityDict UID
uid
getDerivedInputs :: [DataDefinition] -> [Input] -> [Const] ->
ChunkDB -> [SimpleQDef]
getDerivedInputs :: [DataDefinition]
-> [CodeVarChunk] -> [Const] -> ChunkDB -> [QDefinition Expr]
getDerivedInputs [DataDefinition]
ddefs [CodeVarChunk]
ins [Const]
cnsts ChunkDB
sm =
(QDefinition Expr -> Bool)
-> [QDefinition Expr] -> [QDefinition Expr]
forall a. (a -> Bool) -> [a] -> [a]
filter (([CodeVarChunk] -> [CodeVarChunk] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`subsetOf` [CodeVarChunk]
refSet) ([CodeVarChunk] -> Bool)
-> (QDefinition Expr -> [CodeVarChunk]) -> QDefinition Expr -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeExpr -> ChunkDB -> [CodeVarChunk])
-> ChunkDB -> CodeExpr -> [CodeVarChunk]
forall a b c. (a -> b -> c) -> b -> a -> c
flip CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars ChunkDB
sm (CodeExpr -> [CodeVarChunk])
-> (QDefinition Expr -> CodeExpr)
-> QDefinition Expr
-> [CodeVarChunk]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Expr -> CodeExpr
expr (Expr -> CodeExpr)
-> (QDefinition Expr -> Expr) -> QDefinition Expr -> CodeExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QDefinition Expr -> Getting Expr (QDefinition Expr) Expr -> Expr
forall s a. s -> Getting a s a -> a
^. Getting Expr (QDefinition Expr) Expr
forall e. Lens' (QDefinition e) e
forall (c :: * -> *) e. DefiningExpr c => Lens' (c e) e
defnExpr)) ((DataDefinition -> Maybe (QDefinition Expr))
-> [DataDefinition] -> [QDefinition Expr]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe DataDefinition -> Maybe (QDefinition Expr)
qdEFromDD [DataDefinition]
ddefs)
where refSet :: [CodeVarChunk]
refSet = [CodeVarChunk]
ins [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (Const -> CodeVarChunk) -> [Const] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map Const -> CodeVarChunk
forall c.
(Quantity c, MayHaveUnit c, Concept c) =>
c -> CodeVarChunk
quantvar [Const]
cnsts
getConstraints :: (HasUID c) => ConstraintCEMap -> [c] -> [ConstraintCE]
getConstraints :: forall c. HasUID c => ConstraintCEMap -> [c] -> [ConstraintCE]
getConstraints ConstraintCEMap
cm [c]
cs = [[ConstraintCE]] -> [ConstraintCE]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[ConstraintCE]] -> [ConstraintCE])
-> [[ConstraintCE]] -> [ConstraintCE]
forall a b. (a -> b) -> a -> b
$ (c -> Maybe [ConstraintCE]) -> [c] -> [[ConstraintCE]]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (\c
c -> UID -> ConstraintCEMap -> Maybe [ConstraintCE]
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (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) ConstraintCEMap
cm) [c]
cs
constraintvars :: ConstraintCE -> ChunkDB -> [CodeChunk]
constraintvars :: ConstraintCE -> ChunkDB -> [CodeChunk]
constraintvars (Range ConstraintReason
_ RealInterval CodeExpr CodeExpr
ri) ChunkDB
m =
(UID -> CodeChunk) -> [UID] -> [CodeChunk]
forall a b. (a -> b) -> [a] -> [b]
map (CodeVarChunk -> CodeChunk
forall c. CodeIdea c => c -> CodeChunk
codeChunk (CodeVarChunk -> CodeChunk)
-> (UID -> CodeVarChunk) -> UID -> CodeChunk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) ([UID] -> [CodeChunk]) -> [UID] -> [CodeChunk]
forall a b. (a -> b) -> a -> b
$ [UID] -> [UID]
forall a. Eq a => [a] -> [a]
nub ([UID] -> [UID]) -> [UID] -> [UID]
forall a b. (a -> b) -> a -> b
$ RealInterval CodeExpr CodeExpr -> [UID]
eNamesRI RealInterval CodeExpr CodeExpr
ri
constraintvars (Elem ConstraintReason
_ CodeExpr
ri) ChunkDB
m =
(UID -> CodeChunk) -> [UID] -> [CodeChunk]
forall a b. (a -> b) -> [a] -> [b]
map (CodeVarChunk -> CodeChunk
forall c. CodeIdea c => c -> CodeChunk
codeChunk (CodeVarChunk -> CodeChunk)
-> (UID -> CodeVarChunk) -> UID -> CodeChunk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) ([UID] -> [CodeChunk]) -> [UID] -> [CodeChunk]
forall a b. (a -> b) -> a -> b
$ CodeExpr -> [UID]
eDep CodeExpr
ri