renamings

This commit is contained in:
Felix Dilke 2026-01-27 14:22:43 +00:00
parent 7855e5ce20
commit 2102767367
2 changed files with 5 additions and 11 deletions

View File

@ -34,7 +34,7 @@ data RuleElement = -- entry occurring in a head or body relation - constant or v
deriving (Show, Eq) deriving (Show, Eq)
data RuleBodyElement = RuleBodyElement { data RuleBodyElement = RuleBodyElement {
_subRelationName :: Text, _subRelationId :: RelationId,
_ruleElements :: [RuleElement] _ruleElements :: [RuleElement]
} deriving (Show, Eq) } deriving (Show, Eq)
@ -44,22 +44,16 @@ data RelationRule = RelationRule {
} deriving (Show, Eq) } deriving (Show, Eq)
data Relation = Relation { data Relation = Relation {
_name :: Text, _name :: RelationId,
_arity :: Int, _arity :: Int,
_tuples :: Set [Constant], _tuples :: Set [Constant],
_rules :: [RelationRule] _rules :: [RelationRule]
} deriving (Show, Eq) } deriving (Show, Eq)
-- newtype RelationId = RelationId Text
-- deriving (Eq, Ord, Show)
-- Our constants will be the terms of the Datalog grammar - ints/variables/symbols -- Our constants will be the terms of the Datalog grammar - ints/variables/symbols
type Constant = Term type Constant = Term
type RelationId = Text type RelationId = Text
-- newtype Constant = Constant Text
-- deriving (Eq, Ord, Show)
emptyDB :: NaiveDatabase emptyDB :: NaiveDatabase
emptyDB = NaiveDatabase { emptyDB = NaiveDatabase {
relations = Map.empty, relations = Map.empty,
@ -211,7 +205,7 @@ withFactsAndRules facts rules =
fromBodyConstraint :: BodyConstraint -> RuleBodyElement fromBodyConstraint :: BodyConstraint -> RuleBodyElement
fromBodyConstraint (BodyConstraint subRelation elements) = fromBodyConstraint (BodyConstraint subRelation elements) =
RuleBodyElement { RuleBodyElement {
_subRelationName = _name subRelation, _subRelationId = _name subRelation,
_ruleElements = toRuleElement <$> elements _ruleElements = toRuleElement <$> elements
} }
toRuleElement :: ConstraintElement -> RuleElement toRuleElement :: ConstraintElement -> RuleElement

View File

@ -54,13 +54,13 @@ spec = do
headVariables = [ "X", "Y", "Z" ], headVariables = [ "X", "Y", "Z" ],
bodyElements = [ bodyElements = [
RuleBodyElement { RuleBodyElement {
_subRelationName = "parent", _subRelationId = "parent",
_ruleElements = [ _ruleElements = [
RuleElementVariable "X", RuleElementVariable "Z" RuleElementVariable "X", RuleElementVariable "Z"
] ]
}, },
RuleBodyElement { RuleBodyElement {
_subRelationName = "ancestor", _subRelationId = "ancestor",
_ruleElements = [ _ruleElements = [
RuleElementVariable "Z",RuleElementVariable "Y" RuleElementVariable "Z",RuleElementVariable "Y"
] ]