Skip to main content

flow_types/
lib.rs

1//! The declaration model Flow's types are written in, with no values: the
2//! types a value crosses the host boundary at ([`Type`]), the declarations
3//! they name ([`Decl`], each known by its [`Identity`] in the module its
4//! [`ModulePath`] names), the shapes a record
5//! or enum value shares with its declaration ([`RecordShape`],
6//! [`EnumShape`]), the judgment of which types decoding may build and
7//! which values may cross ([`judge`]), and the index decoding finds a
8//! declared name by under a [`Spelling`] ([`NameIndex`]).
9//!
10//! The value model (`flow-lang-value`) builds its records and enums on these
11//! shapes, and the value encoding (`flow-abi`) keeps its declarations in a
12//! catalog of these and judges them with this kernel, which the checker
13//! judges a program's types with too. [`normal_path`] is std's
14//! `path.Path` normal form, which a declaration's library is written in, and
15//! [`LibraryLayout`] is the one layout of a library's files.
16
17#![cfg_attr(all(coverage, test), feature(coverage_attribute))]
18
19mod builtin;
20mod bundle;
21mod judge;
22mod module;
23mod names;
24mod nested;
25mod path;
26mod role;
27mod shape;
28#[expect(
29    clippy::match_same_arms,
30    reason = "generated from std, where a literal form's role marks the type of its own role"
31)]
32#[rustfmt::skip]
33mod std_roles;
34mod types;
35
36pub use builtin::{Builtin, Head};
37pub use bundle::{BundleError, bundled_file};
38pub use judge::{Crossing, Reason, Refusal, Settings, Step, judge};
39pub use module::{
40    KEYWORDS, LibraryLayout, ModulePath, Placement, Segments, SegmentsError, SourcePath,
41    SourcePathError, Spelled, Tree, lowercase_name,
42};
43pub use names::{NameIndex, SharedKey, Spelling};
44pub use nested::{Fold, Nested};
45pub use path::normal_path;
46pub use role::{
47    CallField, CodeStepCtor, DecodeErrorField, JsonNamesCtor, JsonProblemCtor, JsonStepCtor,
48    JsonValueCtor, Members, Mismatch, OptionCtor, ResultCtor, Role, StdEnum, StdRecord, StopCtor,
49    ToolProblemCtor, TypeMismatchField,
50};
51pub use shape::{Constructor, EnumShape, Payload, RecordShape};
52pub use std_roles::{STD_TYPES, Shape};
53pub use types::{Body, Decl, DeclId, Identity, MemberDoc, Type, Versions};
54
55/// `n`, a declaration's or parameter's number, as an index: every `usize`
56/// this crate is built for holds 32 bits.
57fn index(n: u32) -> usize {
58    usize::try_from(n).expect("a u32 fits a usize")
59}
60
61#[doc(hidden)]
62pub use flow_span::spelled as __spelled;