1#![warn(missing_docs)]
8#![deny(unsafe_op_in_unsafe_fn)]
9
10pub mod arena;
11pub mod context;
12pub mod conversion;
13pub mod environment;
14pub mod level;
15pub mod symbol;
16pub mod term;
17pub mod typechecker;
18pub mod unification;
19
20pub use arena::Arena;
21pub use context::Context;
22pub use environment::Environment;
23pub use level::{Level, LevelId};
24pub use symbol::{Symbol, SymbolId, SymbolTable};
25pub use term::{Binder, Term, TermId, TermKind};
26
27pub type Result<T> = std::result::Result<T, Error>;
29
30#[derive(Debug, Clone)]
32pub enum Error {
33 TypeError(String),
35
36 UniverseError(String),
38
39 UnificationError(String),
41
42 NotFound(String),
44
45 ConversionError {
47 expected: String,
49 actual: String,
51 },
52
53 Internal(String),
55}
56
57impl std::fmt::Display for Error {
58 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59 match self {
60 Error::TypeError(msg) => write!(f, "Type error: {}", msg),
61 Error::UniverseError(msg) => write!(f, "Universe error: {}", msg),
62 Error::UnificationError(msg) => write!(f, "Unification error: {}", msg),
63 Error::NotFound(msg) => write!(f, "Not found: {}", msg),
64 Error::ConversionError { expected, actual } => {
65 write!(f, "Conversion check failed: {} ≠ {}", expected, actual)
66 }
67 Error::Internal(msg) => write!(f, "Internal error: {}", msg),
68 }
69 }
70}
71
72impl std::error::Error for Error {}
73
74#[cfg(test)]
75mod tests {
76 use super::*;
77
78 #[test]
79 fn test_basic_term_creation() {
80 let arena = Arena::new();
81 let symbols = SymbolTable::new();
82
83 assert!(arena.terms() == 0);
85 }
86}