diff --git a/haskell-experiments/src/Datalog/NaiveQE.hs b/haskell-experiments/src/Datalog/NaiveQE.hs index 19ce12e..07da548 100644 --- a/haskell-experiments/src/Datalog/NaiveQE.hs +++ b/haskell-experiments/src/Datalog/NaiveQE.hs @@ -48,6 +48,10 @@ computeHerbrand db = relation <- lookupRelation db relationName pure (relationName, relation) ) 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 = if changed then Just newFacts else Nothing where @@ -59,10 +63,6 @@ computeHerbrand db = amalgamateRelationSub newFacts relation = foldr amalgamateRule newFacts (_rules relation) where amalgamateRule :: RelationRule -> NewFacts -> NewFacts - amalgamateRule rule newFacts = + amalgamateRule (RelationRule headVars body) newFacts = newFacts - computeHerbrandSub :: Map Text Relation -> Map Text Relation - computeHerbrandSub facts = - maybe facts computeHerbrandSub (updateFacts facts) - allRelationNames :: [Text] = relationNames db