Add list resugaring on readback

This commit is contained in:
Nicolas Abril 2024-05-15 22:07:58 +02:00
parent 2ae73384e2
commit f724bbf541
15 changed files with 15 additions and 13 deletions

2
Cargo.lock generated
View File

@ -83,7 +83,7 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "bend-lang"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"TSPL 0.0.12",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "bend-lang"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
[lib]

View File

@ -16,5 +16,6 @@ pub mod float_combinators;
pub mod linearize_matches;
pub mod linearize_vars;
pub mod resolve_refs;
pub mod resugar_list;
pub mod resugar_string;
pub mod unique_names;

View File

@ -216,6 +216,7 @@ pub fn readback_hvm_net(net: &Net, book: &Book, labels: &Labels, linear: bool) -
let mut term = net_to_term(&net, book, labels, linear, &mut diags);
term.expand_generated(book);
term.resugar_strings();
term.resugar_lists();
(term, diags)
}

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: examples/queue.bend
---
λa λ* (a 1 λb λ* (b 2 λc λ* (c 3 List/Nil)))
[1, 2, 3]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/escape_sequences.bend
---
λa (Join (List/Cons "\n" (List/Cons "\r" (List/Cons "\t" (List/Cons "\0" (List/Cons "\"" (List/Cons "'" (List/Cons "\u{afe}" (List/Cons "\\" List/Nil)))))))))
λa (Join ["\n", "\r", "\t", "\0", "\"", "'", "\u{afe}", "\\"])

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/fold_with_state.bend
---
λa λ* (a 1 λb λ* (b 2 λc λ* (c 3 List/Nil)))
[1, 2, 3]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/list_resugar.bend
---
λa λ* (a 42 λb λ* (b λc λ* (c λd d List/Nil) List/Nil))
[42, [λd d]]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/list_take.bend
---
λa λ* (a 3 λb λ* (b 2 List/Nil))
[3, 2]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/match_num_num_to_char.bend
---
{{λa λ* (a 0 λb λ* (b 1 λc λ* (c 2 λd λ* (d 3 λe λ* (e 4 λf λ* (f 5 λg λ* (g 6 λh λ* (h 7 λi λ* (i 8 λj λ* (j 9 λk λ* (k 10 List/Nil))))))))))) λl λ* (l 0 λm λ* (m 1 λn λ* (n 2 λo λ* (o 3 λp λ* (p 4 λq λ* (q 5 λr λ* (r 6 λs λ* (s 7 λt λ* (t 8 λu λ* (u 9 λv λ* (v 16777215 List/Nil)))))))))))} λw λ* (w 48 λx λ* (x 49 λy λ* (y 50 λz λ* (z 51 λab λ* (ab 52 λbb λ* (bb 53 λcb λ* (cb 54 λdb λ* (db 55 λeb λ* (eb 56 λfb λ* (fb 57 λgb λ* (gb 0 List/Nil)))))))))))}
{{[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16777215]} [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0]}

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/match_num_succ_complex.bend
---
λa λ* (a λb λ* (b 5 λc λ* (c 5 λd λ* (d 0 λe λ* (e 12 λf λ* (f 0 λg λ* (g 6 List/Nil)))))) λh λ* (h λi λ* (i 5 λj λ* (j 5 λk λ* (k 0 λl λ* (l 12 λm λ* (m 0 λn λ* (n 6 List/Nil)))))) List/Nil))
[[5, 5, 0, 12, 0, 6], [5, 5, 0, 12, 0, 6]]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/match_str.bend
---
λa λ* (a 2 λb λ* (b 2 λc λ* (c 1 λd λ* (d 0 λe λ* (e 0 λf λ* (f 0 List/Nil))))))
[2, 2, 1, 0, 0, 0]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/nested_list_and_string.bend
---
λa λb λ* (b a λc λ* (c λ* 2 λd λ* (d λe λ* (e λf λ* (f 7 λg λ* (g "1234" λl λ* (l 9 List/Nil))) λm λ* (m a (String/Cons * "42"))) List/Nil)))
λa [a, λ* 2, λe λ* (e [7, "1234", 9] λm λ* (m a (String/Cons * "42")))]

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/readback_list_other_ctr.bend
---
λa λ* (a λb λ* (b 97 λc (c 98 "c")) λe λ* (e 1 λf (f 2 λg λ* (g 3 λh λ* (h 4 List/Nil)))))
λa λ* (a λb λ* (b 97 λc (c 98 "c")) λe λ* (e 1 λf (f 2 [3, 4])))

View File

@ -2,4 +2,4 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/tup_list_strings.bend
---
{λa λ* (a {"foo" 0} λe λ* (e {"foo" 0} λi λ* (i {"foo" 1} List/Nil))) 4}
{[{"foo" 0}, {"foo" 0}, {"foo" 1}] 4}