51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
|
// AlexScript test
|
||
|
|
||
|
def extern core::intrinsic::pow_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::mul_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::div_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::mod_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::plus_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::minus_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::equal_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::notEqual_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::lessThan_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::lessThanEq_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::greaterThan_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::greaterThanEq_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::and_u32 : U32 -> U32 -> U32;
|
||
|
def extern core::intrinsic::or_u32 : U32 -> U32 -> U32;
|
||
|
|
||
|
data extern U32;
|
||
|
|
||
|
class Group n {
|
||
|
def plus : n -> n -> n;
|
||
|
def zero : n;
|
||
|
def negate : n -> n;
|
||
|
}
|
||
|
|
||
|
class Group n => Ring n {
|
||
|
def mul : n -> n -> n;
|
||
|
def one : n;
|
||
|
}
|
||
|
|
||
|
instance Group U32 {
|
||
|
def plus = core::intrinsic::plus_u32;
|
||
|
def zero = 0;
|
||
|
def negate = core::intrinsic::negate_u32;
|
||
|
}
|
||
|
|
||
|
instance Ring U32 {
|
||
|
def mul = core::intrinsics::mul_u32;
|
||
|
def one = 1;
|
||
|
}
|
||
|
|
||
|
def extern print_u32 : U32 -> ();
|
||
|
|
||
|
// Impurity expliot to chain together actions.
|
||
|
def progn (l: ()) (r: ()) : () = ();
|
||
|
|
||
|
def main : () =
|
||
|
progn (print_u32 (2 + 2))
|
||
|
(progn (print_u32 (3 * 3))
|
||
|
(progn (print_u32 (4 ^ 4))));
|