Update test fixtures to not use Nat indices

This commit is contained in:
Richard Feldman 2024-01-22 23:46:33 -05:00
parent 70a1def63b
commit 7e51dfd526
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
8 changed files with 62 additions and 62 deletions

View file

@ -1,6 +1,6 @@
app "quicksort" provides [swap, partition, partitionHelp, quicksort] to "./platform"
quicksort : List (Num a), Nat, Nat -> List (Num a)
quicksort : List (Num a), U64, U64 -> List (Num a)
quicksort = \list, low, high ->
when partition low high list is
Pair partitionIndex partitioned ->
@ -9,7 +9,7 @@ quicksort = \list, low, high ->
|> quicksort (partitionIndex + 1) high
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -21,7 +21,7 @@ swap = \i, j, list ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -33,7 +33,7 @@ partition = \low, high, initialList ->
Pair (low - 1) initialList
partitionHelp : Nat, Nat, List (Num a), Nat, (Num a) -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, (Num a) -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is

View file

@ -1,6 +1,6 @@
app "quicksort" provides [quicksort] to "./platform"
quicksortHelp : List (Num a), Nat, Nat -> List (Num a)
quicksortHelp : List (Num a), U64, U64 -> List (Num a)
quicksortHelp = \list, low, high ->
if low < high then
when partition low high list is
@ -12,7 +12,7 @@ quicksortHelp = \list, low, high ->
list
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -23,7 +23,7 @@ swap = \i, j, list ->
_ ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -35,7 +35,7 @@ partition = \low, high, initialList ->
Pair (low - 1) initialList
partitionHelp : Nat, Nat, List (Num a), Nat, (Num a) -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, (Num a) -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is

View file

@ -2,7 +2,7 @@ interface Quicksort
exposes [swap, partition, quicksort]
imports []
quicksort : List (Num a), Nat, Nat -> List (Num a)
quicksort : List (Num a), U64, U64 -> List (Num a)
quicksort = \list, low, high ->
when partition low high list is
Pair partitionIndex partitioned ->
@ -11,7 +11,7 @@ quicksort = \list, low, high ->
|> quicksort (partitionIndex + 1) high
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -23,7 +23,7 @@ swap = \i, j, list ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -35,7 +35,7 @@ partition = \low, high, initialList ->
Pair (low - 1) initialList
partitionHelp : Nat, Nat, List (Num a), Nat, (Num a) -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, (Num a) -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is

View file

