1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! # Type System
//!
//! This module is available when the `types` feature is enabled.
//!
//! Types are defined by a type code which is a byte array. The type code is
//! used to represent the type of a value. This allows for a simple and
//! efficient way to represent types. The syntax of the type code is
//! straightforward and easy to understand and parse. The type code allows the
//! construction of complex types with multiple levels of nesting by combining
//! simpler types.
//!
//! The supported primitive types are the following:
//!
//! - **Boolean**: A boolean value.
//! - **Character**: A Unicode character.
//! - **Integer**: A signed integer value.
//! - **Float**: A floating-point value.
//! - **Symbol**: An interned string value.
//! - **Type**: A type value.
//! - **Binary**: A byte array value.
//!
//! Besides the primitive types, the type system supports the following
//! compound types:
//!
//! - **Array**: A homogeneous collection of elements.
//! - **Pair**: A pair of two values also known as a cons cell.
//! - **Lambda**: A function type.
//! - **Option**: A type that can be `None` or `Some(T)`.
//! - **Union**: A type that can be one of the given types. There must be at
//! least two types in the union.
//!
//! Special types are also supported:
//!
//! - **Any**: A type that can be any value.
//! - **Void**: A type that can't be any type or value. It is used to represent
//! the absence of a type. It is used in the context of functions that don't
//! return a value or do not take any arguments.
//! - **Nil**: A type that represents the absence of a value. It is used in the
//! context of optional types.
//!
//! The types are grouped into different categories:
//!
//! - **Specific Types**: Types that represent a specific value and can be a
//! member of a union type. These types are the following: *Boolean*,
//! *Character*, *Integer*, *Float*, *Symbol*, *Type*, *Binary*, *Array*, *Pair*
//! and *Lambda*.
//! - **Filled Types**: Types that represent a mor general specific value. These
//! types can be used in an option type. These types are the following: *Any*,
//! *Union* and *Specific Types*.
//!
//! ## Parser
//!
//! The type system includes two parsers: a type code parser and a parser for
//! a textual representation of types. The
//! [type code parser](crate::types::parser::binary) is used to parse
//! type codes and convert them into a type. The parser for the
//! [textual representation](crate::types::parser::text) of types is used to
//! parse a string and convert it into a type. The textual representation of
//! types is a human-readable format that can be used to represent types in a
//! more readable way than the type code.
//!
//! ## Type Checker
//!
//! The [`TypeChecker`] trait is used to implement type checking for an
//! interpreter or compiler. The type checker is used to check if a value has a
//! specific type or if a type is a subtype of another type. The type checker
//! can also be used to infer the type of an expression or a value. The type
//! checker is used to implement type inference and type checking for a
//! programming language.
use SmallVec;
pub use Type;
pub use ;
pub use TypeError;
pub use TypeCodeError;
pub use ;
/// Maximum number of elements in an array.
pub const ARRAY_MAX: usize = 0x000f_ffff_ffff;
/// A type alias for a small vector of type codes. The inline storage is 16
/// bytes which is enough for most types.
type TypeVec = ;