proto_vulcan/operator/matche.rs
1//! # Match-operator
2//!
3//! Pattern matching to the tree-terms is done with the `match`-operator, which corresponds to
4//! miniKanren `matche`. Matche, matchu, and matcha are also available.
5//! ```rust
6//! # extern crate proto_vulcan;
7//! # use proto_vulcan::prelude::*;
8//! pub fn membero<U: User, E: Engine<U>>(x: LTerm<U, E>, l: LTerm<U, E>) -> Goal<U, E> {
9//! proto_vulcan_closure!(match l {
10//! [head | _] => head == x,
11//! [_ | rest] => membero(x, rest),
12//! })
13//! }
14//! # fn main() {}
15//! ```
16//!
17
18use crate::engine::Engine;
19use crate::goal::{Goal, GoalCast};
20use crate::operator::conde::Conde;
21use crate::operator::PatternMatchOperatorParam;
22use crate::user::User;
23
24pub fn matche<U, E>(param: PatternMatchOperatorParam<U, E, Goal<U, E>>) -> Goal<U, E>
25where
26 U: User,
27 E: Engine<U>,
28{
29 Conde::from_conjunctions(param.arms).cast_into()
30}