@ -465,10 +465,10 @@ fn iface_quicksort() {
expect_types(
loaded_module,
hashmap! {
"swap" => "Nat, Nat, List a -> List a",
"partition" => "Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]",
"partitionHelp" => "Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]",
"quicksort" => "List (Num a), Nat, Nat -> List (Num a)",
"swap" => "U64, U64, List a -> List a",
"partition" => "U64, U64, List (Num a) -> [Pair U64 (List (Num a))]",
"partitionHelp" => "U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]",
"quicksort" => "List (Num a), U64, U64 -> List (Num a)",
},
);
}
@ -481,10 +481,10 @@ fn quicksort_one_def() {
expect_types(
loaded_module,
hashmap! {
"swap" => "Nat, Nat, List a -> List a",
"partition" => "Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]",
"partitionHelp" => "Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]",
"quicksortHelp" => "List (Num a), Nat, Nat -> List (Num a)",
"swap" => "U64, U64, List a -> List a",
"partition" => "U64, U64, List (Num a) -> [Pair U64 (List (Num a))]",
"partitionHelp" => "U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]",
"quicksortHelp" => "List (Num a), U64, U64 -> List (Num a)",
"quicksort" => "List (Num a) -> List (Num a)",
},
);
@ -498,10 +498,10 @@ fn app_quicksort() {
expect_types(
loaded_module,
hashmap! {
"swap" => "Nat, Nat, List a -> List a",
"partition" => "Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]",
"partitionHelp" => "Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]",
"quicksort" => "List (Num a), Nat, Nat -> List (Num a)",
"swap" => "U64, U64, List a -> List a",
"partition" => "U64, U64, List (Num a) -> [Pair U64 (List (Num a))]",
"partitionHelp" => "U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]",
"quicksort" => "List (Num a), U64, U64 -> List (Num a)",
},
);
}

View file

@ -165,7 +165,7 @@ mod solve_expr {
Str.fromUtf8
"
),
"List U8 -> Result Str [BadUtf8 Utf8ByteProblem Nat]",
"List U8 -> Result Str [BadUtf8 Utf8ByteProblem U64]",
);
}
@ -3016,7 +3016,7 @@ mod solve_expr {
infer_eq_without_problem(
indoc!(
r"
partition : Nat, Nat, List (Int a) -> [Pair Nat (List (Int a))]
partition : U64, U64, List (Int a) -> [Pair U64 (List (Int a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok _ ->
@ -3028,7 +3028,7 @@ mod solve_expr {
partition
"
),
"Nat, Nat, List (Int a) -> [Pair Nat (List (Int a))]",
"U64, U64, List (Int a) -> [Pair U64 (List (Int a))]",
);
}
@ -3037,7 +3037,7 @@ mod solve_expr {
infer_eq_without_problem(
indoc!(
r"
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -3048,7 +3048,7 @@ mod solve_expr {
_ ->
list
partition : Nat, Nat, List (Int a) -> [Pair Nat (List (Int a))]
partition : U64, U64, List (Int a) -> [Pair U64 (List (Int a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -3076,7 +3076,7 @@ mod solve_expr {
partition
"
),
"Nat, Nat, List (Int a) -> [Pair Nat (List (Int a))]",
"U64, U64, List (Int a) -> [Pair U64 (List (Int a))]",
);
}
@ -3116,7 +3116,7 @@ mod solve_expr {
List.get
"
),
"List a, Nat -> Result a [OutOfBounds]",
"List a, U64 -> Result a [OutOfBounds]",
);
}
@ -3772,7 +3772,7 @@ mod solve_expr {
fn list_walk_with_index_until() {
infer_eq_without_problem(
indoc!(r"List.walkWithIndexUntil"),
"List elem, state, (state, elem, Nat -> [Break state, Continue state]) -> state",
"List elem, state, (state, elem, U64 -> [Break state, Continue state]) -> state",
);
}
@ -3784,7 +3784,7 @@ mod solve_expr {
List.dropAt
"
),
"List elem, Nat -> List elem",
"List elem, U64 -> List elem",
);
}
@ -3820,7 +3820,7 @@ mod solve_expr {
List.takeFirst
"
),
"List elem, Nat -> List elem",
"List elem, U64 -> List elem",
);
}
@ -3832,7 +3832,7 @@ mod solve_expr {
List.takeLast
"
),
"List elem, Nat -> List elem",
"List elem, U64 -> List elem",
);
}
@ -3844,7 +3844,7 @@ mod solve_expr {
List.sublist
"
),
"List elem, { len : Nat, start : Nat } -> List elem",
"List elem, { len : U64, start : U64 } -> List elem",
);
}
@ -3852,7 +3852,7 @@ mod solve_expr {
fn list_split() {
infer_eq_without_problem(
indoc!("List.split"),
"List elem, Nat -> { before : List elem, others : List elem }",
"List elem, U64 -> { before : List elem, others : List elem }",
);
}
@ -3864,7 +3864,7 @@ mod solve_expr {
List.dropLast
"
),
"List elem, Nat -> List elem",
"List elem, U64 -> List elem",
);
}
@ -4400,7 +4400,7 @@ mod solve_expr {
r#"
app "test" provides [partitionHelp] to "./platform"
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -4411,7 +4411,7 @@ mod solve_expr {
_ ->
[]
partitionHelp : Nat, Nat, List (Num a), Nat, (Num a) -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, (Num a) -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is
@ -4427,7 +4427,7 @@ mod solve_expr {
Pair i list
"#
),
"Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]",
"U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]",
);
}

View file

