1.8 KiB
1.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build Commands
cabal build # Build the project
cabal test # Run all tests
cabal repl # Start interactive REPL
To run a single test file or specific test:
cabal test --test-option=--match="/DatalogParser/"
Architecture
This is an experimental Datalog implementation in Haskell with the following components:
Parsing Layer (src/Datalog/DatalogParser.hs)
Megaparsec-based parser that converts Datalog text into an AST:
Term- Variables (Var), symbols (Sym), numbers (Num)Literal- Predicate with arguments, optionally negatedStatement- Fact, Rule (withHeadand body literals), or Query- Entry points:
parseDatalog,parseDatalogFile
Evaluation Engine (src/Datalog/NaiveDatabase.hs)
Naive evaluation database storing relations and rules:
NaiveDatabase- Containsrelationsmap andconstantsset (Herbrand universe)Relation- Name, arity, tuples (facts), and associated rulesRelationRule- Head variables and body constraints- Key functions:
withFacts,withFactsAndRulesfor building databases - Query evaluation is not yet implemented
Data Flow
- Text parsed into
Statement(Fact/Rule/Query) - Facts populate relations with tuples; rules encode derivation logic via
RuleContextandBodyConstraint - Variables are indexed during rule processing for efficient constraint matching
Other Modules
SimpleParser/ArithmeticParser- Experimental arithmetic expression parsersOlogs- Categorical data structures (dots and arcs representing objects and morphisms)
Development Environment
Nix support via shell.nix provides HLS, cabal-install, and Hoogle. Use direnv allow for automatic environment loading.