module Language.Drasil.Chunk.CodeBase where
import Database.Drasil (ChunkDB, symbResolve)
import Language.Drasil
import Language.Drasil.CodeExpr.Development
quantvar :: (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar :: forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar c
c = CodeChunk -> Maybe CodeChunk -> CodeVarChunk
CodeVC (QuantityDict -> VarOrFunc -> CodeChunk
CodeC (c -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw c
c) VarOrFunc
Var) Maybe CodeChunk
forall a. Maybe a
Nothing
quantfunc :: (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk
quantfunc :: forall c. (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk
quantfunc c
c = CodeChunk -> CodeFuncChunk
CodeFC (CodeChunk -> CodeFuncChunk) -> CodeChunk -> CodeFuncChunk
forall a b. (a -> b) -> a -> b
$ QuantityDict -> VarOrFunc -> CodeChunk
CodeC (c -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw c
c) VarOrFunc
Func
codevars :: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars :: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars CodeExpr
e ChunkDB
m = (UID -> CodeVarChunk) -> [UID] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) ([UID] -> [CodeVarChunk]) -> [UID] -> [CodeVarChunk]
forall a b. (a -> b) -> a -> b
$ CodeExpr -> [UID]
eDep CodeExpr
e
codevars' :: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' :: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
m = (UID -> CodeVarChunk) -> [UID] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) ([UID] -> [CodeVarChunk]) -> [UID] -> [CodeVarChunk]
forall a b. (a -> b) -> a -> b
$ CodeExpr -> [UID]
eDep' CodeExpr
e
varResolve :: ChunkDB -> UID -> CodeVarChunk
varResolve :: ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m UID
x = QuantityDict -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar (QuantityDict -> CodeVarChunk) -> QuantityDict -> CodeVarChunk
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UID -> QuantityDict
symbResolve ChunkDB
m UID
x
funcResolve :: ChunkDB -> UID -> CodeFuncChunk
funcResolve :: ChunkDB -> UID -> CodeFuncChunk
funcResolve ChunkDB
m UID
x = QuantityDict -> CodeFuncChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk
quantfunc (QuantityDict -> CodeFuncChunk) -> QuantityDict -> CodeFuncChunk
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UID -> QuantityDict
symbResolve ChunkDB
m UID
x