Semi-naive fixed-point relational computation in MoonBit, ported from Datafrog
///|
test "transitive permissions" {
let iteration = @datafrog.Iteration()
let permissions : @datafrog.Variable[(String, String)] = iteration.variable(
"permissions",
)
let parents = @datafrog.Relation([("editors", "alice"), ("staff", "editors")])
permissions.insert_all([("staff", "read dashboard")])
while iteration.changed() {
permissions.from_join(permissions, parents.as_input(), fn(
_,
permission,
person,
) {
(person, permission)
})
}
assert_eq(permissions.complete().to_array(), [
("alice", "read dashboard"),
("staff", "read dashboard"),
("editors", "read dashboard"),
])
}moon add bobzhang/datafrog@0.1.0moon fmt --check
moon check --target all --warn-list +unnecessary_annotation --deny-warn
moon test --target all
moon run cmd/demo
# Restore pinned reference using UPSTREAM.md first:
python3 validation/compare.pypub struct Iteration {
// private fields
}pub struct Leaper[P, V] {
// private fields
}pub struct Relation[T] {
// private fields
}pub struct Variable[T] {
// private fields
}pub struct VariableStats {
name : String
stable : Int
recent : Int
pending : Int
batches : Int
}Install
Download zipSemi-naive fixed-point relational computation in MoonBit, ported from Datafrog