cl_typeck/lib.rs
1//! # The Conlang Type Checker
2//!
3//! As a statically typed language, Conlang requires a robust type checker to enforce correctness.
4//!
5//! This crate is a major work-in-progress.
6//!
7//! # The [Table](table::Table)™
8//! A directed graph of nodes and their dependencies.
9//!
10//! Contains [item definitions](handle) and [type expression](type_expression) information.
11//!
12//! *Every* item is itself a module, and can contain arbitrarily nested items
13//! as part of the item graph
14//!
15//! The table, additionally, has some queues for use in external algorithms,
16//! detailed in the [stage] module.
17//!
18//! # Namespaces
19//! Each item in the graph is given its own namespace, which is further separated into
20//! two distinct parts:
21//! - Children of an item are direct descendents (i.e. their `parent` is a handle to the item)
22//! - Imports of an item are indirect descendents created by `use` or `impl` directives. They are
23//! shadowed by Children with the same name.
24//!
25//! # Order of operations:
26//! For order-of-operations information, see the [stage] module.
27#![warn(clippy::all)]
28
29pub(crate) mod format_utils;
30
31pub mod table;
32
33pub mod handle;
34
35pub mod entry;
36
37pub mod source;
38
39pub mod type_kind;
40
41pub mod type_expression;
42
43pub mod stage {
44 //! Type collection, evaluation, checking, and inference passes.
45 //!
46 //! # Order of operations
47 //! 1. [mod@populate]: Populate the graph with nodes for every named item.
48 //! 2. [mod@import]: Import the `use` nodes discovered in [Stage 1](populate).
49 //! 3. [mod@categorize]: Categorize the nodes according to textual type information.
50 //! - Creates anonymous types (`fn(T) -> U`, `&T`, `[T]`, etc.) as necessary to fill in the
51 //! type graph
52 //! - Creates a new struct type for every enum struct-variant.
53 //! 4. [mod@implement]: Import members of implementation modules into types.
54
55 pub use populate::Populator;
56 /// Stage 1: Populate the graph with nodes.
57 pub mod populate;
58
59 pub use import::import;
60 /// Stage 2: Import the `use` nodes discovered in Stage 1.
61 pub mod import;
62
63 pub use categorize::categorize;
64 /// Stage 3: Categorize the nodes according to textual type information.
65 pub mod categorize;
66
67 pub use implement::implement;
68 /// Stage 4: Import members of `impl` blocks into their corresponding types.
69 pub mod implement;
70
71 // TODO: Make type inference stage 5
72 // TODO: Use the type information stored in the [table]
73 pub mod infer;
74}