still tidier, broken
This commit is contained in:
parent
3a5a70fbde
commit
e5fc523d92
@ -170,15 +170,7 @@ withFactsAndRules facts = foldr (addRule . extractRule) (withFacts facts)
|
||||
constraints = _bodyConstraints context
|
||||
newConstraint = BodyConstraint subRelation variables'
|
||||
constraints' = newConstraint : constraints
|
||||
-- varIndex :: Text -> Int
|
||||
-- varIndex name =
|
||||
-- case elemIndex (RuleElementVariable name) variables' of
|
||||
-- Just index -> index
|
||||
-- Nothing -> throw $ VariableLookupException name variables'
|
||||
-- toConstraint :: Term -> ConstraintElement
|
||||
-- toConstraint (Var name) = ConstraintElementIndex (varIndex name)
|
||||
-- toConstraint constant = ConstraintElementConstant constant
|
||||
addRule :: (Literal, [Literal]) -> NaiveDatabase ->NaiveDatabase
|
||||
addRule :: (Literal, [Literal]) -> NaiveDatabase -> NaiveDatabase
|
||||
addRule (ruleHead, body) db =
|
||||
NaiveDatabase relationMap' constants'
|
||||
where
|
||||
@ -190,10 +182,6 @@ withFactsAndRules facts = foldr (addRule . extractRule) (withFacts facts)
|
||||
context' = foldr digestBody context body
|
||||
db' = _db context'
|
||||
relationMap = relations db'
|
||||
-- variables' = _headEntries context'
|
||||
-- extractVarName :: RuleElement -> Maybe Text
|
||||
-- extractVarName (RuleElementVariable varName) = Just varName
|
||||
-- extractVarName (RuleElementConstant constant) = Nothing
|
||||
newRule =
|
||||
RelationRule
|
||||
{ headVariables = _variableNames context'
|
||||
@ -205,9 +193,6 @@ withFactsAndRules facts = foldr (addRule . extractRule) (withFacts facts)
|
||||
_subRelationId = _name subRelation
|
||||
, _ruleElements = elements
|
||||
}
|
||||
-- toRuleElement :: ConstraintElement -> RuleElement
|
||||
-- toRuleElement (ConstraintElementConstant constant) = RuleElementConstant constant
|
||||
-- toRuleElement (ConstraintElementIndex index) = variables' !! index
|
||||
relation' =
|
||||
Relation
|
||||
{ _name = _name relation
|
||||
@ -217,9 +202,6 @@ withFactsAndRules facts = foldr (addRule . extractRule) (withFacts facts)
|
||||
}
|
||||
relationMap' = Map.insert relationName relation' relationMap
|
||||
constants' = constants db'
|
||||
-- toElement :: Term -> RuleElement
|
||||
-- toElement (Var name) = RuleElementVariable name
|
||||
-- toElement constant = RuleElementConstant constant
|
||||
extractVariableNames :: [Term] -> [Text]
|
||||
extractVariableNames = mapMaybe extractVariableName where
|
||||
extractVariableName :: Term -> Maybe Text
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user