module SysInfo.Drasil.GetChunk (ccss, ccss', combine, getIdeaDict, vars) where
import Language.Drasil
import Language.Drasil.Development
import Language.Drasil.ModelExpr.Development (meDep)
import Database.Drasil (ChunkDB, defResolve, symbResolve, termResolve)
import Data.List (nub)
vars :: ModelExpr -> ChunkDB -> [QuantityDict]
vars :: ModelExpr -> ChunkDB -> [QuantityDict]
vars ModelExpr
e ChunkDB
m = (UID -> QuantityDict) -> [UID] -> [QuantityDict]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> QuantityDict
symbResolve ChunkDB
m) ([UID] -> [QuantityDict]) -> [UID] -> [QuantityDict]
forall a b. (a -> b) -> a -> b
$ ModelExpr -> [UID]
meDep ModelExpr
e
vars' :: Sentence -> ChunkDB -> [QuantityDict]
vars' :: Sentence -> ChunkDB -> [QuantityDict]
vars' Sentence
a ChunkDB
m = (UID -> QuantityDict) -> [UID] -> [QuantityDict]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> QuantityDict
symbResolve ChunkDB
m) ([UID] -> [QuantityDict]) -> [UID] -> [QuantityDict]
forall a b. (a -> b) -> a -> b
$ Sentence -> [UID]
sdep Sentence
a
combine :: Sentence -> ChunkDB -> [DefinedQuantityDict]
combine :: Sentence -> ChunkDB -> [DefinedQuantityDict]
combine Sentence
a ChunkDB
m = (QuantityDict -> ConceptChunk -> DefinedQuantityDict)
-> [QuantityDict] -> [ConceptChunk] -> [DefinedQuantityDict]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith QuantityDict -> ConceptChunk -> DefinedQuantityDict
forall c.
(Quantity c, MayHaveUnit c) =>
c -> ConceptChunk -> DefinedQuantityDict
dqdQd (Sentence -> ChunkDB -> [QuantityDict]
vars' Sentence
a ChunkDB
m) (Sentence -> ChunkDB -> [ConceptChunk]
concpt Sentence
a ChunkDB
m)
combine' :: ModelExpr -> ChunkDB -> [DefinedQuantityDict]
combine' :: ModelExpr -> ChunkDB -> [DefinedQuantityDict]
combine' ModelExpr
a ChunkDB
m = (QuantityDict -> ConceptChunk -> DefinedQuantityDict)
-> [QuantityDict] -> [ConceptChunk] -> [DefinedQuantityDict]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith QuantityDict -> ConceptChunk -> DefinedQuantityDict
forall c.
(Quantity c, MayHaveUnit c) =>
c -> ConceptChunk -> DefinedQuantityDict
dqdQd (ModelExpr -> ChunkDB -> [QuantityDict]
vars ModelExpr
a ChunkDB
m) (ModelExpr -> ChunkDB -> [ConceptChunk]
concpt' ModelExpr
a ChunkDB
m)
ccss :: [Sentence] -> [ModelExpr] -> ChunkDB -> [DefinedQuantityDict]
ccss :: [Sentence] -> [ModelExpr] -> ChunkDB -> [DefinedQuantityDict]
ccss [Sentence]
s [ModelExpr]
e ChunkDB
c = [DefinedQuantityDict] -> [DefinedQuantityDict]
forall a. Eq a => [a] -> [a]
nub ([DefinedQuantityDict] -> [DefinedQuantityDict])
-> [DefinedQuantityDict] -> [DefinedQuantityDict]
forall a b. (a -> b) -> a -> b
$ (Sentence -> [DefinedQuantityDict])
-> [Sentence] -> [DefinedQuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Sentence -> ChunkDB -> [DefinedQuantityDict]
`combine` ChunkDB
c) [Sentence]
s [DefinedQuantityDict]
-> [DefinedQuantityDict] -> [DefinedQuantityDict]
forall a. [a] -> [a] -> [a]
++ (ModelExpr -> [DefinedQuantityDict])
-> [ModelExpr] -> [DefinedQuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ModelExpr -> ChunkDB -> [DefinedQuantityDict]
`combine'` ChunkDB
c) [ModelExpr]
e
ccss' :: [Sentence] -> [ModelExpr] -> ChunkDB -> [QuantityDict]
ccss' :: [Sentence] -> [ModelExpr] -> ChunkDB -> [QuantityDict]
ccss' [Sentence]
s [ModelExpr]
e ChunkDB
c = [QuantityDict] -> [QuantityDict]
forall a. Eq a => [a] -> [a]
nub ([QuantityDict] -> [QuantityDict])
-> [QuantityDict] -> [QuantityDict]
forall a b. (a -> b) -> a -> b
$ (Sentence -> [QuantityDict]) -> [Sentence] -> [QuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Sentence -> ChunkDB -> [QuantityDict]
`vars'` ChunkDB
c) [Sentence]
s [QuantityDict] -> [QuantityDict] -> [QuantityDict]
forall a. [a] -> [a] -> [a]
++ (ModelExpr -> [QuantityDict]) -> [ModelExpr] -> [QuantityDict]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ModelExpr -> ChunkDB -> [QuantityDict]
`vars` ChunkDB
c) [ModelExpr]
e
concpt :: Sentence -> ChunkDB -> [ConceptChunk]
concpt :: Sentence -> ChunkDB -> [ConceptChunk]
concpt Sentence
a ChunkDB
m = (UID -> ConceptChunk) -> [UID] -> [ConceptChunk]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> ConceptChunk
defResolve ChunkDB
m) ([UID] -> [ConceptChunk]) -> [UID] -> [ConceptChunk]
forall a b. (a -> b) -> a -> b
$ Sentence -> [UID]
sdep Sentence
a
concpt' :: ModelExpr -> ChunkDB -> [ConceptChunk]
concpt' :: ModelExpr -> ChunkDB -> [ConceptChunk]
concpt' ModelExpr
a ChunkDB
m = (UID -> ConceptChunk) -> [UID] -> [ConceptChunk]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> ConceptChunk
defResolve ChunkDB
m) ([UID] -> [ConceptChunk]) -> [UID] -> [ConceptChunk]
forall a b. (a -> b) -> a -> b
$ ModelExpr -> [UID]
meDep ModelExpr
a
getIdeaDict :: Sentence -> ChunkDB -> [IdeaDict]
getIdeaDict :: Sentence -> ChunkDB -> [IdeaDict]
getIdeaDict Sentence
a ChunkDB
m = (UID -> IdeaDict) -> [UID] -> [IdeaDict]
forall a b. (a -> b) -> [a] -> [b]
map (ChunkDB -> UID -> IdeaDict
termResolve ChunkDB
m) ([UID] -> [IdeaDict]) -> [UID] -> [IdeaDict]
forall a b. (a -> b) -> a -> b
$ Sentence -> [UID]
shortdep Sentence
a