digestHead abstracts DatalogDB
This commit is contained in:
parent
6dda089bfe
commit
136412a4dd
@ -30,7 +30,7 @@ data NaiveDatabase = NaiveDatabase
|
||||
|
||||
instance DatalogDB NaiveDatabase where
|
||||
emptyDB :: NaiveDatabase
|
||||
emptyDB = NaiveDatabase
|
||||
emptyDB = NaiveDatabase
|
||||
{ relations = Map.empty
|
||||
, constants = Set.empty -- the Herbrand universe
|
||||
}
|
||||
@ -118,15 +118,15 @@ withFacts =
|
||||
newRelationMap = Map.insert relationName newRelation relationMap
|
||||
newConstantSet = Set.union constantSet $ Set.fromList terms
|
||||
|
||||
data RuleContext = RuleContext
|
||||
data (DatalogDB db) => RuleContext db = RuleContext
|
||||
{ __relation :: Relation
|
||||
, _variableNames :: [Text]
|
||||
, _headEntries :: [RuleElement]
|
||||
, _bodyConstraints :: [BodyConstraint]
|
||||
, _db :: NaiveDatabase
|
||||
, _db :: db
|
||||
}
|
||||
|
||||
digestHead :: NaiveDatabase -> Relation -> Literal -> RuleContext
|
||||
digestHead :: forall db . (DatalogDB db) => db -> Relation -> Literal -> RuleContext db
|
||||
digestHead db relation (Literal neg relationName terms) =
|
||||
RuleContext
|
||||
{ __relation = relation
|
||||
@ -147,7 +147,7 @@ digestHead db relation (Literal neg relationName terms) =
|
||||
extractConstant :: RuleElement -> Maybe Constant
|
||||
extractConstant (RuleElementConstant constant) = Just constant
|
||||
extractConstant _ = Nothing
|
||||
digestBody :: Literal -> RuleContext -> RuleContext
|
||||
digestBody :: Literal -> RuleContext NaiveDatabase -> RuleContext NaiveDatabase
|
||||
digestBody (Literal neg subRelationName subTerms) context =
|
||||
context {
|
||||
_variableNames = variableNames
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user