V0.4.0/dsl foundation#122
Merged
Merged
Conversation
New files:
- lib/ex_datalog/schema.ex — ExDatalog.Schema macro module + ExDatalog.UnsupportedFeature struct
- test/ex_datalog/schema_test.exs — 23 integration tests
Key features implemented:
- relation/2 macro — declare typed relations
- fact/1 and facts/2 macros — declare ground facts
- rule/2 macro — declare rules with lowercase vars, not_ negation, named constraints (gt, eq, add, etc.)
- query/2 macro — declare named post-materialization queries with find/where
- __before_compile__ generates program/0, materialize/0,1, queries/0, query/2
- Aggregate syntax (agg) parsed but returns %UnsupportedFeature{feature: :aggregates}
Convention: Uppercase identifiers (X, Y) in rule/query bodies are logic variables. Lowercase atoms and atoms starting with : are constants. _ is wildcard.
Results: 741 tests (718 existing + 23 new), 0 failures, credo clean.
Add Ecto-inspired macro DSL (use ExDatalog.Schema) with relation, fact, facts, rule, query, and wildcard macros that compile into the existing Program/Rule/Fact/Constraint/Knowledge builder APIs. Generated functions: program/0, materialize/0,1, queries/0, query/2 New modules: - ExDatalog.Schema — macro module with __before_compile__ - ExDatalog.DSL.CompileError — readable compile-time errors - ExDatalog.UnsupportedFeature — forward-compatible aggregate stub DSL features: - relation/2: typed field schemas (:atom, :integer, :string, :any) - fact/1, facts/2: single and bulk fact declaration - rule/2: lowercase vars, :atom constants, _/wildcard(), not_ negation, 16 named constraint predicates (gt, eq, add, member, etc.) - query/2: post-materialization queries with find/where and projection - Compile-time validation: undefined relations, unsafe variables, arity mismatches with descriptive error messages - Aggregate syntax parsed but not executable (returns UnsupportedFeature) Documentation: - README updated with DSL quickstart - docs/migration_dsl.md — builder API → DSL migration guide - docs/articles/ — 5 educational articles - livebooks/ex_datalog_dsl.livemd — interactive tutorial - CHANGELOG.md — v0.4.0 entry - mix.exs — extras for livebooks, articles, migration guide; DSL module group
…e before the Enum.each(constraint_ops, ...) expansion, since Elixir matches function clauses in definition order and the expanded constraint ops all match {atom(), _, list()} which would shadow {:agg, _, list}.
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.
v0.4.0: Schema DSL for declaring Datalog programs
Add Ecto-inspired macro DSL (use ExDatalog.Schema) with relation,
fact, facts, rule, query, and wildcard macros that compile into the
existing Program/Rule/Fact/Constraint/Knowledge builder APIs.
Generated functions: program/0, materialize/0,1, queries/0, query/2
New modules:
DSL features:
16 named constraint predicates (gt, eq, add, member, etc.)
arity mismatches with descriptive error messages
Documentation:
Tests: 786 total (718 existing + 68 new), 93.5% coverage, 0 failures.
Quality: mix format, compile --warnings-as-errors, credo --strict,
dialyzer, mix docs all clean. No breaking changes