cl-typeck: More type inference

- Renamed "intrinsic" -> "primitive"
  - I thought it was funny, but it's just annoying.
- Rename "Uninferred" -> "Inferred"
  - It's a concrete type, but an inferred one.
- Add lifetimes to the Entry API
- Categorize does not care about recursive types. You can't have a recursive AST.
- Added helpful constructors to the inference engine
- Added some overloadable operators to the inference engine
  - These are a MAJOR work in progress
- Reorganized the Inference implementation file by functionality.

stdlib:
- Updated standard library.
This commit is contained in:
2025-04-22 06:33:57 -04:00
parent 7cf485fade
commit 681fbc88d3
16 changed files with 925 additions and 479 deletions

View File

@@ -1,7 +1,11 @@
//! # The Conlang Standard Library
pub mod preamble {
pub use super::{num::*, str::str};
pub use super::{
num::*,
range::{RangeExc, RangeInc},
str::str,
};
}
pub mod num;

View File

@@ -1,51 +1,51 @@
//! The primitive numeric types
#[intrinsic = "bool"]
#[lang = "bool"]
pub type bool;
#[intrinsic = "char"]
#[lang = "char"]
pub type char;
#[intrinsic = "i8"]
#[lang = "i8"]
pub type i8;
#[intrinsic = "i16"]
#[lang = "i16"]
pub type i16;
#[intrinsic = "i32"]
#[lang = "i32"]
pub type i32;
#[intrinsic = "i64"]
#[lang = "i64"]
pub type i64;
#[intrinsic = "i128"]
#[lang = "i128"]
pub type i128;
#[intrinsic = "isize"]
#[lang = "isize"]
pub type isize;
#[intrinsic = "u8"]
#[lang = "u8"]
pub type u8;
#[intrinsic = "u16"]
#[lang = "u16"]
pub type u16;
#[intrinsic = "u32"]
#[lang = "u32"]
pub type u32;
#[intrinsic = "u64"]
#[lang = "u64"]
pub type u64;
#[intrinsic = "u128"]
#[lang = "u128"]
pub type u128;
#[intrinsic = "usize"]
#[lang = "usize"]
pub type usize;
#[intrinsic = "f32"]
#[lang = "f32"]
pub type f32;
#[intrinsic = "f64"]
#[lang = "f64"]
pub type f64;
// Contains implementations for (TODO) overloaded operators on num types

View File

@@ -1,9 +1,17 @@
//! Iterable ranges
type T = _;
/// An Exclusive Range `a .. b` iterates from a to b, excluding b
#[intrinsic = "range_exc", T]
struct RangeExc(T, T)
// #[lang = "range_exc", T]
pub struct RangeExc(T, T)
/// An Inclusive Range `a ..= b` iterates from a to b, including b
#[intrinsic = "range_inc", T]
struct RangeInc(T, T)
// #[lang = "range_inc", T]
pub struct RangeInc(T, T)
impl RangeExc {
fn next(this: &RangeInc) -> T {
(*this).0
}
}

View File

@@ -1,4 +1,5 @@
//! TODO: give conland a string type
use super::num::u8;
// #[lang = "str"]
type str = [u8];