Clean up to make room for new standard library

This commit is contained in:
Sam Vervaeck 2020-05-24 21:34:10 +02:00
parent 8f661f49a7
commit 1068dae5d6
9 changed files with 41 additions and 23 deletions

View file

@ -0,0 +1 @@

3
stdlib/either.bolt Normal file
View file

@ -0,0 +1,3 @@
pub struct Either<L, R>;

View file

@ -1,12 +1,5 @@
pub struct String; mod IO {
pub struct Either<L, R> {
is_right: bool,
value: L | R,
}
mod io {
pub type Result<T> = Either<Error, T>; pub type Result<T> = Either<Error, T>;
@ -36,5 +29,5 @@ mod io {
} }
print("Hello, world!"); // IO::print("Hello, world!");

View file

@ -1,5 +1,5 @@
mod Bolt.Lang { mod Bolt::Lang {
pub struct Pos { pub struct Pos {
offset: Int, offset: Int,

View file

View file

@ -1,7 +1,32 @@
newtype Int; pub struct i32;
pub struct i64;
pub struct isize;
pub struct u32;
pub struct u64;
pub struct usize;
pub fn fac(n: Int) -> Int { 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 {
if n == 0 { if n == 0 {
return 1 return 1
} else { } else {
@ -9,9 +34,3 @@ pub fn fac(n: Int) -> Int {
} }
} }
fn (a: Int) + (b: Int) -> Int {
}
precedence a + b < a * b;

4
stdlib/option.bolt Normal file
View file

@ -0,0 +1,4 @@
pub struct Option<T>;

3
stdlib/string.bolt Normal file
View file

@ -0,0 +1,3 @@
pub struct String;

View file

@ -1,5 +0,0 @@
import "lang/bolt" (
Identifier,
Syntax,
);