rearranging code

This commit is contained in:
Felix Dilke 2026-02-10 12:41:57 +00:00
parent 97c9e2d34b
commit f4cd68a76e

View File

@ -48,6 +48,10 @@ computeHerbrand db =
relation <- lookupRelation db relationName relation <- lookupRelation db relationName
pure (relationName, relation) pure (relationName, relation)
) allRelationNames ) allRelationNames
allRelationNames :: [Text] = relationNames db
computeHerbrandSub :: Map Text Relation -> Map Text Relation
computeHerbrandSub facts =
maybe facts computeHerbrandSub (updateFacts facts)
updateFacts :: Facts -> Maybe Facts updateFacts :: Facts -> Maybe Facts
updateFacts facts = updateFacts facts =
if changed then Just newFacts else Nothing where if changed then Just newFacts else Nothing where
@ -59,10 +63,6 @@ computeHerbrand db =
amalgamateRelationSub newFacts relation = amalgamateRelationSub newFacts relation =
foldr amalgamateRule newFacts (_rules relation) where foldr amalgamateRule newFacts (_rules relation) where
amalgamateRule :: RelationRule -> NewFacts -> NewFacts amalgamateRule :: RelationRule -> NewFacts -> NewFacts
amalgamateRule rule newFacts = amalgamateRule (RelationRule headVars body) newFacts =
newFacts newFacts
computeHerbrandSub :: Map Text Relation -> Map Text Relation
computeHerbrandSub facts =
maybe facts computeHerbrandSub (updateFacts facts)
allRelationNames :: [Text] = relationNames db