Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sc-507] Update the name of floated combinators #233

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/term/transform/float_combinators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'d> TermInfo<'d> {
}

fn detach_term(&mut self, term: &mut Term) {
let comb_name = Name::new(format!("{}$S{}", self.def_name, self.counter));
let comb_name = Name::new(format!("{}$C{}", self.def_name, self.counter));
self.counter += 1;

let comb_var = Term::Ref { nam: comb_name.clone() };
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/cli__compile_all.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/compile_all.hvm
---
@Pair = (a (b {2 {2 a {2 b c}} c}))
@Pair.get = (a ({2 @Pair.get$S0 (a b)} b))
@Pair.get$S0 = {2 a {2 b ((a (b c)) c)}}
@Pair.get = (a ({2 @Pair.get$C0 (a b)} b))
@Pair.get$C0 = {2 a {2 b ((a (b c)) c)}}
@main = a
& @Pair.get ~ ((<+ b c> (b c)) (d a))
& @Pair ~ (#40 (#2 d))
4 changes: 2 additions & 2 deletions tests/snapshots/cli__desugar_float_combinators.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ input_file: tests/golden_tests/cli/desugar_float_combinators.hvm

(S) = λa λb let {b b_2} = b; λc (b (a b_2 c))

(get) = λa (a get$S0 0)
(get) = λa (a get$C0 0)

(main) = (get (S (S Z)))

(get$S0) = λb (+ b 1)
(get$C0) = λb (+ b 1)
12 changes: 6 additions & 6 deletions tests/snapshots/compile_file__match_num_all_patterns.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ In definition 'zero_var_succ':

@main = #0
@succ_var = (?<(#0 (a a)) b> b)
@succ_var_zero = (?<(a @succ_var_zero$S0) b> b)
@succ_var_zero = (?<(a @succ_var_zero$C0) b> b)
& #0 ~ <+ #1 a>
@succ_var_zero$S0 = (<+ #2 a> a)
@succ_var_zero$C0 = (<+ #2 a> a)
@succ_zero = (?<(#0 (a a)) b> b)
@succ_zero_succ = (?<(#0 (a a)) b> b)
@succ_zero_var = (?<(#0 (a a)) b> b)
@var_succ = (a a)
@var_zero = (a a)
@zero_succ = (?<(#0 (a a)) b> b)
@zero_succ_var = (?<(#0 (a a)) b> b)
@zero_var = (?<(#0 @zero_var$S0) a> a)
@zero_var$S0 = (<+ #1 <- #1 a>> a)
@zero_var_succ = (?<(#0 @zero_var_succ$S0) a> a)
@zero_var_succ$S0 = (<+ #1 <- #1 a>> a)
@zero_var = (?<(#0 @zero_var$C0) a> a)
@zero_var$C0 = (<+ #1 <- #1 a>> a)
@zero_var_succ = (?<(#0 @zero_var_succ$C0) a> a)
@zero_var_succ$C0 = (<+ #1 <- #1 a>> a)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unscoped_supercombinator.hvm
---
@Foo = ((@Foo$S0 (@Foo$S1 a)) a)
@Foo$S0 = (a ((a b) b))
@Foo$S1 = (a ((a b) b))
@Foo = ((@Foo$C0 (@Foo$C1 a)) a)
@Foo$C0 = (a ((a b) b))
@Foo$C1 = (a ((a b) b))
@main = a
& @Foo ~ (* a)

8 changes: 4 additions & 4 deletions tests/snapshots/compile_file_o_all__adt_option_and.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/adt_option_and.hvm
---
@None = {2 * {2 a a}}
@Option.and = ({2 @Option.and$S2 {2 @Option.and$S3_$_Option.and$S1 a}} a)
@Option.and$S0 = {2 a (b {2 {2 [b a] c} {2 * c}})}
@Option.and$S2 = {2 a ({2 @Option.and$S0 {2 @Option.and$S3_$_Option.and$S1 (a b)}} b)}
@Option.and$S3_$_Option.and$S1 = (* @None)
@Option.and = ({2 @Option.and$C2 {2 @Option.and$C3_$_Option.and$C1 a}} a)
@Option.and$C0 = {2 a (b {2 {2 [b a] c} {2 * c}})}
@Option.and$C2 = {2 a ({2 @Option.and$C0 {2 @Option.and$C3_$_Option.and$C1 (a b)}} b)}
@Option.and$C3_$_Option.and$C1 = (* @None)
@Some = (a {2 {2 a b} {2 * b}})
@main = a
& @Option.and ~ (b (c a))
Expand Down
5 changes: 2 additions & 3 deletions tests/snapshots/compile_file_o_all__and.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/and.hvm
---
@and = (a ({2 (b b) {2 @and$S0 (a c)}} c))
@and$S0 = (* @false)
@and = (a ({2 (b b) {2 @and$C0 (a c)}} c))
@and$C0 = (* @false)
@false = {2 * {2 a a}}
@main = a
& @and ~ (@true (@false a))
@true = {2 a {2 * a}}

5 changes: 2 additions & 3 deletions tests/snapshots/compile_file_o_all__ex2.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/ex2.hvm
---
@E = (* @E$S0)
@E$S0 = (* (a a))
@E = (* @E$C0)
@E$C0 = (* (a a))
@I = (a (* ((a b) (* b))))
@c2 = ({3 (a b) (c a)} (c b))
@decO = ((@decO (@low (@E a))) (* ((a b) (* b))))
Expand All @@ -16,4 +16,3 @@ input_file: tests/golden_tests/compile_file_o_all/ex2.hvm
@run = ((@runO (@runI (@E a))) a)
@runI = ((@lowO (@lowI (@E (@runO (@runI (@E a)))))) a)
@runO = ((@decO (@low (@E (@lowO (@lowI (@E (@runO (@runI (@E a))))))))) a)

10 changes: 5 additions & 5 deletions tests/snapshots/compile_file_o_all__expr.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ input_file: tests/golden_tests/compile_file_o_all/expr.hvm
@App = (a (b {4 * {4 * {4 {4 a {4 b c}} {4 * {4 * {4 * {4 * {4 * {4 * c}}}}}}}}}))
@Dup = (a (b (c (d {4 * {4 * {4 * {4 * {4 * {4 * {4 {4 a {4 b {4 c {4 d e}}}} {4 * {4 * e}}}}}}}}}))))
@Let = (a (b (c {4 * {4 * {4 * {4 * {4 * {4 {4 a {4 b {4 c d}}} {4 * {4 * {4 * d}}}}}}}}})))
@Mul = {2 * @Mul$S1}
@Mul$S0 = {2 a {2 * a}}
@Mul$S1 = {2 * @Mul$S0}
@Mul = {2 * @Mul$C1}
@Mul$C0 = {2 a {2 * a}}
@Mul$C1 = {2 * @Mul$C0}
@Num = (a {4 * {4 {4 a b} {4 * {4 * {4 * {4 * {4 * {4 * {4 * b}}}}}}}}})
@Op2 = (a (b (c {4 * {4 * {4 * {4 * {4 * {4 * {4 * {4 * {4 {4 a {4 b {4 c d}}} d}}}}}}}}})))
@Sub = {2 * @Sub$S0}
@Sub$S0 = {2 a {2 * {2 * a}}}
@Sub = {2 * @Sub$C0}
@Sub$C0 = {2 a {2 * {2 * a}}}
@Var = (a {4 {4 a b} {4 * {4 * {4 * {4 * {4 * {4 * {4 * {4 * b}}}}}}}}})
@main = a
& @Let ~ (b (c (d a)))
Expand Down
34 changes: 17 additions & 17 deletions tests/snapshots/compile_file_o_all__list_merge_sort.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/list_merge_sort.hvm
---
@Cons = (a (b {4 {4 a {4 b c}} {4 * c}}))
@If$S0 = (a (* a))
@If$S1 = (* (a a))
@Map = ({4 @Map$S0 {4 @Unpack$S3_$_MergePair$S4_$_Map$S1 a}} a)
@Map$S0 = {4 a {4 {4 @Map$S0 {4 @Unpack$S3_$_MergePair$S4_$_Map$S1 (b c)}} ({5 (a d) b} {4 {4 d {4 c e}} {4 * e}})}}
@Merge$S0 = {4 {9 a {9 b c}} {4 {7 d {4 @Merge$S0 {4 @Merge$S1 (e (f (g h)))}}} ({15 (i (a {2 @If$S0 {2 @If$S1 ({4 {4 j {4 k l}} {4 * l}} ({4 {4 c {4 h m}} {4 * m}} n))}})) {15 o e}} ({13 i {13 j f}} ({11 {4 @Merge$S2 {4 @Merge$S3 (o ({4 {4 b {4 d p}} {4 * p}} k))}} g} n)))}}
@Merge$S1 = (* @Cons)
@Merge$S2 = {4 a {4 b (c ({4 @Merge$S0 {4 @Merge$S1 (c (a (b d)))}} d))}}
@Merge$S3 = (* (a a))
@MergePair$S0 = {4 a {4 {4 @MergePair$S3 {4 @Unpack$S3_$_MergePair$S4_$_Map$S1 (b c)}} ({17 d b} ({4 @Merge$S2 {4 @Merge$S3 (d (a e))}} {4 {4 e {4 c f}} {4 * f}}))}}
@MergePair$S1 = (a {4 {4 a {4 @Nil b}} {4 * b}})
@MergePair$S2 = (* @MergePair$S1)
@MergePair$S3 = {4 a {4 {4 @MergePair$S0 {4 @MergePair$S2 (b (a c))}} (b c)}}
@If$C0 = (a (* a))
@If$C1 = (* (a a))
@Map = ({4 @Map$C0 {4 @Unpack$C3_$_MergePair$C4_$_Map$C1 a}} a)
@Map$C0 = {4 a {4 {4 @Map$C0 {4 @Unpack$C3_$_MergePair$C4_$_Map$C1 (b c)}} ({5 (a d) b} {4 {4 d {4 c e}} {4 * e}})}}
@Merge$C0 = {4 {9 a {9 b c}} {4 {7 d {4 @Merge$C0 {4 @Merge$C1 (e (f (g h)))}}} ({15 (i (a {2 @If$C0 {2 @If$C1 ({4 {4 j {4 k l}} {4 * l}} ({4 {4 c {4 h m}} {4 * m}} n))}})) {15 o e}} ({13 i {13 j f}} ({11 {4 @Merge$C2 {4 @Merge$C3 (o ({4 {4 b {4 d p}} {4 * p}} k))}} g} n)))}}
@Merge$C1 = (* @Cons)
@Merge$C2 = {4 a {4 b (c ({4 @Merge$C0 {4 @Merge$C1 (c (a (b d)))}} d))}}
@Merge$C3 = (* (a a))
@MergePair$C0 = {4 a {4 {4 @MergePair$C3 {4 @Unpack$C3_$_MergePair$C4_$_Map$C1 (b c)}} ({17 d b} ({4 @Merge$C2 {4 @Merge$C3 (d (a e))}} {4 {4 e {4 c f}} {4 * f}}))}}
@MergePair$C1 = (a {4 {4 a {4 @Nil b}} {4 * b}})
@MergePair$C2 = (* @MergePair$C1)
@MergePair$C3 = {4 a {4 {4 @MergePair$C0 {4 @MergePair$C2 (b (a c))}} (b c)}}
@Nil = {4 * {4 a a}}
@Pure = (a {4 {4 a {4 @Nil b}} {4 * b}})
@Unpack = (a ({4 @Unpack$S2 {4 @Unpack$S3_$_MergePair$S4_$_Map$S1 (a b)}} b))
@Unpack$S0 = {4 a {4 {4 @MergePair$S3 {4 @Unpack$S3_$_MergePair$S4_$_Map$S1 (b {4 @Unpack$S0 {4 @Unpack$S1 (c (d e))}})}} ({3 c {17 f b}} ({4 @Merge$S2 {4 @Merge$S3 (f (a d))}} e))}}
@Unpack$S1 = (* (a a))
@Unpack$S2 = {4 a {4 {4 @Unpack$S0 {4 @Unpack$S1 (b (a c))}} (b c)}}
@Unpack$S3_$_MergePair$S4_$_Map$S1 = (* @Nil)
@Unpack = (a ({4 @Unpack$C2 {4 @Unpack$C3_$_MergePair$C4_$_Map$C1 (a b)}} b))
@Unpack$C0 = {4 a {4 {4 @MergePair$C3 {4 @Unpack$C3_$_MergePair$C4_$_Map$C1 (b {4 @Unpack$C0 {4 @Unpack$C1 (c (d e))}})}} ({3 c {17 f b}} ({4 @Merge$C2 {4 @Merge$C3 (f (a d))}} e))}}
@Unpack$C1 = (* (a a))
@Unpack$C2 = {4 a {4 {4 @Unpack$C0 {4 @Unpack$C1 (b (a c))}} (b c)}}
@Unpack$C3_$_MergePair$C4_$_Map$C1 = (* @Nil)
@main = (a (b c))
& @Unpack ~ (a (d c))
& @Map ~ (b (@Pure d))
6 changes: 3 additions & 3 deletions tests/snapshots/compile_file_o_all__list_reverse.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/list_reverse.hvm
---
@concat$S0 = {2 a {2 {2 @concat$S0 {2 (b b) (c d)}} (c {2 {2 a {2 d e}} {2 * e}})}}
@concat$C0 = {2 a {2 {2 @concat$C0 {2 (b b) (c d)}} (c {2 {2 a {2 d e}} {2 * e}})}}
@cons = (a (b {2 {2 a {2 b c}} {2 * c}}))
@main = a
& @reverse ~ (b a)
& @cons ~ (#3 (c b))
& @cons ~ (#2 (d c))
& @cons ~ (#1 (@nil d))
@nil = {2 * {2 a a}}
@reverse = ({2 @reverse$S0 {2 @nil a}} a)
@reverse$S0 = {2 a {2 {2 @reverse$S0 {2 @nil {2 @concat$S0 {2 (b b) ({2 {2 a {2 @nil c}} {2 * c}} d)}}}} d}}
@reverse = ({2 @reverse$C0 {2 @nil a}} a)
@reverse$C0 = {2 a {2 {2 @reverse$C0 {2 @nil {2 @concat$C0 {2 (b b) ({2 {2 a {2 @nil c}} {2 * c}} d)}}}} d}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/match_dup_and_reconstruction.hvm
---
@Boxed = (a {2 {2 a b} b})
@Got = ({3 {2 @Got$S0 (a b)} a} b)
@Got$S0 = {2 a (b [b a])}
@Got = ({3 {2 @Got$C0 (a b)} a} b)
@Got$C0 = {2 a (b [b a])}
@main = a
& @Got ~ (b a)
& @Boxed ~ (#10 b)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/num_pattern_with_var.hvm
---
@Foo = ({2 (* #0) {2 @Foo$S3 a}} a)
@Foo$S2 = (a (* a))
@Foo$S3 = (?<((* #0) @Foo$S2) (* a)> a)
@Foo = ({2 (* #0) {2 @Foo$C3 a}} a)
@Foo$C2 = (a (* a))
@Foo$C3 = (?<((* #0) @Foo$C2) (* a)> a)
@main = a
& @Foo ~ (@true (#3 a))
@true = {2 * {2 a a}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/recursive_combinator_inactive.hvm
---
@Foo = (?<({3 @Foo @Foo} @Foo$S0) a> a)
@Foo$S0 = (a (* a))
@Foo = (?<({3 @Foo @Foo} @Foo$C0) a> a)
@Foo$C0 = (a (* a))
@main = a
& @Foo ~ (#0 a)

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ input_file: tests/golden_tests/compile_file_o_all/repeated_name_trucation.hvm
---
Warnings:
Mutual recursion cycle detected in compiled functions:
Cycle 1: long_name_that_truncates -> long_name_that_truncates$S0 -> long_name_that_truncates
Cycle 1: long_name_that_truncates -> long_name_that_truncates$C0 -> long_name_that_truncates
This program will expand infinitely in strict evaluation mode.
Read https://github.com/HigherOrderCO/hvm-lang/blob/main/docs/lazy-definitions.md for more information.

@long_name_that_truncates = (* @long_name_that_truncates$S0)
@long_name_that_truncates$S0 = (* @long_name_that_truncates)
@long_name_that_truncates = (* @long_name_that_truncates$C0)
@long_name_that_truncates$C0 = (* @long_name_that_truncates)
@main = a
& @long_name_that_truncates ~ ((b b) a)
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/scrutinee_reconstruction.hvm
---
@None = {2 * {2 a a}}
@Option.or = ({3 {2 @Option.or$S1 {2 @Option.or$S2 (a b)}} a} b)
@Option.or$S0 = (a (* a))
@Option.or$S1 = {2 * @Option.or$S0}
@Option.or$S2 = (* (a a))
@Option.or = ({3 {2 @Option.or$C1 {2 @Option.or$C2 (a b)}} a} b)
@Option.or$C0 = (a (* a))
@Option.or$C1 = {2 * @Option.or$C0}
@Option.or$C2 = (* (a a))
@Some = (a {2 {2 a b} {2 * b}})
@main = a
& @Option.or ~ (b (@None a))
Expand Down
9 changes: 4 additions & 5 deletions tests/snapshots/compile_file_o_all__sum_predicates.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ input_file: tests/golden_tests/compile_file_o_all/sum_predicates.hvm
---
@main = a
& @sum_pred ~ (#8 (#5 a))
@sum_pred = (?<(@sum_pred$S0 @sum_pred$S2) a> a)
@sum_pred$S0 = (?<(#0 (a a)) b> b)
@sum_pred$S1 = (a (<+ a b> b))
@sum_pred$S2 = (a (?<((b b) @sum_pred$S1) (a c)> c))

@sum_pred = (?<(@sum_pred$C0 @sum_pred$C2) a> a)
@sum_pred$C0 = (?<(#0 (a a)) b> b)
@sum_pred$C1 = (a (<+ a b> b))
@sum_pred$C2 = (a (?<((b b) @sum_pred$C1) (a c)> c))
13 changes: 6 additions & 7 deletions tests/snapshots/compile_file_o_all__weekday.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/weekday.hvm
---
@Saturday = {2 * @Saturday$S4}
@Saturday$S0 = {2 a {2 * a}}
@Saturday$S1 = {2 * @Saturday$S0}
@Saturday$S2 = {2 * @Saturday$S1}
@Saturday$S3 = {2 * @Saturday$S2}
@Saturday$S4 = {2 * @Saturday$S3}
@Saturday = {2 * @Saturday$C4}
@Saturday$C0 = {2 a {2 * a}}
@Saturday$C1 = {2 * @Saturday$C0}
@Saturday$C2 = {2 * @Saturday$C1}
@Saturday$C3 = {2 * @Saturday$C2}
@Saturday$C4 = {2 * @Saturday$C3}
@main = a
& (b b) ~ (@Saturday a)

6 changes: 3 additions & 3 deletions tests/snapshots/mutual_recursion__len.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/len.hvm
---
@Len = ({2 @Len$S1 {2 #0 a}} a)
@Len$S0 = {2 a b}
@Len = ({2 @Len$C1 {2 #0 a}} a)
@Len$C0 = {2 a b}
& #1 ~ <+ c b>
& @Len ~ (a c)
@Len$S1 = {2 * @Len$S0}
@Len$C1 = {2 * @Len$C0}
@List.cons = (a (b {2 {2 a {2 b c}} {2 * c}}))
@List.nil = {2 * {2 a a}}
@main = a
Expand Down
Loading