minor fix

This commit is contained in:
Felix Dilke 2026-01-27 18:01:30 +00:00
parent 429d64ee73
commit 43e7d8afed

View File

@ -116,8 +116,7 @@ maybeConstant (RuleElementConstant constant) = Just constant
maybeConstant _ = Nothing
withFactsAndRules :: [Text] -> [Text] -> NaiveDatabase
withFactsAndRules facts =
foldr (addRule . extractRule) (withFacts facts)
withFactsAndRules facts = foldr (addRule . extractRule) (withFacts facts)
where
extractRule :: Text -> (Literal, [Literal])
extractRule ruleText =
@ -179,18 +178,18 @@ withFactsAndRules facts =
terms = arguments ruleHead
newArity = length terms
relation = lookupRelation relationName (relations db) newArity Set.empty
context' = digestHead db relation ruleHead
context'' = foldl digestBody context' body
db' = _db context''
context = digestHead db relation ruleHead
context' = foldl digestBody context body
db' = _db context'
relationMap = relations db'
variables' = _headEntries context''
variables' = _headEntries context'
extractVarName :: RuleElement -> Maybe Text
extractVarName (RuleElementVariable varName) = Just varName
extractVarName (RuleElementConstant constant) = Nothing
newRule =
RelationRule
{ headVariables = mapMaybe extractVarName variables'
, bodyElements = fromBodyConstraint <$> _bodyConstraints context''
, bodyElements = fromBodyConstraint <$> _bodyConstraints context'
}
where
fromBodyConstraint :: BodyConstraint -> RuleBodyElement