Module knube::exp [−][src]
Simple expression construction.
This module defines an expression type that is able to describe simple expressions composed of constants, variables, and applications.
Usage
To construct expressions, the API provides the functions cst
, var
, and app
, which
construct constants, variables, and applications, respectively. The corresponding Exp
enum
variants can be used directly but require a call to Box::new
to construct each value of the
App
tuple.
These functions allow the expressions to be constructed similarly to how they would be in functional languages like OCaml, for example:
use knube::exp::{cst, var, app}; let e = app(app(cst("f"), cst("a")), var("x"));
Which would translate to the expression ((f a) x)
(OCaml style) or f(a)(x)
(Rust style).
This crate uses the Rust style to display expressions.
Enums
Exp | A simple expression, as described in the module documentation. |
Functions
app | Constructs an application with the given left and right expressions. |
cst | Constructs a constant with the given name. |
var | Constructs a variable with the given name. Variables are just identifiers, they don’t hold any value. |
Type Definitions
ExpBox | An alias to make functions signatures returning expressions easier to read and write. |