plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


6b57711 — Peter John 2026-11-10T14:18:28+05:30
std: Json and base64 move to std/encoding; math, Random, Aabb, Vec2 and Affine to std/math
Files changed (85) hide show
  1. benchmarks/master_vs_simpler/branch/array.plum +1 -1
  2. benchmarks/master_vs_simpler/branch/cons.plum +1 -1
  3. benchmarks/master_vs_simpler/branch/fib.plum +1 -1
  4. benchmarks/master_vs_simpler/branch/loop.plum +1 -1
  5. benchmarks/master_vs_simpler/branch/map.plum +1 -1
  6. benchmarks/master_vs_simpler/branch/particles.plum +1 -1
  7. benchmarks/master_vs_simpler/branch/str.plum +1 -1
  8. benchmarks/master_vs_simpler/branch/trig.plum +1 -1
  9. benchmarks/math_bits/check.plum +1 -1
  10. benchmarks/scene_trees/scene_tree.plum +2 -2
  11. compiler/checker/tests/checker/modules_tests.rs +3 -3
  12. compiler/cli/tests/cli/old_forms_test.rs +3 -3
  13. compiler/core/src/modules.rs +1 -1
  14. compiler/core/src/native.rs +1 -1
  15. compiler/core/tests/core/layout_test.rs +1 -1
  16. compiler/core/tests/core/purity_test.rs +1 -1
  17. compiler/game/tests/fixtures/assets_fixture.plum +2 -2
  18. compiler/game/tests/fixtures/host_fixture.plum +2 -2
  19. compiler/game/tests/fixtures/main_game_fixture.plum +2 -2
  20. compiler/game/tests/fixtures/main_missing_fixture.plum +1 -1
  21. compiler/game/tests/fixtures/state_draw_keeps.plum +1 -1
  22. compiler/game/tests/fixtures/state_in_place.plum +1 -1
  23. compiler/game/tests/fixtures/state_main_alias.plum +1 -1
  24. compiler/game/tests/fixtures/state_reset.plum +1 -1
  25. compiler/game/tests/fixtures/target_fixture.plum +2 -2
  26. compiler/game/tests/host_test.rs +4 -4
  27. compiler/game/web-test/fixtures/interleave.plum +2 -2
  28. compiler/game/web-test/fixtures/main_game.plum +2 -2
  29. compiler/game/web-test/fixtures/rendertarget.plum +2 -2
  30. compiler/game/web-test/fixtures/stress.plum +2 -2
  31. compiler/game/web-test/fixtures/stress_scene_port.plum +2 -2
  32. compiler/game/web-test/fixtures/stress_state_view.plum +2 -2
  33. compiler/game/web-test/fixtures/stress_world.plum +3 -3
  34. compiler/game/web-test/fixtures/text_sizes.plum +2 -2
  35. compiler/lsp/src/main.rs +3 -3
  36. compiler/wasm-codegen/tests/wasm_codegen/e2e_types/type_param_static.rs +1 -1
  37. compiler/wasm-codegen/tests/wasm_codegen/native_test.rs +2 -2
  38. docs/game.md +2 -2
  39. docs/language.md +2 -2
  40. docs/std.md +2 -2
  41. examples/errors.plum +1 -1
  42. examples/games/clicks.plum +1 -1
  43. examples/games/kids/balloon_pop.plum +4 -4
  44. examples/games/orb_run.plum +4 -4
  45. examples/games/two_screens.plum +1 -1
  46. examples/json.plum +1 -1
  47. examples/numbers.plum +2 -2
  48. std/Float.plum +1 -1
  49. std/Int.plum +1 -1
  50. std/Slice.plum +1 -1
  51. std/Uuid.plum +1 -1
  52. std/collections/BPlusTree.plum +1 -1
  53. std/collections/BTree.plum +1 -1
  54. std/collections/Bvh.plum +2 -2
  55. std/collections/KdTree.plum +1 -1
  56. std/collections/Quadtree.plum +2 -2
  57. std/collections/SegmentTree.plum +1 -1
  58. std/collections/Treap.plum +2 -2
  59. std/decimal.plum +1 -1
  60. std/{Json.plum → encoding/Json.plum} +1 -1
  61. std/{base64.plum → encoding/base64.plum} +0 -0
  62. std/game/Game.plum +2 -2
  63. std/game/Replay.plum +1 -1
  64. std/game/gfx.plum +1 -1
  65. std/game/input.plum +2 -2
  66. std/game/scene/Actor.plum +3 -3
  67. std/game/scene/Ctx.plum +2 -2
  68. std/game/scene/Place.plum +3 -3
  69. std/game/scene/SceneTree.plum +3 -3
  70. std/game/ui.plum +2 -2
  71. std/http.plum +1 -1
  72. std/{Aabb.plum → math/Aabb.plum} +1 -1
  73. std/{game → math}/Affine.plum +2 -2
  74. std/{Random.plum → math/Random.plum} +0 -0
  75. std/{game → math}/Vec2.plum +1 -1
  76. std/{math.plum → math/math.plum} +0 -0
  77. std/os.plum +1 -1
  78. tests/core/float_bits.plum +1 -1
  79. tests/core/math_edges.plum +1 -1
  80. tests/core/native_math.plum +1 -1
  81. tests/fbip/slice_shapes.plum +1 -1
  82. tests/port/game/determinism.plum +3 -3
  83. tests/port/game/replay.plum +4 -4
  84. tests/std/json.plum +1 -1
  85. tests/wasm_codegen/e2e_types/static_on_builtin_method_and_json_cycle.plum +1 -1
benchmarks/master_vs_simpler/branch/array.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun sumFrom(xs: Slice[Int], i: Int, acc: Int) -> Int = if i >= xs.length() then acc else sumFrom(xs, i + 1, acc + xs.at(i))
13
13
 
benchmarks/master_vs_simpler/branch/cons.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun build(n: Int, acc: List[Int]) -> List[Int] = if n == 0 then acc else build(n - 1, Cons(head: n, tail: acc))
13
13
 
benchmarks/master_vs_simpler/branch/fib.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun fib(n: Int) -> Int = if n < 2 then n else fib(n - 1) + fib(n - 2)
13
13
 
