V0.3.0/refactor - #114
Merged
Merged
Conversation
- closed #109 - closed #110 - closed #111 Add ergonomic shorthand notation for constructing Datalog rules, avoiding the verbose Rule.new/Atom.new/Term.var ceremony. This introduces the Prolog-inspired convention where uppercase atoms become variables, :_ becomes a wildcard, and lowercase atoms/other values become constants. New APIs: - Program.add_rule/3,4 — accept {relation, [terms]} tuples for heads, {:positive/negative, {relation, [terms]}} for body literals, and {:op, args...} tuples for constraints - Term.from/1 — convert shorthand values to Term.t() - Atom.from_tuple/1 — construct Atom from {"rel", [terms]} tuple - Constraint.from_tuple/1 — construct Constraint from operator tuples ({:neq, :A, :B}, {:add, :X, :Y, :Z}, {:is_integer, :V}, etc.) Before: Program.add_rule(program, Rule.new( Atom.new("ancestor", [Term.var("X"), Term.var("Y")]), [{:positive, Atom.new("parent", [Term.var("X"), Term.var("Y")])}] ) ) After: Program.add_rule(program, {"ancestor", [:X, :Y]}, [{:positive, {"parent", [:X, :Y]}}] ) Constraint shorthand examples: {:neq, :A, :C} → Constraint.neq(Term.var("A"), Term.var("C")) {:gt, :S, 100_000} → Constraint.gt(Term.var("S"), Term.const(100_000)) {:add, :Balance, :Limit, :Total} {:is_integer, :V} → Constraint.type_integer(Term.var("V")) {:starts_with, :E, "admin."} {:member, :Dept, [:engineering, :infra]} The struct-based Program.add_rule/2 with Rule.new remains available for full control over term types. Both forms can be mixed in the same program. Updates across codebase: - All livebook examples (quickstart.livemd, examples.livemd, examples.exs) converted to shorthand notation - README Quick Start updated to showcase shorthand - Program moduledoc rewritten with shorthand examples - CHANGELOG.md updated with [Unreleased] section - Roadmap updated: v0.3.0 = shorthand, v0.4.0 = Sigil DSL (bumped from v0.3) - 38 new tests for Term.from/1, Atom.from_tuple/1, Constraint.from_tuple/1, and Program.add_rule/3,4 shorthand All 639 tests pass. Credo --strict clean. Dialyzer clean. mix docs --warnings-as-errors clean.
- mix.exs: version bumped 0.2.0 → 0.3.0 - mix.exs: livebooks added to extras for Hex docs - README.md: dependency ~> 0.3.0, livebook links in Documentation section, roadmap updated with rename note - CHANGELOG.md: [Unreleased] → [0.3.0] - 2025-06-19, added ### Changed section documenting Result → Knowledge, query → materialize, telemetry renames, error passthrough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.