From 13420ed7458b6908e2239424a3a5120593af57f1 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 28 Mar 2019 10:37:43 +0100 Subject: [PATCH] Document the empty type Relates to #28 --- README.md | 9 ++++++++- src/lib.rs | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7df46b3..bffc67a 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ They return the result as the type it was passed into the function. ### Values Operators take values as arguments and produce values as results. -Values can be boolean, integer or floating point numbers. +Values can be boolean, integer or floating point numbers, tuples or the empty type. Strings are supported as well, but there are no operations defined for them yet. Values are denoted as displayed in the following table. @@ -165,8 +165,15 @@ Values are denoted as displayed in the following table. | `Value::Boolean` | `true`, `false` | | `Value::Int` | `3`, `-9`, `0`, `135412` | | `Value::Float` | `3.`, `.35`, `1.00`, `0.5`, `123.554` | +| `Value::Tuple` | `(3, 55.0, false, ())`, `(1, 2)` | +| `Value::Empty` | `()` | Integers are internally represented as `i64`, and floating point numbers are represented as `f64`. +Tuples are represented as `Vec` and empty values are not stored, but represented by rust's unit type `()` where necessary. + +There exist type aliases for some of the types. +They include `IntType`, `FloatType`, `TupleType` and `EmptyType`. + Values can be constructed either directly or using the `From` trait. Values can be decomposed using the `Value::as_[type]` methods. The type of a value can be checked using the `Value::is_[type]` methods. diff --git a/src/lib.rs b/src/lib.rs index 32a4b03..43facf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -143,7 +143,7 @@ //! ### Values //! //! Operators take values as arguments and produce values as results. -//! Values can be boolean, integer or floating point numbers. +//! Values can be boolean, integer or floating point numbers, tuples or the empty type. //! Strings are supported as well, but there are no operations defined for them yet. //! Values are denoted as displayed in the following table. //! @@ -152,8 +152,15 @@ //! | `Value::Boolean` | `true`, `false` | //! | `Value::Int` | `3`, `-9`, `0`, `135412` | //! | `Value::Float` | `3.`, `.35`, `1.00`, `0.5`, `123.554` | +//! | `Value::Tuple` | `(3, 55.0, false, ())`, `(1, 2)` | +//! | `Value::Empty` | `()` | //! //! Integers are internally represented as `i64`, and floating point numbers are represented as `f64`. +//! Tuples are represented as `Vec` and empty values are not stored, but represented by rust's unit type `()` where necessary. +//! +//! There exist type aliases for some of the types. +//! They include `IntType`, `FloatType`, `TupleType` and `EmptyType`. +//! //! Values can be constructed either directly or using the `From` trait. //! Values can be decomposed using the `Value::as_[type]` methods. //! The type of a value can be checked using the `Value::is_[type]` methods. @@ -283,7 +290,7 @@ pub use function::Function; pub use interface::*; pub use tree::Node; pub use value::{ - value_type::ValueType, EmptyType, FloatType, IntType, TupleType, Value, EMPTY_VALUE, + EMPTY_VALUE, EmptyType, FloatType, IntType, TupleType, Value, value_type::ValueType, }; mod context;