benchmarks/master_vs_simpler/branch/loop.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun go(i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else go(i + 1, n, {acc + i * i % 7} % 1000000007)
13
13
 
benchmarks/master_vs_simpler/branch/map.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun look(m: Map[Int, Int], i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else look(m, i + 1, n, acc + m.get(i * 7919 % 1000003).unwrapOr(0) % 13)
13
13
 
benchmarks/master_vs_simpler/branch/particles.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  struct P(x: Float, y: Float, vx: Float, vy: Float) =
13
13
  fun moved(self) -> P =
benchmarks/master_vs_simpler/branch/str.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun go(i: Int, n: Int, acc: Int) -> Int = if i >= n then acc else go(i + 1, n, acc + "item-{i}-{i % 97}".length())
13
13
 
benchmarks/master_vs_simpler/branch/trig.plum CHANGED
@@ -7,7 +7,7 @@ import std/Io
7
7
  import std/collections/List
8
8
  import std/Slice
9
9
  import std/collections/Map
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  fun go(i: Int, n: Int, s: Float) -> Float =
13
13
  x := Float(i) * 0.001
benchmarks/math_bits/check.plum CHANGED
@@ -24,7 +24,7 @@ import std/Io
24
24
  import std/collections/List
25
25
  import std/Slice
26
26
  import std/collections/Map
27
- import std/math
27
+ import std/math/math
28
28
 
29
29
  # --- the old loop versions ---
30
30
 
benchmarks/scene_trees/scene_tree.plum CHANGED
@@ -8,8 +8,8 @@ import std/Option
8
8
  import std/Result
9
9
  import std/collections/List
10
10
  import std/Slice
11
- import std/game/Vec2
11
+ import std/math/Vec2
12
- import std/game/Affine
12
+ import std/math/Affine
13
13
  import std/game/Color
14
14
  import std/collections/RoseTree
15
15
  import std/game/scene/Place
compiler/checker/tests/checker/modules_tests.rs CHANGED
@@ -157,10 +157,10 @@ fn a_module_name_is_the_lowercased_last_path_segment() {
157
157
 
158
158
  #[test]
159
159
  fn the_old_namespace_form_is_an_error() {
160
- let e = run("oldns", "import std/Float\nimport std/math\n\nfun f() -> Float =\n Math.sqrt(2.0)\n").unwrap_err();
160
+ let e = run("oldns", "import std/Float\nimport std/math/math\n\nfun f() -> Float =\n Math.sqrt(2.0)\n").unwrap_err();
161
161
  assert!(e.contains("'Math' is not a type: modules are lowercase, write math.<name>"), "{e}");
162
- run("newns", "import std/Float\nimport std/math\n\nfun f() -> Float =\n math.sqrt(2.0)\n").unwrap();
162
+ run("newns", "import std/Float\nimport std/math/math\n\nfun f() -> Float =\n math.sqrt(2.0)\n").unwrap();
163
- let e = run("barens", "import std/Float\nimport std/math\n\nfun f() -> Float =\n sqrt(2.0)\n").unwrap_err();
163
+ let e = run("barens", "import std/Float\nimport std/math/math\n\nfun f() -> Float =\n sqrt(2.0)\n").unwrap_err();
164
164
  assert!(e.contains("'sqrt' is defined in module math: write math.sqrt"), "{e}");
165
165
  }
166
166
 
compiler/cli/tests/cli/old_forms_test.rs CHANGED
@@ -26,16 +26,16 @@ fn compileOutcome(name: &str, src: &str) -> (bool, String) {
26
26
 
27
27
  #[test]
28
28
  fn theOldNamespaceFormIsAnError() {
29
- let (ok, text) = compileOutcome("math", "import std/Float\nimport std/math\n\nfun main() -> Float =\n Math.sqrt(2.0)\n");
29
+ let (ok, text) = compileOutcome("math", "import std/Float\nimport std/math/math\n\nfun main() -> Float =\n Math.sqrt(2.0)\n");
30
30
  assert!(!ok, "{text}");
31
31
  assert!(text.contains("'Math' is not a type: modules are lowercase, write math.<name>"), "{text}");
32
- let (ok, text) = compileOutcome("modern", "import std/Float\nimport std/math\n\nfun main() -> Float =\n math.sqrt(2.0)\n");
32
+ let (ok, text) = compileOutcome("modern", "import std/Float\nimport std/math/math\n\nfun main() -> Float =\n math.sqrt(2.0)\n");
33
33
  assert!(ok, "{text}");
34
34
  }
35
35
 
36
36
  #[test]
37
37
  fn aBareModuleFunctionIsAnError() {
38
- let (ok, text) = compileOutcome("bare", "import std/Float\nimport std/math\n\nfun main() -> Float =\n sqrt(2.0)\n");
38
+ let (ok, text) = compileOutcome("bare", "import std/Float\nimport std/math/math\n\nfun main() -> Float =\n sqrt(2.0)\n");
39
39
  assert!(!ok, "{text}");
40
40
  assert!(text.contains("'sqrt' is defined in module math: write math.sqrt"), "{text}");
41
41
  }
compiler/core/src/modules.rs CHANGED
@@ -1,4 +1,4 @@
1
- //! Modules. `import a/b` makes `b` (lowercased: `import std/math` is `math`) a name for that
1
+ //! Modules. `import a/b` makes `b` (lowercased: `import std/math/math` is `math`) a name for that
2
2
  //! file's top-level functions and constants: `b.f()`, `b.Const`. Types and enum variants stay
3
3
  //! unqualified.
4
4
  //!
compiler/core/src/native.rs CHANGED
@@ -30,7 +30,7 @@ pub enum NativeOp {
30
30
 
31
31
  /// `(file, receiver type, fn name, op)`: `None` receiver is a module-level fn.
32
32
  const TABLE: &[(&str, Option<&str>, &str, NativeOp)] = &[
33
- ("std/math.plum", None, "sqrt", NativeOp::F64Sqrt),
33
+ ("std/math/math.plum", None, "sqrt", NativeOp::F64Sqrt),
34
34
  ("std/Float.plum", Some("Float"), "sqrt", NativeOp::F64Sqrt),
35
35
  ("std/Float.plum", Some("Float"), "abs", NativeOp::F64Abs),
36
36
  ("std/Float.plum", Some("Float"), "floor", NativeOp::F64Floor),
compiler/core/tests/core/layout_test.rs CHANGED
@@ -88,7 +88,7 @@ fn std_and_examples_layouts() {
88
88
  let l = structLayout(e, &all);
89
89
  assert_eq!(l, plum_core::layout::itemLayout(e, &s.items), "{} in {}", e.name, f.display());
90
90
  if l == Layout::Flat { flat += 1 } else { boxed += 1 }
91
- if f.ends_with("std/game/Vec2.plum") || f.ends_with("std/collections/Set.plum") {
91
+ if f.ends_with("std/math/Vec2.plum") || f.ends_with("std/collections/Set.plum") {
92
92
  known.push((e.name.clone(), l));
93
93
  }
94
94
  }
compiler/core/tests/core/purity_test.rs CHANGED
@@ -162,7 +162,7 @@ fn a_call_of_an_fn_typed_field_is_not_a_method_of_that_name() {
162
162
  /// compiler fills with one instruction: they are pure, and so are their callers.
163
163
  #[test]
164
164
  fn std_native_ops_are_pure() {
165
- let src = "import std/Int\nimport std/Float\nimport std/math\n\n\
165
+ let src = "import std/Int\nimport std/Float\nimport std/math/math\n\n\
166
166
  fun len(x: Float, y: Float) -> Float = math.sqrt(x * x + y * y)\n\n\
167
167
  fun cell(x: Float) -> Int = Int(x.floor()) + Int(x.abs().ceil())\n\n\
168
168
  fun ones(n: Int) -> Int = n.popCount() + n.leadingZeros()\n\n\
compiler/game/tests/fixtures/assets_fixture.plum CHANGED
@@ -4,12 +4,12 @@ import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
6
  import std/os
7
- import std/game/Vec2
7
+ import std/math/Vec2
8
8
  import std/game/Color
9
9
  import std/game/gfx
10
10
  import std/Io
11
11
  import std/game/input
12
- import std/game/Affine
12
+ import std/math/Affine
13
13
  import std/game/Store
14
14
  import std/game/Game
15
15
  import std/collections/RoseTree
compiler/game/tests/fixtures/host_fixture.plum CHANGED
@@ -4,12 +4,12 @@ import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
6
  import std/os
7
- import std/game/Vec2
7
+ import std/math/Vec2
8
8
  import std/game/Color
9
9
  import std/game/gfx
10
10
  import std/Io
11
11
  import std/game/input
12
- import std/game/Affine
12
+ import std/math/Affine
13
13
  import std/game/Store
14
14
  import std/game/Game
15
15
  import std/collections/RoseTree
compiler/game/tests/fixtures/main_game_fixture.plum CHANGED
@@ -5,11 +5,11 @@ import std/Float
5
5
  import std/Str
6
6
  import std/Bool
7
7
  import std/Slice
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
9
  import std/game/Color
10
10
  import std/game/gfx
11
11
  import std/game/input
12
- import std/game/Affine
12
+ import std/math/Affine
13
13
  import std/game/Store
14
14
  import std/game/Game
15
15
  import std/collections/RoseTree
compiler/game/tests/fixtures/main_missing_fixture.plum CHANGED
@@ -7,7 +7,7 @@ import std/game/Color
7
7
  import std/game/gfx
8
8
  import std/Io
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
compiler/game/tests/fixtures/state_draw_keeps.plum CHANGED
@@ -7,7 +7,7 @@ import std/game/Color
7
7
  import std/game/gfx
8
8
  import std/Io
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
compiler/game/tests/fixtures/state_in_place.plum CHANGED
@@ -7,7 +7,7 @@ import std/game/Color
7
7
  import std/game/gfx
8
8
  import std/Io
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
compiler/game/tests/fixtures/state_main_alias.plum CHANGED
@@ -7,7 +7,7 @@ import std/game/Color
7
7
  import std/game/gfx
8
8
  import std/Io
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
compiler/game/tests/fixtures/state_reset.plum CHANGED
@@ -7,7 +7,7 @@ import std/game/Color
7
7
  import std/game/gfx
8
8
  import std/Io
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
compiler/game/tests/fixtures/target_fixture.plum CHANGED
@@ -3,12 +3,12 @@ module target_fixture
3
3
  import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
- import std/game/Vec2
6
+ import std/math/Vec2
7
7
  import std/game/Color
8
8
  import std/game/gfx
9
9
  import std/Io
10
10
  import std/game/input
11
- import std/game/Affine
11
+ import std/math/Affine
12
12
  import std/game/Store
13
13
  import std/game/Game
14
14
  import std/collections/RoseTree
compiler/game/tests/host_test.rs CHANGED
@@ -151,7 +151,7 @@ fn unknownImportTraps() {
151
151
  let path = dir.join("m.plum");
152
152
  std::fs::write(
153
153
  &path,
154
- "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/game/Vec2\nimport std/game/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(n: Int) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n x := io.rawExists(\"a\")\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(n: 0)), Quiet(n: 0))\n",
154
+ "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/math/Vec2\nimport std/math/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(n: Int) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n x := io.rawExists(\"a\")\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(n: 0)), Quiet(n: 0))\n",
155
155
  )
156
156
  .unwrap();
157
157
  let wasm = compile(&path);
@@ -366,7 +366,7 @@ fn randomSeedProvidedByHost() {
366
366
  let path = dir.join("m.plum");
367
367
  std::fs::write(
368
368
  &path,
369
- "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/game/Vec2\nimport std/game/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(seed: Int) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"seed {self.seed}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(seed: io.randomSeed())), Quiet(n: 0))\n",
369
+ "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/math/Vec2\nimport std/math/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(seed: Int) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"seed {self.seed}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(seed: io.randomSeed())), Quiet(n: 0))\n",
370
370
  )
371
371
  .unwrap();
372
372
  let wasm = compile(&path);
@@ -390,7 +390,7 @@ fn seedGame(name: &str) -> Vec<u8> {
390
390
  let path = dir.join("m.plum");
391
391
  std::fs::write(
392
392
  &path,
393
- "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/game/Vec2\nimport std/game/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(seed: Int, ticks: Int, keys: Int, x: Float, w: Float) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun step(self, ctx: Ctx[Int], dt: Float) -> State =\n State(..self, ticks: self.ticks + 1, keys: self.keys + ctx.input.held.keys.length(), x: ctx.input.pos.x, w: ctx.view.x)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"seed {self.seed} ticks {self.ticks} keys {self.keys} x {self.x} w {self.w}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(seed: io.randomSeed(), ticks: 0, keys: 0, x: 0.0, w: 0.0)), Quiet(n: 0))\n",
393
+ "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/math/Vec2\nimport std/math/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Quiet(n: Int) is Reducer[Int] =\n fun update(self, msg: Int) -> Quiet = self\nstruct PageScreen(id: Int) is Screen[Quiet, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(seed: Int, ticks: Int, keys: Int, x: Float, w: Float) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun step(self, ctx: Ctx[Int], dt: Float) -> State =\n State(..self, ticks: self.ticks + 1, keys: self.keys + ctx.input.held.keys.length(), x: ctx.input.pos.x, w: ctx.view.x)\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"seed {self.seed} ticks {self.ticks} keys {self.keys} x {self.x} w {self.w}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Quiet, Int] =\n Game.start(screenOf(State(seed: io.randomSeed(), ticks: 0, keys: 0, x: 0.0, w: 0.0)), Quiet(n: 0))\n",
394
394
  )
395
395
  .unwrap();
396
396
  let wasm = compile(&path);
@@ -465,7 +465,7 @@ fn everySeedOfARecordedRunReplays() {
465
465
  let path = dir.join("m.plum");
466
466
  std::fs::write(
467
467
  &path,
468
- "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/game/Vec2\nimport std/game/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Seeds(mut c: Int)\nstruct Mixed(seeds: Seeds) is Reducer[Int] =\n fun update(self, msg: Int) -> Mixed = self\n fun handle(self, io: Io, msg: Int) =\n self.seeds.c = self.seeds.c ^ io.randomSeed()\nstruct PageScreen(id: Int) is Screen[Mixed, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(a: Int, b: Int, seeds: Seeds) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun step(self, ctx: Ctx[Int], dt: Float) -> State =\n ctx.send(1)\n self\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"{self.a} {self.b} {self.seeds.c}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Mixed, Int] =\n a := io.randomSeed()\n seeds := Seeds(c: 0)\n Game.start(screenOf(State(a: a, b: io.randomSeed(), seeds: seeds)), Mixed(seeds: seeds))\n",
468
+ "import std/Int\nimport std/Float\nimport std/Str\nimport std/Io\nimport std/Slice\nimport std/math/Vec2\nimport std/math/Affine\nimport std/game/Color\nimport std/game/gfx\nimport std/game/input\nimport std/game/Store\nimport std/game/Game\nimport std/game/scene/Place\nimport std/game/scene/Actor\nimport std/game/scene/Ctx\nimport std/game/scene/SceneTree\nimport std/collections/RoseTree\nstruct Seeds(mut c: Int)\nstruct Mixed(seeds: Seeds) is Reducer[Int] =\n fun update(self, msg: Int) -> Mixed = self\n fun handle(self, io: Io, msg: Int) =\n self.seeds.c = self.seeds.c ^ io.randomSeed()\nstruct PageScreen(id: Int) is Screen[Mixed, Int] =\n fun key(self) -> Int = self.id\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun draw(self, io: Io, shown: SceneTree[Int]) = shown.paint(io)\nfun screenOf(top: Actor[Int]) -> SceneTree[Int] =\n kid: RoseTree[Actor[Int]] := RoseTree.leaf(top)\n page: RoseTree[Actor[Int]] := RoseTree.of(PageScreen(id: -2), [kid])\n SceneTree.ofScreens([page])\nstruct State(a: Int, b: Int, seeds: Seeds) is Actor[Int] =\n fun key(self) -> Int = 1\n fun place(self) -> Place = place.at(0.0, 0.0)\n fun step(self, ctx: Ctx[Int], dt: Float) -> State =\n ctx.send(1)\n self\n fun paint(self, io: Io, m: Affine, alpha: Float) =\n gfx.drawText(io, \"{self.a} {self.b} {self.seeds.c}\", 0.0, 0.0, 8.0, Color.White)\n\nfun main(io: Io) -> Game[Mixed, Int] =\n a := io.randomSeed()\n seeds := Seeds(c: 0)\n Game.start(screenOf(State(a: a, b: io.randomSeed(), seeds: seeds)), Mixed(seeds: seeds))\n",
469
469
  )
470
470
  .unwrap();
471
471
  let wasm = compile(&path);
compiler/game/web-test/fixtures/interleave.plum CHANGED
@@ -6,12 +6,12 @@ import std/Str
6
6
  import std/Int
7
7
  import std/Float
8
8
  import std/Array
9
- import std/game/Vec2
9
+ import std/math/Vec2
10
10
  import std/game/Color
11
11
  import std/game/gfx
12
12
  import std/Io
13
13
  import std/game/input
14
- import std/game/Affine
14
+ import std/math/Affine
15
15
  import std/game/Store
16
16
  import std/game/Game
17
17
  import std/collections/RoseTree
compiler/game/web-test/fixtures/main_game.plum CHANGED
@@ -4,8 +4,8 @@ import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
6
  import std/Io
7
- import std/game/Vec2
7
+ import std/math/Vec2
8
- import std/game/Affine
8
+ import std/math/Affine
9
9
  import std/game/Color
10
10
  import std/game/gfx
11
11
  import std/game/input
compiler/game/web-test/fixtures/rendertarget.plum CHANGED
@@ -14,12 +14,12 @@ module rendertarget
14
14
  import std/Str
15
15
  import std/Int
16
16
  import std/Float
17
- import std/game/Vec2
17
+ import std/math/Vec2
18
18
  import std/game/Color
19
19
  import std/game/gfx
20
20
  import std/Io
21
21
  import std/game/input
22
- import std/game/Affine
22
+ import std/math/Affine
23
23
  import std/game/Store
24
24
  import std/game/Game
25
25
  import std/collections/RoseTree
compiler/game/web-test/fixtures/stress.plum CHANGED
@@ -6,12 +6,12 @@ module stress
6
6
  import std/Str
7
7
  import std/Int
8
8
  import std/Float
9
- import std/game/Vec2
9
+ import std/math/Vec2
10
10
  import std/game/Color
11
11
  import std/game/gfx
12
12
  import std/Io
13
13
  import std/game/input
14
- import std/game/Affine
14
+ import std/math/Affine
15
15
  import std/game/Store
16
16
  import std/game/Game
17
17
  import std/collections/RoseTree
compiler/game/web-test/fixtures/stress_scene_port.plum CHANGED
@@ -12,8 +12,8 @@ import std/Str
12
12
  import std/Int
13
13
  import std/Float
14
14
  import std/collections/List
15
- import std/game/Vec2
15
+ import std/math/Vec2
16
- import std/game/Affine
16
+ import std/math/Affine
17
17
  import std/game/Color
18
18
  import std/game/gfx
19
19
  import std/game/input
compiler/game/web-test/fixtures/stress_state_view.plum CHANGED
@@ -17,8 +17,8 @@ import std/Float
17
17
  import std/Slice
18
18
  import std/Option
19
19
  import std/collections/List
20
- import std/game/Vec2
20
+ import std/math/Vec2
21
- import std/game/Affine
21
+ import std/math/Affine
22
22
  import std/game/Color
23
23
  import std/game/gfx
24
24
  import std/game/Anim
compiler/game/web-test/fixtures/stress_world.plum CHANGED
@@ -10,11 +10,11 @@ import std/Str
10
10
  import std/Int
11
11
  import std/Float
12
12
  import std/Bool
13
- import std/math
13
+ import std/math/math
14
14
  import std/collections/List
15
15
  import std/Slice
16
- import std/game/Vec2
16
+ import std/math/Vec2
17
- import std/game/Affine
17
+ import std/math/Affine
18
18
  import std/game/Color
19
19
  import std/game/gfx
20
20
  import std/collections/RoseTree
compiler/game/web-test/fixtures/text_sizes.plum CHANGED
@@ -5,12 +5,12 @@ module text_sizes
5
5
  import std/Str
6
6
  import std/Int
7
7
  import std/Float
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
9
  import std/game/Color
10
10
  import std/game/gfx
11
11
  import std/Io
12
12
  import std/game/input
13
- import std/game/Affine
13
+ import std/math/Affine
14
14
  import std/game/Store
15
15
  import std/game/Game
16
16
  import std/collections/RoseTree
compiler/lsp/src/main.rs CHANGED
@@ -719,7 +719,7 @@ mod tests {
719
719
  let index = completion::stdLibIndex(&repoRoot());
720
720
  for (name, path) in [
721
721
  ("os", "std/os"),
722
- ("base64", "std/base64"),
722
+ ("base64", "std/encoding/base64"),
723
723
  ("testing", "std/testing"),
724
724
  ("http", "std/http"),
725
725
  ("gfx", "std/game/gfx"),
@@ -728,7 +728,7 @@ mod tests {
728
728
  ("SceneTree", "std/game/scene/SceneTree"),
729
729
  ("Io", "std/Io"),
730
730
  ("Key", "std/game/input"),
731
- ("Vec2", "std/game/Vec2"),
731
+ ("Vec2", "std/math/Vec2"),
732
732
  ] {
733
733
  assert_eq!(index.get(name).map(String::as_str), Some(path), "{name}");
734
734
  }
@@ -741,7 +741,7 @@ mod tests {
741
741
  let dir = std::env::temp_dir().join(format!("plum-lsp-ns-{}", std::process::id()));
742
742
  std::fs::create_dir_all(&dir).unwrap();
743
743
  let path = dir.join("t.plum");
744
- let text = "module t\nimport std/Int\nimport std/Str\nimport std/os\nimport std/base64\n\nfun main() =\n x := os.zzzzzz\n";
744
+ let text = "module t\nimport std/Int\nimport std/Str\nimport std/os\nimport std/encoding/base64\n\nfun main() =\n x := os.zzzzzz\n";
745
745
  std::fs::write(&path, text).unwrap();
746
746
  let labels = |recv: &str| -> Vec<String> {
747
747
  memberCompletionFor(&path, &repoRoot(), text, 7, recv)
compiler/wasm-codegen/tests/wasm_codegen/e2e_types/type_param_static.rs CHANGED
@@ -53,5 +53,5 @@ fun main() -> Int =
53
53
  Err(e) => e.into_iter().map(|x| x.message).collect(),
54
54
  },
55
55
  };
56
- assert!(!errs.is_empty(), "toJson must not exist without std/Json");
56
+ assert!(!errs.is_empty(), "toJson must not exist without std/encoding/Json");
57
57
  }
compiler/wasm-codegen/tests/wasm_codegen/native_test.rs CHANGED
@@ -77,7 +77,7 @@ fn runInt(wasm: &[u8]) -> i64 {
77
77
 
78
78
  const SRC: &str = "import std/Int
79
79
  import std/Float
80
- import std/math
80
+ import std/math/math
81
81
 
82
82
  fun calc(x: Float, y: Float) -> Float =
83
83
  math.sqrt(x) + y.sqrt() + {-x}.abs() + x.floor() + y.ceil() + {-y}.trunc()
@@ -121,7 +121,7 @@ fn native_ops_compile_in_line() {
121
121
 
122
122
  const BITS_SRC: &str = "import std/Int
123
123
  import std/Float
124
- import std/math
124
+ import std/math/math
125
125
 
126
126
  fun bitsOf(x: Float) -> Int =
127
127
  x.toBits()
docs/game.md CHANGED
@@ -26,7 +26,7 @@ import std/Float
26
26
  import std/Str
27
27
  import std/Option
28
28
  import std/Io
29
- import std/game/Affine
29
+ import std/math/Affine
30
30
  import std/game/Color
31
31
  import std/game/gfx
32
32
  import std/game/input
@@ -184,7 +184,7 @@ The host adds up the time between frames and runs one tick (`Game.update`) for e
184
184
 
185
185
  The tick's `Input` (`ctx.input`) is read from the host once per frame, before the ticks. A frame's key and pointer events go to its first tick, or to the next frame's if it ran none, so a press counts once. Later ticks of the frame see what is held, with no events. Actors and rules have no `io`, so they can't read input any other way.
186
186
 
187
- Keep randomness in the state `S`: a `Random` ([`std/Random.plum`](../std/Random.plum)) seeded once in `main` from `io.randomSeed()`, drawn from only in `update` (`r := self.rng.nextFloat()`, then keep `r.rng` in the next state). Then the same seed and the same inputs give the same game, tick for tick, and a test can play one: `game.step(io, input, 1.0 / 60.0, view)` from one seed and one list of inputs gives the same game each time. Orb Run's `same_seed_same_game` test does exactly this.
187
+ Keep randomness in the state `S`: a `Random` ([`std/math/Random.plum`](../std/Random.plum)) seeded once in `main` from `io.randomSeed()`, drawn from only in `update` (`r := self.rng.nextFloat()`, then keep `r.rng` in the next state). Then the same seed and the same inputs give the same game, tick for tick, and a test can play one: `game.step(io, input, 1.0 / 60.0, view)` from one seed and one list of inputs gives the same game each time. Orb Run's `same_seed_same_game` test does exactly this.
188
188
 
189
189
  The maths is the same everywhere too. std's maths (`math.sin`, `math.sqrt`, ...) is Plum code built from IEEE 754 double operations, which wasm defines exactly, so every browser and the native host get the same bits; a test in [`tests/port/game/replay.plum`](../tests/port/game/replay.plum) pins some of them. The one host value a tick reads is the screen size (`ctx.view`), and a replay records it (see below).
190
190
 
docs/language.md CHANGED
@@ -505,7 +505,7 @@ fun doubled() -> Int =
505
505
  MaxRetries * 2
506
506
  ```
507
507
 
508
- A file that writes `import std/math` calls `math.sqrt(2.0)`; its own functions and constants need no prefix. `primitive` is only for std.
508
+ A file that writes `import std/math/math` calls `math.sqrt(2.0)`; its own functions and constants need no prefix. `primitive` is only for std.
509
509
 
510
510
  ## Operators on your own types
511
511
 
@@ -709,7 +709,7 @@ fun main() -> Int =
709
709
 
710
710
  This means two modules can each have a `clamp` without clashing, while two modules that define the same type name are an error. A module's own functions and constants need no prefix inside it, and a local with the same name as a module hides the module.
711
711
 
712
- Module-level constants can be any pure expression, and they may refer to each other in any order. The same goes for std: `import std/math` gives `math.sqrt(2.0)`, and `import std/game/gfx` gives `gfx.rect(io, ..)`.
712
+ Module-level constants can be any pure expression, and they may refer to each other in any order. The same goes for std: `import std/math/math` gives `math.sqrt(2.0)`, and `import std/game/gfx` gives `gfx.rect(io, ..)`.
713
713
 
714
714
  A module-level `extern fun` binds to a function the host provides. It takes `io: Io` first, because it reaches outside the program:
715
715
 
docs/std.md CHANGED
@@ -25,7 +25,7 @@ The [game engine](game.md) has its own page.
25
25
  import std/Int
26
26
  import std/Float
27
27
  import std/Str
28
- import std/math
28
+ import std/math/math
29
29
 
30
30
  fun main() =
31
31
  a := 5.max(3)
@@ -168,7 +168,7 @@ See [the language guide](language.md#option-and-result).
168
168
  import std/Int
169
169
  import std/Str
170
170
  import std/collections/Map
171
- import std/Json
171
+ import std/encoding/Json
172
172
 
173
173
  struct Point(x: Int, y: Int) =
174
174
  fun toJson(self) -> Json =
examples/errors.plum CHANGED
@@ -12,7 +12,7 @@ import std/Result
12
12
 
13
13
  # `Result[T, E]` is `Ok(value)` or `Err(error)`. A failure is an ordinary value of
14
14
  # an ordinary type `E`: usually one enum per module whose cases name what can go
15
- # wrong (`NumError` in std/Int, `IoError` in std/Os, `JsonError` in std/Json).
15
+ # wrong (`NumError` in std/Int, `IoError` in std/Os, `JsonError` in std/encoding/Json).
16
16
  # Nothing is implicit: a success is written `Ok(n)`, a failure `Err(Case)`.
17
17
  #
18
18
  # `r?` unwraps the `Ok` value, or returns the `Err` from the enclosing function
examples/games/clicks.plum CHANGED
@@ -6,7 +6,7 @@ import std/Float
6
6
  import std/Str
7
7
  import std/Option
8
8
  import std/Io
9
- import std/game/Affine
9
+ import std/math/Affine
10
10
  import std/game/Color
11
11
  import std/game/gfx
12
12
  import std/game/input
examples/games/kids/balloon_pop.plum CHANGED
@@ -29,10 +29,10 @@ import std/Bool
29
29
  import std/Slice
30
30
  import std/Option
31
31
  import std/collections/List
32
- import std/math
32
+ import std/math/math
33
- import std/Random
33
+ import std/math/Random
34
- import std/game/Vec2
34
+ import std/math/Vec2
35
- import std/game/Affine
35
+ import std/math/Affine
36
36
  import std/game/Color
37
37
  import std/game/gfx
38
38
  import std/game/audio
examples/games/orb_run.plum CHANGED
@@ -52,10 +52,10 @@ import std/Bool
52
52
  import std/Slice
53
53
  import std/Option
54
54
  import std/collections/List
55
- import std/math
55
+ import std/math/math
56
- import std/Random
56
+ import std/math/Random
57
- import std/game/Vec2
57
+ import std/math/Vec2
58
- import std/game/Affine
58
+ import std/math/Affine
59
59
  import std/game/Color
60
60
  import std/game/gfx
61
61
  import std/game/audio
examples/games/two_screens.plum CHANGED
@@ -7,7 +7,7 @@ import std/Float
7
7
  import std/Str
8
8
  import std/Option
9
9
  import std/Io
10
- import std/game/Vec2
10
+ import std/math/Vec2
11
11
  import std/game/Color
12
12
  import std/game/gfx
13
13
  import std/game/input
examples/json.plum CHANGED
@@ -4,7 +4,7 @@
4
4
  import std/Int
5
5
  import std/Str
6
6
  import std/Slice
7
- import std/Json
7
+ import std/encoding/Json
8
8
  import std/Option
9
9
  import std/Result
10
10
 
examples/numbers.plum CHANGED
@@ -2,7 +2,7 @@
2
2
  import std/Str
3
3
  import std/Int
4
4
  import std/Float
5
- import std/math
5
+ import std/math/math
6
6
  import std/Slice
7
7
  import std/collections/List
8
8
  import std/Option
@@ -128,7 +128,7 @@ test "pow computes integer powers exactly for both Int and Float self"
128
128
 
129
129
  test "log2/log10 agree between Int and the equivalent Float"
130
130
  # `log`/`log2`/`log10` are built on the Taylor-series `ln` approximation
131
- # (see `std/math.plum`'s `ln`), not exact libm — compare within a
131
+ # (see `std/math/math.plum`'s `ln`), not exact libm — compare within a
132
132
  # small epsilon rather than requiring bit-exact equality.
133
133
  a := 8.log2()
134
134
  b := 8.0.log2()
std/Float.plum CHANGED
@@ -2,7 +2,7 @@ module std
2
2
 
3
3
  import std/Str
4
4
  import std/Int
5
- import std/math
5
+ import std/math/math
6
6
  import std/decimal
7
7
  import std/Option
8
8
  import std/Result
std/Int.plum CHANGED
@@ -2,7 +2,7 @@ module std
2
2
 
3
3
  import std/Str
4
4
  import std/Float
5
- import std/math
5
+ import std/math/math
6
6
  import std/Pair
7
7
  import std/Option
8
8
  import std/Result
std/Slice.plum CHANGED
@@ -5,7 +5,7 @@ import std/Buffer
5
5
  import std/Int
6
6
  import std/Float
7
7
  import std/Str
8
- import std/Random
8
+ import std/math/Random
9
9
  import std/Option
10
10
 
11
11
  # A growable list over a backing `Array[T]`: element `i` is `data[start + i]`,
std/Uuid.plum CHANGED
@@ -3,7 +3,7 @@ module std
3
3
  import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
- import std/Random
6
+ import std/math/Random
7
7
  import std/Option
8
8
  import std/Result
9
9
 
std/collections/BPlusTree.plum CHANGED
@@ -6,7 +6,7 @@ import std/Pair
6
6
  import std/Str
7
7
  import std/Float
8
8
  import std/Array
9
- import std/game/Vec2
9
+ import std/math/Vec2
10
10
  import std/collections/List
11
11
  import std/Slice
12
12
  import std/collections/text
std/collections/BTree.plum CHANGED
@@ -7,7 +7,7 @@ import std/Str
7
7
  import std/Bool
8
8
  import std/Float
9
9
  import std/Array
10
- import std/game/Vec2
10
+ import std/math/Vec2
11
11
  import std/collections/List
12
12
  import std/collections/text
13
13
 
std/collections/Bvh.plum CHANGED
@@ -5,8 +5,8 @@ import std/Float
5
5
  import std/Option
6
6
  import std/Str
7
7
  import std/Pair
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
- import std/Aabb
9
+ import std/math/Aabb
10
10
  import std/collections/List
11
11
  import std/Slice
12
12
  import std/collections/Set
std/collections/KdTree.plum CHANGED
@@ -5,7 +5,7 @@ import std/Float
5
5
  import std/Str
6
6
  import std/Option
7
7
  import std/Pair
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
9
  import std/Slice
10
10
  import std/collections/List
11
11
  import std/collections/text
std/collections/Quadtree.plum CHANGED
@@ -5,8 +5,8 @@ import std/Float
5
5
  import std/Str
6
6
  import std/Option
7
7
  import std/Pair
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
- import std/Aabb
9
+ import std/math/Aabb
10
10
  import std/Slice
11
11
  import std/collections/List
12
12
  import std/collections/text
std/collections/SegmentTree.plum CHANGED
@@ -4,7 +4,7 @@ import std/Int
4
4
  import std/Str
5
5
  import std/Float
6
6
  import std/Option
7
- import std/game/Vec2
7
+ import std/math/Vec2
8
8
  import std/collections/List
9
9
  import std/Slice
10
10
 
std/collections/Treap.plum CHANGED
@@ -4,7 +4,7 @@ import std/Int
4
4
  import std/Str
5
5
  import std/Option
6
6
  import std/Pair
7
- import std/Random
7
+ import std/math/Random
8
8
  import std/collections/List
9
9
  import std/Slice
10
10
  import std/collections/Map
@@ -19,7 +19,7 @@ import std/collections/text
19
19
  # Keys are ordered by `before(a, b)` ("a belongs before b", strictly), stored in the
20
20
  # wrapper: `Treap.by(|a, b| a > b)`, `Treap.ints()`, `Treap.seeded(before, seed)`.
21
21
  # Priorities are deterministic, as in the twin: each new key draws one from a seeded
22
- # `std/Random` (xorshift64*, an immutable value) held in the wrapper, and `insert`
22
+ # `std/math/Random` (xorshift64*, an immutable value) held in the wrapper, and `insert`
23
23
  # returns a treap carrying the next generator, so the same inserts from the same seed
24
24
  # give the same tree. Replacing an existing key draws nothing.
25
25
  # Built on `split(k)` and `join(other)`; `union`, `intersection` and `difference` are
std/decimal.plum CHANGED
@@ -7,7 +7,7 @@ import std/Buffer
7
7
  import std/Byte
8
8
  import std/Slice
9
9
  import std/Option
10
- import std/math
10
+ import std/math/math
11
11
 
12
12
  # Exact conversion between decimal text and Float, on small unsigned big integers.
13
13
  #
std/{Json.plum → encoding/Json.plum} RENAMED
@@ -14,7 +14,7 @@ import std/decimal
14
14
  # Placement rule for built-in `toJson` / `fromJson`: they live HERE, in this
15
15
  # file, as extension blocks at the bottom (`primitive Int =`, `primitive Slice[T] =`),
16
16
  # holding only `fun`s. The loader merges them into the type's methods, so they
17
- # exist only in programs that import std/Json, and Int/Str/Slice/Map never
17
+ # exist only in programs that import std/encoding/Json, and Int/Str/Slice/Map never
18
18
  # import Json (no cycle, no Pair/Bool drag-in). Std-only; a duplicate method
19
19
  # name is a collision error. `Json.encode` / `Json.decode` stay duck-typed and
20
20
  # call `x.toJson()` / `T.fromJson(j)` per instantiation.
std/{base64.plum → encoding/base64.plum} RENAMED
File without changes
std/game/Game.plum CHANGED
@@ -9,8 +9,8 @@ import std/collections/List
9
9
  import std/Slice
10
10
  import std/Io
11
11
  import std/ref
12
- import std/game/Vec2
12
+ import std/math/Vec2
13
- import std/game/Affine
13
+ import std/math/Affine
14
14
  import std/game/Color
15
15
  import std/game/gfx
16
16
  import std/game/input
std/game/Replay.plum CHANGED
@@ -8,7 +8,7 @@ import std/Option
8
8
  import std/Result
9
9
  import std/Slice
10
10
  import std/Buffer
11
- import std/game/Vec2
11
+ import std/math/Vec2
12
12
  import std/Io
13
13
  import std/game/input
14
14
 
std/game/gfx.plum CHANGED
@@ -3,7 +3,7 @@ module std
3
3
  import std/Int
4
4
  import std/Float
5
5
  import std/Str
6
- import std/game/Vec2
6
+ import std/math/Vec2
7
7
  import std/game/Color
8
8
  import std/Io
9
9
 
std/game/input.plum CHANGED
@@ -3,8 +3,8 @@ module std
3
3
  import std/Int
4
4
  import std/Float
5
5
  import std/Slice
6
- import std/game/Vec2
6
+ import std/math/Vec2
7
- import std/game/Affine
7
+ import std/math/Affine
8
8
  import std/Io
9
9
  import std/Option
10
10
  import std/collections/List
std/game/scene/Actor.plum CHANGED
@@ -4,10 +4,10 @@ import std/Int
4
4
  import std/Float
5
5
  import std/Bool
6
6
  import std/Str
7
- import std/math
7
+ import std/math/math
8
8
  import std/Io
9
- import std/game/Vec2
9
+ import std/math/Vec2
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Color
12
12
  import std/game/gfx
13
13
  import std/game/input
std/game/scene/Ctx.plum CHANGED
@@ -5,8 +5,8 @@ import std/Float
5
5
  import std/Str
6
6
  import std/collections/List
7
7
  import std/Slice
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
- import std/game/Affine
9
+ import std/math/Affine
10
10
  import std/game/input
11
11
  import std/collections/RoseTree
12
12
  import std/game/scene/Actor
std/game/scene/Place.plum CHANGED
@@ -1,9 +1,9 @@
1
1
  module std
2
2
 
3
3
  import std/Float
4
- import std/math
4
+ import std/math/math
5
- import std/game/Vec2
5
+ import std/math/Vec2
6
- import std/game/Affine
6
+ import std/math/Affine
7
7
 
8
8
  # Where an actor is in its parent: its position, its scale and rotation, and the origin
9
9
  # (in its own coordinates) it turns and scales about. Every actor has one (`Actor.place`);
std/game/scene/SceneTree.plum CHANGED
@@ -11,11 +11,11 @@ import std/Array
11
11
  import std/collections/Map
12
12
  import std/collections/Set
13
13
  import std/Pair
14
- import std/math
14
+ import std/math/math
15
15
  import std/Io
16
16
  import std/ref
17
- import std/game/Vec2
17
+ import std/math/Vec2
18
- import std/game/Affine
18
+ import std/math/Affine
19
19
  import std/game/Color
20
20
  import std/game/gfx
21
21
  import std/game/input
std/game/ui.plum CHANGED
@@ -7,8 +7,8 @@ import std/Slice
7
7
  import std/collections/List
8
8
  import std/Option
9
9
  import std/Io
10
- import std/game/Vec2
10
+ import std/math/Vec2
11
- import std/game/Affine
11
+ import std/math/Affine
12
12
  import std/game/Color
13
13
  import std/game/input
14
14
  import std/collections/RoseTree
std/http.plum CHANGED
@@ -1,7 +1,7 @@
1
1
  module std
2
2
 
3
3
  import std/Buffer
4
- import std/Json
4
+ import std/encoding/Json
5
5
  import std/Slice
6
6
  import std/collections/Map
7
7
  import std/Str
std/{Aabb.plum → math/Aabb.plum} RENAMED
@@ -1,7 +1,7 @@
1
1
  module std
2
2
 
3
3
  import std/Float
4
- import std/game/Vec2
4
+ import std/math/Vec2
5
5
 
6
6
  # An axis-aligned box from `min` to `max` (corners included), for bounds and
7
7
  # collision. `Aabb.of(x, y, w, h)` builds one from a top-left corner and a size.
std/{game → math}/Affine.plum RENAMED
@@ -1,8 +1,8 @@
1
1
  module std
2
2
 
3
3
  import std/Float
4
- import std/math
4
+ import std/math/math
5
- import std/game/Vec2
5
+ import std/math/Vec2
6
6
  import std/Option
7
7
 
8
8
  # A 2D affine transform: x' = a*x + c*y + e, y' = b*x + d*y + f.
std/{Random.plum → math/Random.plum} RENAMED
File without changes
std/{game → math}/Vec2.plum RENAMED
@@ -1,7 +1,7 @@
1
1
  module std
2
2
 
3
3
  import std/Float
4
- import std/math
4
+ import std/math/math
5
5
 
6
6
  # A 2D point or vector. Operators work through the methods below:
7
7
  # `a + b` is `a.add(b)`, `a - b` is `a.sub(b)`, `a * s` is `a.mul(s)`,
std/{math.plum → math/math.plum} RENAMED
File without changes
std/os.plum CHANGED
@@ -3,7 +3,7 @@ module std
3
3
  import std/Slice
4
4
  import std/Str
5
5
  import std/Uuid
6
- import std/Random
6
+ import std/math/Random
7
7
  import std/Int
8
8
  import std/Float
9
9
  import std/Io
tests/core/float_bits.plum CHANGED
@@ -5,7 +5,7 @@
5
5
  # against mpmath.
6
6
  import std/Float
7
7
  import std/Int
8
- import std/math
8
+ import std/math/math
9
9
 
10
10
  Inf = 1.0f / 0.0f
11
11
  NaN = 0.0f / 0.0f
tests/core/math_edges.plum CHANGED
@@ -10,7 +10,7 @@ import std/Int
10
10
  import std/Str
11
11
  import std/collections/Map
12
12
  import std/Option
13
- import std/math
13
+ import std/math/math
14
14
 
15
15
  Inf = 1.0f / 0.0f
16
16
  NaN = 0.0f / 0.0f
tests/core/native_math.plum CHANGED
@@ -4,7 +4,7 @@
4
4
  # infinities, subnormals, halves and values past 2^53 and 2^63.
5
5
  import std/Float
6
6
  import std/Int
7
- import std/math
7
+ import std/math/math
8
8
  import std/Slice
9
9
 
10
10
  Inf = 1.0f / 0.0f
tests/fbip/slice_shapes.plum CHANGED
@@ -5,7 +5,7 @@ import std/Time
5
5
  import std/Io
6
6
  import std/Slice
7
7
  import std/collections/List
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
9
 
10
10
  # Twelve shapes on `Slice`, which mutates in place today (`push`, `putAt`), and the per-frame update
11
11
  # on a persistent `List` (`List.map`).
tests/port/game/determinism.plum CHANGED
@@ -4,10 +4,10 @@ import std/Bool
4
4
  import std/Str
5
5
  import std/Slice
6
6
  import std/Io
7
- import std/Random
7
+ import std/math/Random
8
- import std/game/Vec2
8
+ import std/math/Vec2
9
9
  import std/game/input
10
- import std/game/Affine
10
+ import std/math/Affine
11
11
  import std/game/Store
12
12
  import std/game/Game
13
13
  import std/collections/RoseTree
tests/port/game/replay.plum CHANGED
@@ -6,12 +6,12 @@ import std/Slice
6
6
  import std/Option
7
7
  import std/Result
8
8
  import std/Io
9
- import std/Random
9
+ import std/math/Random
10
- import std/math
10
+ import std/math/math
11
- import std/game/Vec2
11
+ import std/math/Vec2
12
12
  import std/game/input
13
13
  import std/game/Replay
14
- import std/game/Affine
14
+ import std/math/Affine
15
15
  import std/game/Store
16
16
  import std/game/Game
17
17
  import std/collections/RoseTree
tests/std/json.plum CHANGED
@@ -5,7 +5,7 @@ import std/Option
5
5
  import std/Result
6
6
  import std/Slice
7
7
  import std/collections/Map
8
- import std/Json
8
+ import std/encoding/Json
9
9
 
10
10
  fun num(s: Str) -> Float = Json.fromStr(s)!.asFloat()!
11
11
 
tests/wasm_codegen/e2e_types/static_on_builtin_method_and_json_cycle.plum CHANGED
@@ -1,6 +1,6 @@
1
1
  import std/Int
2
2
  import std/Str
3
- import std/Json
3
+ import std/encoding/Json
4
4
  import std/Result
5
5
 
6
6
  fun parseIt[T](s: Str) -> Result[T, NumError] =