diff --git a/compiler/builtins/src/std.rs b/compiler/builtins/src/std.rs index b6c930bee8..7dfc89444a 100644 --- a/compiler/builtins/src/std.rs +++ b/compiler/builtins/src/std.rs @@ -510,9 +510,9 @@ pub fn types() -> MutMap { ), ); - // push : List elem -> elem -> List elem + // append : List elem -> elem -> List elem add_type( - Symbol::LIST_PUSH, + Symbol::LIST_APPEND, SolvedType::Func( vec![list_type(flex(TVAR1)), flex(TVAR1)], Box::new(list_type(flex(TVAR1))), diff --git a/compiler/builtins/src/unique.rs b/compiler/builtins/src/unique.rs index e93cc3edea..11d444a5c9 100644 --- a/compiler/builtins/src/unique.rs +++ b/compiler/builtins/src/unique.rs @@ -669,13 +669,13 @@ pub fn types() -> MutMap { ) }); - // push : Attr * (List a) + // append : Attr * (List a) // , a // -> Attr * (List a) // // NOTE: we demand the new item to have the same uniqueness as the other list items. // It could be allowed to add unique items to shared lists, but that requires special code gen - add_type(Symbol::LIST_PUSH, { + add_type(Symbol::LIST_APPEND, { let_tvars! { a, star1, star2 }; unique_function( diff --git a/compiler/can/src/builtins.rs b/compiler/can/src/builtins.rs index bfb03c4142..5bdc26b9f1 100644 --- a/compiler/can/src/builtins.rs +++ b/compiler/can/src/builtins.rs @@ -53,7 +53,7 @@ pub fn builtin_defs(var_store: &mut VarStore) -> MutMap { Symbol::LIST_LEN => list_len, Symbol::LIST_GET => list_get, Symbol::LIST_SET => list_set, - Symbol::LIST_PUSH => list_push, + Symbol::LIST_APPEND => list_append, Symbol::LIST_FIRST => list_first, Symbol::LIST_IS_EMPTY => list_is_empty, Symbol::LIST_SINGLE => list_single, @@ -856,13 +856,13 @@ fn list_set(symbol: Symbol, var_store: &mut VarStore) -> Def { ) } -/// List.push : List elem, elem -> List elem -fn list_push(symbol: Symbol, var_store: &mut VarStore) -> Def { +/// List.append : List elem, elem -> List elem +fn list_append(symbol: Symbol, var_store: &mut VarStore) -> Def { let list_var = var_store.fresh(); let elem_var = var_store.fresh(); let body = RunLowLevel { - op: LowLevel::ListPush, + op: LowLevel::ListAppend, args: vec![ (list_var, Var(Symbol::ARG_1)), (elem_var, Var(Symbol::ARG_2)), diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 4f445544ee..34829d16a5 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1820,7 +1820,7 @@ fn run_low_level<'a, 'ctx, 'env>( } } ListConcat => list_concat(env, layout_ids, scope, parent, args), - ListPush => { + ListAppend => { // List.push List elem, elem -> List elem debug_assert_eq!(args.len(), 2); diff --git a/compiler/gen/tests/gen_list.rs b/compiler/gen/tests/gen_list.rs index 0a3cd176f8..356ff4671c 100644 --- a/compiler/gen/tests/gen_list.rs +++ b/compiler/gen/tests/gen_list.rs @@ -38,10 +38,10 @@ mod gen_list { } #[test] - fn list_push() { - assert_evals_to!("List.push [1] 2", &[1, 2], &'static [i64]); - assert_evals_to!("List.push [1, 1] 2", &[1, 1, 2], &'static [i64]); - assert_evals_to!("List.push [] 3", &[3], &'static [i64]); + fn list_append() { + assert_evals_to!("List.append [1] 2", &[1, 2], &'static [i64]); + assert_evals_to!("List.append [1, 1] 2", &[1, 1, 2], &'static [i64]); + assert_evals_to!("List.append [] 3", &[3], &'static [i64]); assert_evals_to!( indoc!( r#" @@ -49,19 +49,19 @@ mod gen_list { initThrees = [] - List.push (List.push initThrees 3) 3 + List.append (List.append initThrees 3) 3 "# ), &[3, 3], &'static [i64] ); assert_evals_to!( - "List.push [ True, False ] True", + "List.append [ True, False ] True", &[true, false, true], &'static [bool] ); assert_evals_to!( - "List.push [ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ] 23", + "List.append [ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ] 23", &[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], &'static [i64] ); diff --git a/compiler/load/tests/fixtures/build/app_with_deps/AStar.roc b/compiler/load/tests/fixtures/build/app_with_deps/AStar.roc index 0901f80fe9..30c45eacf3 100644 --- a/compiler/load/tests/fixtures/build/app_with_deps/AStar.roc +++ b/compiler/load/tests/fixtures/build/app_with_deps/AStar.roc @@ -54,7 +54,7 @@ reconstructPath = \cameFrom, goal -> [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal updateCost : position, position, Model position -> Model position updateCost = \current, neighbour, model -> diff --git a/compiler/load/tests/fixtures/build/interface_with_deps/AStar.roc b/compiler/load/tests/fixtures/build/interface_with_deps/AStar.roc index 0901f80fe9..30c45eacf3 100644 --- a/compiler/load/tests/fixtures/build/interface_with_deps/AStar.roc +++ b/compiler/load/tests/fixtures/build/interface_with_deps/AStar.roc @@ -54,7 +54,7 @@ reconstructPath = \cameFrom, goal -> [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal updateCost : position, position, Model position -> Model position updateCost = \current, neighbour, model -> diff --git a/compiler/module/src/low_level.rs b/compiler/module/src/low_level.rs index df6c7e98d1..618577d370 100644 --- a/compiler/module/src/low_level.rs +++ b/compiler/module/src/low_level.rs @@ -11,7 +11,7 @@ pub enum LowLevel { ListRepeat, ListReverse, ListConcat, - ListPush, + ListAppend, NumAdd, NumSub, NumMul, diff --git a/compiler/module/src/symbol.rs b/compiler/module/src/symbol.rs index 92833ac764..05e50c7183 100644 --- a/compiler/module/src/symbol.rs +++ b/compiler/module/src/symbol.rs @@ -648,7 +648,7 @@ define_builtins! { 2 LIST_IS_EMPTY: "isEmpty" 3 LIST_GET: "get" 4 LIST_SET: "set" - 5 LIST_PUSH: "push" + 5 LIST_APPEND: "append" 6 LIST_MAP: "map" 7 LIST_LEN: "len" 8 LIST_FOLDL: "foldl" diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index bd8d09f3ce..c2864e99ec 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -2362,7 +2362,7 @@ mod solve_expr { [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal reconstructPath "# @@ -2534,7 +2534,7 @@ mod solve_expr { x = [] when List.get input 0 is - Ok val -> List.push x val + Ok val -> List.append x val Err _ -> f input f "# diff --git a/compiler/solve/tests/solve_uniq_expr.rs b/compiler/solve/tests/solve_uniq_expr.rs index e5776d70b3..b5bbf75904 100644 --- a/compiler/solve/tests/solve_uniq_expr.rs +++ b/compiler/solve/tests/solve_uniq_expr.rs @@ -2275,9 +2275,9 @@ mod solve_uniq_expr { } #[test] - fn list_push() { + fn list_append() { infer_eq( - "List.push", + "List.append", "Attr * (Attr * (List a), a -> Attr * (List a))", ); } @@ -2303,7 +2303,7 @@ mod solve_uniq_expr { infer_eq( indoc!( r#" - singleton = \x -> List.push [] x + singleton = \x -> List.append [] x singleton "# @@ -2317,7 +2317,7 @@ mod solve_uniq_expr { infer_eq( indoc!( r#" - reverse = \list -> List.foldr list (\e, l -> List.push l e) [] + reverse = \list -> List.foldr list (\e, l -> List.append l e) [] reverse "# @@ -2742,7 +2742,7 @@ mod solve_uniq_expr { [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal reconstructPath "# @@ -2812,7 +2812,7 @@ mod solve_uniq_expr { [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal updateCost : position, position, Model position -> Model position updateCost = \current, neighbour, model -> @@ -2897,7 +2897,7 @@ mod solve_uniq_expr { [] Ok next -> - List.push (reconstructPath cameFrom next) goal + List.append (reconstructPath cameFrom next) goal updateCost : position, position, Model position -> Model position