simplified addRule
This commit is contained in:
parent
2f911a9f39
commit
b816bb4cae
@ -53,7 +53,8 @@ instance DatalogDB NaiveDatabase where
|
||||
|
||||
addRule :: (Literal, [Literal]) -> NaiveDatabase -> NaiveDatabase
|
||||
addRule (ruleHead, body) db =
|
||||
NaiveDatabase relationMap' constants' where
|
||||
insertRelation db' newRelation
|
||||
where
|
||||
relationName = predName ruleHead
|
||||
terms = arguments ruleHead
|
||||
newArity = length terms
|
||||
@ -61,13 +62,10 @@ instance DatalogDB NaiveDatabase where
|
||||
context = digestHead db relation ruleHead
|
||||
context' = foldr digestBody context body
|
||||
db' = _db context'
|
||||
relationMap = relations db'
|
||||
relation' = appendRule relation RelationRule {
|
||||
newRelation = appendRule relation RelationRule {
|
||||
headVariables = _variableNames context'
|
||||
, bodyElements = toRuleBodyElement <$> _bodyConstraints context'
|
||||
}
|
||||
relationMap' = Map.insert relationName relation' relationMap
|
||||
constants' = constants db'
|
||||
|
||||
addConstants :: NaiveDatabase -> Set Constant -> NaiveDatabase
|
||||
addConstants db newConstants =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user