ds-kanren-0.2.0.0: A subset of the miniKanren language

Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.DSKanren.Core

Synopsis

Documentation

data Term Source

The terms of our logical language.

Constructors

Var Var

Logical variables that can unify with other terms

Atom String

The equivalent of Scheme's symbols or keywords

Pair Term Term

Pairs of terms

Instances

data Var Source

The abstract type of variables. As a consumer you should never feel the urge to manipulate these directly.

Instances

type Neq = (Term, Term) Source

(===) :: Term -> Term -> Predicate Source

Equating two terms will attempt to unify them and backtrack if this is impossible.

(=/=) :: Term -> Term -> Predicate Source

The opposite of unification. If any future unification would cause these two terms to become equal we'll backtrack.

fresh :: (Term -> Predicate) -> Predicate Source

Generate a fresh (not rigid) term to use for our program.

conj :: Predicate -> Predicate -> Predicate Source

Conjunction. This will return solutions that satsify both the first and second predicate.

disconj :: Predicate -> Predicate -> Predicate Source

Disjunction. This will return solutions that satisfy either the first predicate or the second.

failure :: Predicate Source

The Eeyore of predicates, always fails. This is mostly useful as a way of pruning out various conditions, as in conj (a === b) failure. This is also an identity for disconj.

success :: Predicate Source

The Tigger of predicates! always passes. This isn't very useful on it's own, but is helpful when building up new combinators. This is also an identity for conj.

currentGoal :: Term Source

The goal that this logic program is trying to create. This is occasionally useful when we're doing generating programs.

run :: (Term -> Predicate) -> [(Term, [Neq])] Source

Run a program and find all solutions for the parametrized term.