[][src]Crate canrun

Canrun is a logic programming library inspired by the *Kanren family of language DSLs.

Status: Exploratory and Highly Experimental

I'm still quite new to both Rust and logic programming, so there are likely to be rough edges. At best the goal is to be a useful implementation of the core concepts of a Kanren in way that is idiomatic to Rust. At worst it may just be a poor misinterpretation with fatal flaws.

Quick Start

use canrun::{Goal, both, unify, var};
use canrun::example::I32;

let x = var();
let y = var();
let goal: Goal<I32> = both(unify(x, y), unify(1, x));
let result: Vec<_> = goal.query(y).collect();
assert_eq!(result, vec![1])

Re-exports

pub use collections::*;
pub use domains::*;
pub use goals::*;
pub use state::*;
pub use value::*;

Modules

collections

Collections and related goal functions.

domains

Constrain the set of types that you can reason about in a particular context.

example

Basic domains for simple use cases.

goals

Make declarative assertions about the relationships between values.

state

Track value bindings and constraints during the evaluation process.

util

Assorted helpers, especially for testing.

value

Contain individual resolved values or variables that can be bound through unification.

Macros

all

Create a goal that only succeeds if all sub-goals succeed.

any

Create a goal that yields a state for every successful sub-goal.

lmap

Create an LMap with automatic key/value IntoVal wrapping.

ltup

Create a tuple of logical values with automatic IntoVal wrapping.

lvec

Create an LVec<T> with automatic value IntoVal wrapping.

val

Easy conversion of LVar<T> and T values into Val<T>.

Traits

Query

Derive reified values potential resolved states.

ReifyIn

Extract a fully resolved T from a Val<T>.

UnifyIn

How compatible values are matched with each other.