Initial commit
This commit is contained in:
commit
7c512ab94f
26 changed files with 729 additions and 0 deletions
33
crates/typing/src/bin.rs
Normal file
33
crates/typing/src/bin.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
//! # 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,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue