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