'addConstants' API method
This commit is contained in:
parent
72f973c195
commit
d8d2c51dec
@ -24,3 +24,4 @@ class DatalogDB db where
|
|||||||
lookupRelation :: db -> Text -> Maybe Relation
|
lookupRelation :: db -> Text -> Maybe Relation
|
||||||
insertRelation :: db -> Relation -> db
|
insertRelation :: db -> Relation -> db
|
||||||
addRule :: (Literal, [Literal]) -> db -> db
|
addRule :: (Literal, [Literal]) -> db -> db
|
||||||
|
addConstants :: db -> Set Constant -> db
|
||||||
@ -63,6 +63,12 @@ instance DatalogDB NaiveDatabase where
|
|||||||
relationMap' = Map.insert relationName relation' relationMap
|
relationMap' = Map.insert relationName relation' relationMap
|
||||||
constants' = constants db'
|
constants' = constants db'
|
||||||
|
|
||||||
|
addConstants :: NaiveDatabase -> Set Constant -> NaiveDatabase
|
||||||
|
addConstants db newConstants =
|
||||||
|
db {
|
||||||
|
constants = Set.union newConstants (constants db)
|
||||||
|
}
|
||||||
|
|
||||||
lookupRelation0 :: DatalogDB db => Text -> db -> Int -> Set [Constant] -> Relation
|
lookupRelation0 :: DatalogDB db => Text -> db -> Int -> Set [Constant] -> Relation
|
||||||
lookupRelation0 relationName db newArity tuples =
|
lookupRelation0 relationName db newArity tuples =
|
||||||
case lookupRelation db relationName of
|
case lookupRelation db relationName of
|
||||||
@ -139,6 +145,7 @@ digestHead db relation (Literal neg relationName terms) =
|
|||||||
headTermToElement (Var name) =
|
headTermToElement (Var name) =
|
||||||
RuleElementVariable $ lookupVariable name variableNames
|
RuleElementVariable $ lookupVariable name variableNames
|
||||||
headTermToElement constant = RuleElementConstant constant
|
headTermToElement constant = RuleElementConstant constant
|
||||||
|
-- db' = insertRelation db relation
|
||||||
relationMap :: Map RelationId Relation = relations db
|
relationMap :: Map RelationId Relation = relations db
|
||||||
relationMap' = Map.insert relationName relation relationMap
|
relationMap' = Map.insert relationName relation relationMap
|
||||||
extraVariables = headTermToElement <$> terms
|
extraVariables = headTermToElement <$> terms
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user