Skip to content

Commit

Permalink
Flesh out stdlib a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Jan 2, 2024
1 parent 2949941 commit c7f6e58
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/rose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"exports": {
".": "./dist/index.js",
"./ad": "./dist/ad.js",
"./num": "./dist/num.js",
"./prelude": "./dist/prelude.js"
},
Expand Down
137 changes: 137 additions & 0 deletions packages/rose/src/num.rose
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,143 @@ pub infixl [1] A B (Mul A B) => (x : A) * (y : B) : (Mul A B).T = Mul.mul x y

pub infixl [1] A B (Div A B) => (x : A) / (y : B) : (Div A B).T = Div.div x y

# i32

instance Neg i32 {
type T = i32
def neg = i32.neg
}

instance Add i32 i32 {
type T = i32
def add = i32.add
}

instance Sub i32 i32 {
type T = i32
def sub = i32.sub
}

instance Mul i32 i32 {
type T = i32
def mul = i32.mul
}

instance Div i32 i32 {
type T = i32
def div = i32.div
}

# u32

instance Neg u32 {
type T = u32
def neg = u32.neg
}

instance Add u32 u32 {
type T = u32
def add = u32.add
}

instance Sub u32 u32 {
type T = u32
def sub = u32.sub
}

instance Mul u32 u32 {
type T = u32
def mul = u32.mul
}

instance Div u32 u32 {
type T = u32
def div = u32.div
}

# i64

instance Neg i64 {
type T = i64
def neg = i64.neg
}

instance Add i64 i64 {
type T = i64
def add = i64.add
}

instance Sub i64 i64 {
type T = i64
def sub = i64.sub
}

instance Mul i64 i64 {
type T = i64
def mul = i64.mul
}

instance Div i64 i64 {
type T = i64
def div = i64.div
}

# u64

instance Neg u64 {
type T = u64
def neg = u64.neg
}

instance Add u64 u64 {
type T = u64
def add = u64.add
}

instance Sub u64 u64 {
type T = u64
def sub = u64.sub
}

instance Mul u64 u64 {
type T = u64
def mul = u64.mul
}

instance Div u64 u64 {
type T = u64
def div = u64.div
}

# f32

instance Neg f32 {
type T = f32
def neg = f32.neg
}

instance Add f32 f32 {
type T = f32
def add = f32.add
}

instance Sub f32 f32 {
type T = f32
def sub = f32.sub
}

instance Mul f32 f32 {
type T = f32
def mul = f32.mul
}

instance Div f32 f32 {
type T = f32
def div = f32.div
}

# f64

instance Neg f64 {
type T = f64
def neg = f64.neg
Expand Down

0 comments on commit c7f6e58

Please sign in to comment.