Clean up to make room for new standard library
This commit is contained in:
parent
8f661f49a7
commit
1068dae5d6
9 changed files with 41 additions and 23 deletions
|
@ -0,0 +1 @@
|
|||
|
3
stdlib/either.bolt
Normal file
3
stdlib/either.bolt
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
pub struct Either<L, R>;
|
||||
|
|
@ -1,12 +1,5 @@
|
|||
|
||||
pub struct String;
|
||||
|
||||
pub struct Either<L, R> {
|
||||
is_right: bool,
|
||||
value: L | R,
|
||||
}
|
||||
|
||||
mod io {
|
||||
mod IO {
|
||||
|
||||
pub type Result<T> = Either<Error, T>;
|
||||
|
||||
|
@ -36,5 +29,5 @@ mod io {
|
|||
|
||||
}
|
||||
|
||||
print("Hello, world!");
|
||||
// IO::print("Hello, world!");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
mod Bolt.Lang {
|
||||
mod Bolt::Lang {
|
||||
|
||||
pub struct Pos {
|
||||
offset: Int,
|
||||
|
|
|
@ -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 {
|
||||
return 1
|
||||
} 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
4
stdlib/option.bolt
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
pub struct Option<T>;
|
||||
|
||||
|
3
stdlib/string.bolt
Normal file
3
stdlib/string.bolt
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
pub struct String;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
import "lang/bolt" (
|
||||
Identifier,
|
||||
Syntax,
|
||||
);
|
Loading…
Reference in a new issue