Metadata-Version: 2.4
Name: mangle-py
Version: 0.7.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Summary: Python bindings for Mangle, a Datalog-style logic language. Import as `import mangle`.
Home-Page: https://codeberg.org/TauCeti/mangle-rs
Author-email: Burak Emir <burak.emir@gmail.com>
License: Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://codeberg.org/TauCeti/mangle-rs

# mangle-py

Python bindings for Mangle (Datalog-style logic language), built with PyO3 and maturin.

## Build

```sh
# in crates/mangle-py
uv venv
uv pip install maturin
maturin develop --release
```

Then `import mangle` in Python.

## API (v1)

```python
import mangle

# One-shot evaluation
results = mangle.eval("p(1). p(2). q(X) :- p(X).", query="q(X)")

# Stateful program
prog = mangle.Program("p(1). q(X) :- p(X).")
prog.query("q")              # -> [[1]]
prog.relations()             # -> ["p", "q"]
prog.insert("p", [2])        # add EDB fact (no auto re-derivation)
prog.retract("p", [1])

# Multi-unit
prog = mangle.Program.from_units([unit_a, unit_b])

# Name constants distinct from strings
mangle.Name("/role/admin")
```

## Limitations (v1)

- No automatic re-derivation after `insert`/`retract`. To re-evaluate rules, create a new `Program`.
- Compound `Struct` values map to Python `dict`; field order is not preserved on round-trip.
- WASM/server mode and Python-implemented `Store` backends are not exposed.

