shiny/crates/typing/src/bin.rs
2024-10-15 20:33:46 +03:00

33 lines
827 B
Rust

//! # Binary types
use shiny_arena::make_comb;
use crate::ptr;
make_comb! {
/// Type with additionally equipped ID.
pub struct Field {
pub ty: ptr::Ty,
pub id: ptr::Id,
}
/// Product type. Pretty much just `lhs_ty * rhs_ty`.
/// The following properties must be upheld:
///
/// 1. lhs * rhs = rhs * lhs <- commutativity
/// 2. (a * b) * c = a * (b * c) <- associativity
pub struct Prod {
pub lhs: ptr::Ty,
pub rhs: ptr::Ty,
}
/// Sum type. Pretty much just `lhs_ty + rhs_ty`.
/// The following properties must be upheld:
///
/// 1. lhs + rhs = rhs + rhs <- commutativity
/// 2. (a + b) + c = a + (b + c) <- associativity
pub struct Sum {
pub lhs: ptr::Ty,
pub rhs: ptr::Ty,
}
}