mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Rename List.push to List.append
This commit is contained in:
parent
0b078783fd
commit
759f1289d6
11 changed files with 29 additions and 29 deletions
|
@ -510,9 +510,9 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
),
|
||||
);
|
||||
|
||||
// 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))),
|
||||
|
|
|
@ -669,13 +669,13 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
)
|
||||
});
|
||||
|
||||
// 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(
|
||||
|
|
|
@ -53,7 +53,7 @@ pub fn builtin_defs(var_store: &mut VarStore) -> MutMap<Symbol, Def> {
|
|||
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)),
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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]
|
||||
);
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -11,7 +11,7 @@ pub enum LowLevel {
|
|||
ListRepeat,
|
||||
ListReverse,
|
||||
ListConcat,
|
||||
ListPush,
|
||||
ListAppend,
|
||||
NumAdd,
|
||||
NumSub,
|
||||
NumMul,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
"#
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue