module Language.Drasil.Chunk.CodeBase where
import Database.Drasil (ChunkDB, symbResolve)
import Language.Drasil
import Language.Drasil.CodeExpr.Development
import Data.List (nub)
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 (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw c
c) VarOrFunc
Var) 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 forall a b. (a -> b) -> a -> b
$ QuantityDict -> VarOrFunc -> CodeChunk
CodeC (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 = forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) 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 = forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> CodeVarChunk
varResolve ChunkDB
m) forall a b. (a -> b) -> a -> b
$ forall a. Eq a => [a] -> [a]
nub 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 = forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar 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 = forall c. (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk
quantfunc forall a b. (a -> b) -> a -> b
$ ChunkDB -> UID -> QuantityDict
symbResolve ChunkDB
m UID
x