Module canrun::goals

source ·
Expand description

Declarative relationships between values.

Goals provide a high level interface for defining logic programs. They are composable, with many higher level goals being made up of lower level primitives. Since the typical way of using goals are through simple functions, it is easy to build and reuse custom, first class goal constructors.

While State exposes a lower level API, in practice there really shouldn’t be anything that can’t be expressed using goals.

Most structs that implement Goal are constructed with one of the many constructor functions and macros. These high level methods provide automatic Value wrapping through Into<Value<T>> and other niceties.

Re-exports

Modules

Macros

  • Create a goal that only succeeds if all sub-goals succeed.
  • Create a goal that yields a state for every successful sub-goal.

Structs

  • A Goal that only succeeds if all sub-goals succeed.
  • A Goal that yields a state for every successful sub-goal.
  • A Goal that only succeeds if both sub-goals succeed. Create with both.
  • A Goal that gives access to the underlying State struct. Create with custom.
  • A Goal that succeeds if either sub-goal succeed. Create with either.
  • A Goal that always fails.
  • A Goal that is generated via callback just as it is about to be evaluated. Create with lazy.
  • A Not goal that needs to keep evaluating the state as variables are resolved.
  • A Goal that always succeeds.
  • Create a goal that attempts to unify two values with each other. Create with unify.

Enums

  • A Goal that only succeeds if the sub-goal is proved to always fail.

Traits

  • Types implementing Goal represent declarative, lazily applied state updates.

Functions

  • Create a goal that only succeeds if both sub-goals succeed.
  • Create a goal that gives access to the underlying State struct.
  • Create a goal that succeeds if either sub-goal succeed.
  • Create a goal that is generated via callback just as it is about to be evaluated.
  • Create a Goal that only succeeds if the sub-goal is proved to always fail.
  • Create a goal that attempts to unify two values with each other.