diff --git a/haskell-experiments/src/Datalog/NaiveDatabase.hs b/haskell-experiments/src/Datalog/NaiveDatabase.hs index 75ecd77..8776d81 100644 --- a/haskell-experiments/src/Datalog/NaiveDatabase.hs +++ b/haskell-experiments/src/Datalog/NaiveDatabase.hs @@ -100,17 +100,12 @@ data BodyConstraint = BodyConstraint { data RuleContext = RuleContext { __relation :: Relation, + -- _variableNames :: [Text], _headVariables :: [RuleElement], _bodyConstraints :: [BodyConstraint], _db :: NaiveDatabase } -toElement :: Term -> RuleElement --- toElement constant@(Var _) = RuleElementConstant constant --- toElement constant@(Num _) = RuleElementConstant constant -toElement (Var name) = RuleElementVariable name -toElement constant = RuleElementConstant constant - maybeConstant :: RuleElement -> Maybe Constant maybeConstant (RuleElementConstant constant) = Just constant maybeConstant _ = Nothing @@ -202,6 +197,9 @@ withFactsAndRules facts rules = } newRelationMap = Map.insert relationName relation' relationMap constants' = constants db' + toElement :: Term -> RuleElement + toElement (Var name) = RuleElementVariable name + toElement constant = RuleElementConstant constant query :: NaiveDatabase -> Text -> Text query db qText =