Some minor fixes to standard library
This commit is contained in:
parent
ec746b655d
commit
53b253b9e9
6 changed files with 43 additions and 29 deletions
|
@ -1,10 +1,13 @@
|
|||
|
||||
import "../option"
|
||||
import "../numbers"
|
||||
|
||||
mod Bolt::Lang {
|
||||
|
||||
pub struct Pos {
|
||||
offset: Int,
|
||||
line: Int,
|
||||
column: Int,
|
||||
offset: usize,
|
||||
line: usize,
|
||||
column: usize,
|
||||
}
|
||||
|
||||
pub struct Span {
|
||||
|
|
8
stdlib/lib.bolt
Normal file
8
stdlib/lib.bolt
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
pub import "./option"
|
||||
pub import "./either"
|
||||
pub import "./string"
|
||||
pub import "./math.bolt"
|
||||
pub import "./vec.bolt"
|
||||
pub import "./lang/bolt"
|
||||
|
|
@ -1,29 +1,4 @@
|
|||
|
||||
pub struct i32;
|
||||
pub struct i64;
|
||||
pub struct isize;
|
||||
pub struct u32;
|
||||
pub struct u64;
|
||||
pub struct usize;
|
||||
|
||||
trait Num;
|
||||
|
||||
fn (a: N) + (b: N) -> N where N: Num {
|
||||
N::add(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) - (b: N) -> N where N: Num {
|
||||
N::sub(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) / (b: N) -> N where N: Num {
|
||||
N::div(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) * (b: N) -> N where N: Num {
|
||||
N::mul(a, b)
|
||||
}
|
||||
|
||||
// precedence a + b < a * b;
|
||||
|
||||
pub fn fac(n: I) -> I where I: int {
|
||||
|
|
26
stdlib/numbers.bolt
Normal file
26
stdlib/numbers.bolt
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
pub struct i32;
|
||||
pub struct i64;
|
||||
pub struct isize;
|
||||
pub struct u32;
|
||||
pub struct u64;
|
||||
pub struct usize;
|
||||
|
||||
trait Num;
|
||||
|
||||
fn (a: N) + (b: N) -> N where N: Num {
|
||||
N::add(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) - (b: N) -> N where N: Num {
|
||||
N::sub(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) / (b: N) -> N where N: Num {
|
||||
N::div(a, b)
|
||||
}
|
||||
|
||||
fn (a: N) * (b: N) -> N where N: Num {
|
||||
N::mul(a, b)
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
pub struct Option<T>;
|
||||
|
||||
|
||||
|
|
3
stdlib/vec.bolt
Normal file
3
stdlib/vec.bolt
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
pub struct Vec<T>;
|
||||
|
Loading…
Reference in a new issue