@ -30,7 +30,7 @@ const ROC_LIST_MAP: &str = indoc::indoc!(
r#"
app "bench" provides [main] to "./platform"
main : List I64 -> Nat
main : List I64 -> U64
main = \list ->
list
|> List.map (\x -> x + 2)
@ -42,7 +42,7 @@ const ROC_LIST_MAP_WITH_INDEX: &str = indoc::indoc!(
r#"
app "bench" provides [main] to "./platform"
main : List I64 -> Nat
main : List I64 -> U64
main = \list ->
list
|> List.mapWithIndex (\x, _ -> x + 2)

View file

@ -40,7 +40,7 @@ const PURE_ROC_QUICKSORT: &str = indoc::indoc!(
quicksortHelp originalList 0 (n - 1)
quicksortHelp : List (Num a), Nat, Nat -> List (Num a)
quicksortHelp : List (Num a), U64, U64 -> List (Num a)
quicksortHelp = \list, low, high ->
if low < high then
when partition low high list is
@ -51,7 +51,7 @@ const PURE_ROC_QUICKSORT: &str = indoc::indoc!(
else
list
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -62,7 +62,7 @@ const PURE_ROC_QUICKSORT: &str = indoc::indoc!(
Err _ ->
Pair low initialList
partitionHelp : Nat, Nat, List (Num c), Nat, Num c -> [Pair Nat (List (Num c))]
partitionHelp : U64, U64, List (Num c), U64, Num c -> [Pair U64 (List (Num c))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is

View file

@ -1014,7 +1014,7 @@ fn list_walk_implements_position() {
r"
Option a : [Some a, None]
find : List a, a -> Option Nat where a implements Eq
find : List a, a -> Option U64 where a implements Eq
find = \list, needle ->
findHelp list needle
|> .v
@ -2412,7 +2412,7 @@ fn gen_swap() {
app "quicksort" provides [main] to "./platform"
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -2447,7 +2447,7 @@ fn gen_quicksort() {
quicksortHelp list 0 (n - 1)
quicksortHelp : List (Num a), Nat, Nat -> List (Num a)
quicksortHelp : List (Num a), U64, U64 -> List (Num a)
quicksortHelp = \list, low, high ->
if low < high then
when partition low high list is
@ -2459,7 +2459,7 @@ fn gen_quicksort() {
list
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -2470,7 +2470,7 @@ fn gen_quicksort() {
_ ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -2482,7 +2482,7 @@ fn gen_quicksort() {
Pair low initialList
partitionHelp : Nat, Nat, List (Num a), Nat, (Num a) -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, (Num a) -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is
@ -2520,7 +2520,7 @@ fn quicksort() {
quicksortHelp list 0 (List.len list - 1)
quicksortHelp : List (Num a), Nat, Nat -> List (Num a)
quicksortHelp : List (Num a), U64, U64 -> List (Num a)
quicksortHelp = \list, low, high ->
if low < high then
when partition low high list is
@ -2532,7 +2532,7 @@ fn quicksort() {
list
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -2543,7 +2543,7 @@ fn quicksort() {
_ ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -2555,7 +2555,7 @@ fn quicksort() {
Pair low initialList
partitionHelp : Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
# if j < high then
if Bool.false then
@ -2596,7 +2596,7 @@ fn quicksort_singleton() {
quicksortHelp list 0 (List.len list - 1)
quicksortHelp : List (Num a), Nat, Nat -> List (Num a)
quicksortHelp : List (Num a), U64, U64 -> List (Num a)
quicksortHelp = \list, low, high ->
if low < high then
when partition low high list is
@ -2608,7 +2608,7 @@ fn quicksort_singleton() {
list
swap : Nat, Nat, List a -> List a
swap : U64, U64, List a -> List a
swap = \i, j, list ->
when Pair (List.get list i) (List.get list j) is
Pair (Ok atI) (Ok atJ) ->
@ -2619,7 +2619,7 @@ fn quicksort_singleton() {
_ ->
[]
partition : Nat, Nat, List (Num a) -> [Pair Nat (List (Num a))]
partition : U64, U64, List (Num a) -> [Pair U64 (List (Num a))]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
@ -2631,7 +2631,7 @@ fn quicksort_singleton() {
Pair low initialList
partitionHelp : Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]
partitionHelp : U64, U64, List (Num a), U64, Num a -> [Pair U64 (List (Num a))]
partitionHelp = \i, j, list, high, pivot ->
if j < high then
when List.get list j is
@ -3512,7 +3512,7 @@ fn monomorphized_lists() {
r"
l = \{} -> [1, 2, 3]
f : List U8, List U16 -> Nat
f : List U8, List U16 -> U64
f = \_, _ -> 18
f (l {}) (l {})
@ -3753,7 +3753,7 @@ fn list_walk_backwards_implements_position() {
r"
Option a : [Some a, None]
find : List a, a -> Option Nat where a implements Eq
find : List a, a -> Option U64 where a implements Eq
find = \list, needle ->
findHelp list needle
|> .v