M tests/programs/test_module3.gt +12 -6
@@ 1,5 1,8 @@
-- Compile:
-- status: success
+--
+-- Run:
+-- stdout: 3
-- Fine let's try something simpler.
@@ 14,7 17,7 @@ end
-- To ponder: What if we did attach names to types, or had
-- specialization? The latter evokes the Instance Problem, the former
-- I suppose is a way around it.
-const IntEq = Eq {
+const IntEq Eq = Eq {
.eq = fn(lhs I32, rhs I32) Bool =
true
end,
@@ 24,7 27,7 @@ type Ord(@Self) = struct
cmp: fn(@Self, @Self) I32,
end
-const IntOrd = Ord {
+const IntOrd Ord = Ord {
.cmp = fn(lhs I32, rhs I32) I32 =
0
end,
@@ 35,7 38,7 @@ type From(@Self, @In) = struct
from: fn(@In) @Self
end
-const BoolFromInt = From {
+const BoolFromInt From(Bool, I32) = From {
.from = fn(i I32) Bool = false end
}
@@ 52,7 55,7 @@ type Len(@Self) = struct
len: fn(@Self) I32,
end
-const ListLen = Len {
+const ListLen Len(List(@T)) = Len {
.len = fn(self List(@T)) I32 = 0 end
}
@@ 66,7 69,7 @@ fn list_len(l List(@T)) I32 =
module_len(ListLen, l)
end
-const ListIdx = Idx {
+const ListIdx Idx(List(@T)) = Idx {
.idx = fn(self List(@T), i I32) @T = self$.dummy_data end
}
@@ 77,7 80,10 @@ fn idx(l List(@T)) @T =
end
-- Can we make another instance for a more specialized type?
-const IntListIdx = Idx {
+const IntListIdx Idx(List(I32)) = Idx {
.idx = fn(self List(I32), i I32) I32 = self$.dummy_data end
}
+fn main() {} =
+ __println(3)
+end
M tests/programs/test_module6.gt +7 -0
@@ 1,5 1,8 @@
-- Compile:
-- status: success
+--
+-- Run:
+-- stdout: 3
-- TODO: BUGGO: This test occasionally fails to pass, *hopefully*
-- because of HashMap ordering shenanigans. Investigate.
@@ 33,3 36,7 @@ fn make_cell_map(k @K, v @V) Map(Cell(@K
}
module
end
+
+fn main() {} =
+ __println(3)
+end
M tests/programs/test_module7.gt +4 -2
@@ 1,5 1,7 @@
-- Compile:
-- status: success
+-- Run:
+-- stdout: 12
/- Another monad-ish attempt, this also gets called map
@@ 34,11 36,11 @@ fn f(i Bool) I32 =
12
end
-fn main() I32 =
+fn main() {} =
let test_cell = Cell {
.val = true
}
let thing = make_cell_functor(f)
let test_result Cell(I32) = thing$.map(test_cell)
- 0
+ __println(test_result$.val)
end