From 94fab781479509d594888d017933e6eff08fbfb6 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Sat, 4 Jun 2022 15:50:07 -0700 Subject: [PATCH] chore(stdlib)!: Remove `sum` function from the List module --- .../__snapshots__/stdlib.24cb9bbf.0.snapshot | 8 ++-- .../__snapshots__/stdlib.5fe88631.0.snapshot | 8 ++-- .../__snapshots__/stdlib.648f406e.0.snapshot | 8 ++-- .../__snapshots__/stdlib.6bf88430.0.snapshot | 8 ++-- .../__snapshots__/stdlib.6de47be2.0.snapshot | 8 ++-- .../__snapshots__/stdlib.8300ad7c.0.snapshot | 42 +++++++++---------- .../__snapshots__/stdlib.91a94037.0.snapshot | 8 ++-- .../__snapshots__/stdlib.a70e79ca.0.snapshot | 8 ++-- .../__snapshots__/stdlib.d28dee65.0.snapshot | 8 ++-- .../__snapshots__/stdlib.d4faa5bf.0.snapshot | 8 ++-- .../__snapshots__/stdlib.e306600a.0.snapshot | 8 ++-- .../__snapshots__/stdlib.e6349872.0.snapshot | 8 ++-- compiler/test/stdlib/list.test.gr | 5 --- stdlib/list.gr | 19 --------- stdlib/list.md | 32 -------------- 15 files changed, 65 insertions(+), 121 deletions(-) diff --git a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot index 7943910092..3126ac170c 100644 --- a/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.24cb9bbf.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_18 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -103,10 +103,10 @@ stdlib › stdlib_equal_18 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot index d181ead4fe..5d3677a322 100644 --- a/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.5fe88631.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_16 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -103,10 +103,10 @@ stdlib › stdlib_equal_16 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot index 60e8eade7c..aa551551c1 100644 --- a/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.648f406e.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_12 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -127,10 +127,10 @@ stdlib › stdlib_equal_12 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot index ebfac0947a..11a8df47ec 100644 --- a/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6bf88430.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_15 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -99,10 +99,10 @@ stdlib › stdlib_equal_15 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot index a1aeb13158..786eaa6462 100644 --- a/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.6de47be2.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_14 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -99,10 +99,10 @@ stdlib › stdlib_equal_14 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot index f10b8fb8dd..d11da00506 100644 --- a/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.8300ad7c.0.snapshot @@ -10,13 +10,13 @@ stdlib › stdlib_equal_3 (import \"_grainEnv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32)) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[]\" (global $[]_1253 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $[...]_1247 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[]\" (global $[]_1250 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$[...]\" (global $[...]_1244 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $[...]_1247 (param i32 i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"[...]\" (func $[...]_1244 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -44,15 +44,15 @@ stdlib › stdlib_equal_3 (local.set $6 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 7) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[]_1253) + (global.get $[]_1250) ) ) (call $decRef_0 @@ -69,10 +69,10 @@ stdlib › stdlib_equal_3 (local.set $7 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 5) (call $incRef_0 @@ -94,10 +94,10 @@ stdlib › stdlib_equal_3 (local.set $8 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 3) (call $incRef_0 @@ -119,15 +119,15 @@ stdlib › stdlib_equal_3 (local.set $9 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 7) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[]_1253) + (global.get $[]_1250) ) ) (call $decRef_0 @@ -144,10 +144,10 @@ stdlib › stdlib_equal_3 (local.set $10 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 5) (call $incRef_0 @@ -169,10 +169,10 @@ stdlib › stdlib_equal_3 (local.set $11 (tuple.extract 0 (tuple.make - (call $[...]_1247 + (call $[...]_1244 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $[...]_1247) + (global.get $[...]_1244) ) (i32.const 3) (call $incRef_0 @@ -190,10 +190,10 @@ stdlib › stdlib_equal_3 (block $do_backpatches.11 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot index 82cc3a0269..64841858f2 100644 --- a/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.91a94037.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_11 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -107,10 +107,10 @@ stdlib › stdlib_equal_11 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot index eabcf4005c..e55139c4b5 100644 --- a/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.a70e79ca.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_9 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -99,10 +99,10 @@ stdlib › stdlib_equal_9 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot index 9d123fd8e6..4b18d4925b 100644 --- a/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d28dee65.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_10 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -103,10 +103,10 @@ stdlib › stdlib_equal_10 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot index c9b7d54dab..59a7bb5c16 100644 --- a/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.d4faa5bf.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_13 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -95,10 +95,10 @@ stdlib › stdlib_equal_13 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot index 8d92a6422f..9e5ad4b7ad 100644 --- a/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e306600a.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_8 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -95,10 +95,10 @@ stdlib › stdlib_equal_8 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot index 247ee432cb..4b370435f9 100644 --- a/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot +++ b/compiler/test/__snapshots__/stdlib.e6349872.0.snapshot @@ -11,11 +11,11 @@ stdlib › stdlib_equal_17 (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$incRef\" (global $GRAIN$EXPORT$incRef_0 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$decRef\" (global $GRAIN$EXPORT$decRef_0 (mut i32))) - (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1245 (mut i32))) + (import \"GRAIN$MODULE$pervasives\" \"GRAIN$EXPORT$==\" (global $==_1242 (mut i32))) (import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"incRef\" (func $incRef_0 (param i32 i32) (result i32))) (import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32))) - (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1245 (param i32 i32 i32) (result i32))) + (import \"GRAIN$MODULE$pervasives\" \"==\" (func $==_1242 (param i32 i32 i32) (result i32))) (global $GRAIN$TABLE_SIZE i32 (i32.const 0)) (elem $elem (global.get $relocBase_0)) (export \"memory\" (memory $0)) @@ -103,10 +103,10 @@ stdlib › stdlib_equal_17 (block $do_backpatches.5 ) ) - (call $==_1245 + (call $==_1242 (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) - (global.get $==_1245) + (global.get $==_1242) ) (call $incRef_0 (global.get $GRAIN$EXPORT$incRef_0) diff --git a/compiler/test/stdlib/list.test.gr b/compiler/test/stdlib/list.test.gr index 6987965f03..74982e9d6f 100644 --- a/compiler/test/stdlib/list.test.gr +++ b/compiler/test/stdlib/list.test.gr @@ -3,11 +3,6 @@ import String from "string" let list = [1, 2, 3] -// List.sum - -assert sum(list) == 6 -assert sum([]) == 0 - // List.reverse assert reverse([]) == [] diff --git a/stdlib/list.gr b/stdlib/list.gr index a341231131..3d066716f7 100644 --- a/stdlib/list.gr +++ b/stdlib/list.gr @@ -58,25 +58,6 @@ export let length = list => { iter(0, list) } -/** - * Adds all numbers in the input list. - * - * @param list: The input list - * @returns The combined sum of all values - * - * @since v0.1.0 - * @history v0.2.0: Made the function tail-recursive - */ -export let sum = list => { - let rec iter = (n, list) => { - match (list) { - [] => n, - [first, ...rest] => iter(n + first, rest), - } - } - iter(0, list) -} - /** * Creates a new list with all elements in reverse order. * diff --git a/stdlib/list.md b/stdlib/list.md index a6b26731e7..2b231aeb0b 100644 --- a/stdlib/list.md +++ b/stdlib/list.md @@ -91,38 +91,6 @@ Returns: |----|-----------| |`Number`|The number of elements in the list| -### List.**sum** - -
-Added in 0.1.0 - - - - - - - -
versionchanges
0.2.0Made the function tail-recursive
-
- -```grain -sum : List -> Number -``` - -Adds all numbers in the input list. - -Parameters: - -|param|type|description| -|-----|----|-----------| -|`list`|`List`|The input list| - -Returns: - -|type|description| -|----|-----------| -|`Number`|The combined sum of all values| - ### List.**reverse**