renamings
This commit is contained in:
parent
7855e5ce20
commit
2102767367
@ -34,7 +34,7 @@ data RuleElement = -- entry occurring in a head or body relation - constant or v
|
||||
deriving (Show, Eq)
|
||||
|
||||
data RuleBodyElement = RuleBodyElement {
|
||||
_subRelationName :: Text,
|
||||
_subRelationId :: RelationId,
|
||||
_ruleElements :: [RuleElement]
|
||||
} deriving (Show, Eq)
|
||||
|
||||
@ -44,22 +44,16 @@ data RelationRule = RelationRule {
|
||||
} deriving (Show, Eq)
|
||||
|
||||
data Relation = Relation {
|
||||
_name :: Text,
|
||||
_name :: RelationId,
|
||||
_arity :: Int,
|
||||
_tuples :: Set [Constant],
|
||||
_rules :: [RelationRule]
|
||||
} deriving (Show, Eq)
|
||||
|
||||
-- newtype RelationId = RelationId Text
|
||||
-- deriving (Eq, Ord, Show)
|
||||
|
||||
-- Our constants will be the terms of the Datalog grammar - ints/variables/symbols
|
||||
type Constant = Term
|
||||
type RelationId = Text
|
||||
|
||||
-- newtype Constant = Constant Text
|
||||
-- deriving (Eq, Ord, Show)
|
||||
|
||||
emptyDB :: NaiveDatabase
|
||||
emptyDB = NaiveDatabase {
|
||||
relations = Map.empty,
|
||||
@ -211,7 +205,7 @@ withFactsAndRules facts rules =
|
||||
fromBodyConstraint :: BodyConstraint -> RuleBodyElement
|
||||
fromBodyConstraint (BodyConstraint subRelation elements) =
|
||||
RuleBodyElement {
|
||||
_subRelationName = _name subRelation,
|
||||
_subRelationId = _name subRelation,
|
||||
_ruleElements = toRuleElement <$> elements
|
||||
}
|
||||
toRuleElement :: ConstraintElement -> RuleElement
|
||||
|
||||
@ -54,13 +54,13 @@ spec = do
|
||||
headVariables = [ "X", "Y", "Z" ],
|
||||
bodyElements = [
|
||||
RuleBodyElement {
|
||||
_subRelationName = "parent",
|
||||
_subRelationId = "parent",
|
||||
_ruleElements = [
|
||||
RuleElementVariable "X", RuleElementVariable "Z"
|
||||
]
|
||||
},
|
||||
RuleBodyElement {
|
||||
_subRelationName = "ancestor",
|
||||
_subRelationId = "ancestor",
|
||||
_ruleElements = [
|
||||
RuleElementVariable "Z",RuleElementVariable "Y"
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user