| @@ -106,14 +106,19 @@ fn empty_variant_list(node: &SyntaxNode) -> bool { |
| 106 | 106 | .any(|c| matches!(c.kind(), VARIANT | COMMENT | DOC_COMMENT)) |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | | −/// `()`/`< >`/`{ }` holding neither an element nor a comment: it hugs its |
| 110 | | −/// head even when the construct around it breaks (`fn f()`, not |
| 111 | | −/// `fn f\n ()`). |
| 112 | | −fn empty_brackets(node: &SyntaxNode) -> bool { |
| 109 | +/// A parameter list holding at least one parameter. An empty one prints |
| 110 | +/// as nothing: `fn main ::` (ADR 0061). |
| 111 | +fn has_params(node: &SyntaxNode) -> bool { |
| 112 | + node.children().any(|n| n.kind() == PARAM) |
| 113 | +} |
| 114 | + |
| 115 | +/// An argument list with parentheses: a constructor's fields or a record |
| 116 | +/// update (`User(~name: "ada")`), as opposed to an application's bare |
| 117 | +/// arguments (`f a b`) (ADR 0061). |
| 118 | +fn arg_list_parened(node: &SyntaxNode) -> bool { |
| 113 | 119 | node.children_with_tokens() |
| 114 | | − .filter(|c| !c.kind().is_trivia()) |
| 115 | | − .count() |
| 116 | | − == 2 |
| 120 | + .find(|c| !c.kind().is_trivia()) |
| 121 | + .is_some_and(|c| c.kind() == L_PAREN) |
| 117 | 122 | } |
| 118 | 123 | |
| 119 | 124 | /// A comma separating match arms, handler clauses or variants. The grammar |
| @@ -696,6 +701,16 @@ impl<'a> Printer<'a> { |
| 696 | 701 | match node.kind() { |
| 697 | 702 | SOURCE_FILE => self.raw(node), // handled by `source_file` |
| 698 | 703 | ATTR => self.attr(node), |
| 704 | + ATTR_ARG_CALL => { |
| 705 | + // `(blocking io)`: tokens space-joined inside the parens. |
| 706 | + let Seq { items, .. } = self.seq(node); |
| 707 | + let inner: Vec<Doc> = items |
| 708 | + .iter() |
| 709 | + .filter(|i| !matches!(i.el.kind(), L_PAREN | R_PAREN)) |
| 710 | + .map(|i| self.item_doc(i)) |
| 711 | + .collect(); |
| 712 | + pretty::cat([self.t("("), pretty::join(self.t(" "), inner), self.t(")")]) |
| 713 | + } |
| 699 | 714 | IMPORT => self.import(node), |
| 700 | 715 | IMPORT_PATH => self.joined_tokens(node), |
| 701 | 716 | IMPORT_LIST => self.bracket_list(node, L_BRACE, R_BRACE, false), |
| @@ -743,7 +758,8 @@ impl<'a> Printer<'a> { |
| 743 | 758 | BIN_EXPR => self.bin_expr(node), |
| 744 | 759 | PREFIX_EXPR => self.prefix_expr(node), |
| 745 | 760 | CALL_EXPR => self.call_expr(node), |
| 746 | | − ARG_LIST => self.bracket_list(node, L_PAREN, R_PAREN, false), |
| 761 | + ARG_LIST if arg_list_parened(node) => self.bracket_list(node, L_PAREN, R_PAREN, false), |
| 762 | + ARG_LIST => self.space_list(node), |
| 747 | 763 | ARG => self.arg(node), |
| 748 | 764 | LABEL => self.label(node), |
| 749 | 765 | FIELD_EXPR => self.field_expr(node), |
| @@ -789,15 +805,23 @@ impl<'a> Printer<'a> { |
| 789 | 805 | self.seq_stacked(items.into_iter().collect(), &end_comments) |
| 790 | 806 | } |
| 791 | 807 | |
| 792 | | − /// `@name` or `@name(arg, ...)`. |
| 808 | + /// `@name arg*`: the name, then its arguments space-separated (ADR |
| 809 | + /// 0061). |
| 793 | 810 | fn attr(&self, node: &SyntaxNode) -> Doc<'a> { |
| 794 | 811 | let Seq { items, .. } = self.seq(node); |
| 795 | 812 | let mut docs = vec![self.t("@")]; |
| 796 | 813 | for item in items { |
| 797 | 814 | match item.el.kind() { |
| 798 | 815 | AT => docs.push(self.skipped(&item)), |
| 799 | | − NAME => docs.push(self.item_doc(&item)), |
| 800 | | − ATTR_ARG_LIST => docs.push(self.item_doc(&item)), |
| 816 | + ATTR_ARG_LIST => { |
| 817 | + if let NodeOrToken::Node(n) = &item.el { |
| 818 | + let Seq { items: args, .. } = self.seq(n); |
| 819 | + for arg in args { |
| 820 | + docs.push(self.t(" ")); |
| 821 | + docs.push(self.item_doc(&arg)); |
| 822 | + } |
| 823 | + } |
| 824 | + } |
| 801 | 825 | _ => docs.push(self.item_doc(&item)), |
| 802 | 826 | } |
| 803 | 827 | } |
| @@ -883,9 +907,10 @@ impl<'a> Printer<'a> { |
| 883 | 907 | (attrs, rest) |
| 884 | 908 | } |
| 885 | 909 | |
| 886 | | − /// `fn name(params) -> T / <effects> where C { body }`; broken |
| 887 | | − /// parameters move whole under the head, then the row breaks for |
| 888 | | − /// itself: the signature breaks at the parameters, then the row. |
| 910 | + /// `fn name :: params -> T / <effects> where C { body }` (ADR 0061): |
| 911 | + /// the signature is one group — it fits on one line, or breaks whole: |
| 912 | + /// the `::` holds the head line, the parameters stack one per line |
| 913 | + /// under it, then the return type and `where` on their own lines. |
| 889 | 914 | fn fn_def(&self, node: &SyntaxNode) -> Doc<'a> { |
| 890 | 915 | let Seq { mut items, .. } = self.seq(node); |
| 891 | 916 | let (attrs, mut head) = self.item_prefix(&mut items); |
| @@ -895,13 +920,14 @@ impl<'a> Printer<'a> { |
| 895 | 920 | for item in items { |
| 896 | 921 | match item.el.kind() { |
| 897 | 922 | FN_KW => head.push(self.punct(&item, "fn ")), |
| 923 | + COLON2 => head.push(self.punct(&item, " ::")), |
| 898 | 924 | PARAM_LIST => { |
| 899 | 925 | if let NodeOrToken::Node(n) = &item.el |
| 900 | | − && empty_brackets(n) |
| 926 | + && has_params(n) |
| 901 | 927 | { |
| 902 | | − head.push(self.item_doc(&item)); |
| 928 | + params = Some(self.with_comments(&item, self.space_list(n))); |
| 903 | 929 | } else { |
| 904 | | − params = Some(self.item_doc(&item)); |
| 930 | + head.push(self.skipped(&item)); |
| 905 | 931 | } |
| 906 | 932 | } |
| 907 | 933 | RET_TYPE | WHERE_CLAUSE => { |
| @@ -920,7 +946,7 @@ impl<'a> Printer<'a> { |
| 920 | 946 | } |
| 921 | 947 | } |
| 922 | 948 | let sig = match params { |
| 923 | | − Some(p) => self.under(pretty::cat(head), Doc::SoftLine, p, pretty::cat(tail)), |
| 949 | + Some(p) => self.under(pretty::cat(head), Doc::Line, p, pretty::cat(tail)), |
| 924 | 950 | None => pretty::group(pretty::cat([ |
| 925 | 951 | pretty::cat(head), |
| 926 | 952 | pretty::nest(1, pretty::cat(tail)), |
| @@ -933,6 +959,17 @@ impl<'a> Printer<'a> { |
| 933 | 959 | } |
| 934 | 960 | } |
| 935 | 961 | |
| 962 | + /// Space-separated elements that break one per line (an application's |
| 963 | + /// arguments, a definition's parameters, ADR 0061): `a b: T ~name: c` |
| 964 | + /// flat, or stacked when the enclosing group breaks. |
| 965 | + fn space_list(&self, node: &SyntaxNode) -> Doc<'a> { |
| 966 | + let Seq { items, .. } = self.seq(node); |
| 967 | + pretty::join( |
| 968 | + Doc::Line, |
| 969 | + items.iter().map(|i| self.item_doc(i)).collect::<Vec<_>>(), |
| 970 | + ) |
| 971 | + } |
| 972 | + |
| 936 | 973 | /// `pat: T` in a parameter list. |
| 937 | 974 | fn param(&self, node: &SyntaxNode) -> Doc<'a> { |
| 938 | 975 | let Seq { items, .. } = self.seq(node); |
| @@ -1128,7 +1165,9 @@ impl<'a> Printer<'a> { |
| 1128 | 1165 | return self.t("{}"); |
| 1129 | 1166 | } |
| 1130 | 1167 | // A comment above the first variant keeps its own line. |
| 1131 | | − let first_has_comments = variants.first().is_some_and(|(item, _)| !item.leading.is_empty()); |
| 1168 | + let first_has_comments = variants |
| 1169 | + .first() |
| 1170 | + .is_some_and(|(item, _)| !item.leading.is_empty()); |
| 1132 | 1171 | let body = self.seq_lead_comma(variants, &end); |
| 1133 | 1172 | // The opener is inside the nest so that a comment trailing it |
| 1134 | 1173 | // ends its line at the variants' indent, not the brace's. |
| @@ -1251,12 +1290,9 @@ impl<'a> Printer<'a> { |
| 1251 | 1290 | } |
| 1252 | 1291 | let doc = self.el_doc(&item.el); |
| 1253 | 1292 | let doc = match &item.trailing { |
| 1254 | | − Some(c) => pretty::cat([ |
| 1255 | | − doc, |
| 1256 | | − self.t(" "), |
| 1257 | | − self.comment(c), |
| 1258 | | − Doc::HardLineSoft, |
| 1259 | | − ]), |
| 1293 | + Some(c) => { |
| 1294 | + pretty::cat([doc, self.t(" "), self.comment(c), Doc::HardLineSoft]) |
| 1295 | + } |
| 1260 | 1296 | None => doc, |
| 1261 | 1297 | }; |
| 1262 | 1298 | members.push(ListEntry::Item(doc)); |
| @@ -1293,8 +1329,8 @@ impl<'a> Printer<'a> { |
| 1293 | 1329 | ]) |
| 1294 | 1330 | } |
| 1295 | 1331 | |
| 1296 | | − /// `fn op(..) -> T`, `final ctl op(..) -> T`; broken parameters move |
| 1297 | | − /// whole under the operation's name. |
| 1332 | + /// `fn op :: params -> T`, `final ctl op :: params -> T` (ADR 0061); |
| 1333 | + /// broken parameters stack under the `::`, one per line. |
| 1298 | 1334 | fn effect_op(&self, node: &SyntaxNode) -> Doc<'a> { |
| 1299 | 1335 | let Seq { items, .. } = self.seq(node); |
| 1300 | 1336 | let mut head = Vec::new(); |
| @@ -1306,13 +1342,14 @@ impl<'a> Printer<'a> { |
| 1306 | 1342 | MULTI_KW => head.push(self.punct(&item, "multi ")), |
| 1307 | 1343 | CTL_KW => head.push(self.punct(&item, "ctl ")), |
| 1308 | 1344 | FN_KW => head.push(self.punct(&item, "fn ")), |
| 1345 | + COLON2 => head.push(self.punct(&item, " ::")), |
| 1309 | 1346 | PARAM_LIST => { |
| 1310 | 1347 | if let NodeOrToken::Node(n) = &item.el |
| 1311 | | − && empty_brackets(n) |
| 1348 | + && has_params(n) |
| 1312 | 1349 | { |
| 1313 | | − head.push(self.item_doc(&item)); |
| 1350 | + params = Some(self.with_comments(&item, self.space_list(n))); |
| 1314 | 1351 | } else { |
| 1315 | | − params = Some(self.item_doc(&item)); |
| 1352 | + head.push(self.skipped(&item)); |
| 1316 | 1353 | } |
| 1317 | 1354 | } |
| 1318 | 1355 | RET_TYPE | WHERE_CLAUSE => { |
| @@ -1324,7 +1361,7 @@ impl<'a> Printer<'a> { |
| 1324 | 1361 | } |
| 1325 | 1362 | } |
| 1326 | 1363 | match params { |
| 1327 | | − Some(p) => self.under(pretty::cat(head), Doc::SoftLine, p, pretty::cat(tail)), |
| 1364 | + Some(p) => self.under(pretty::cat(head), Doc::Line, p, pretty::cat(tail)), |
| 1328 | 1365 | None => pretty::group(pretty::cat([ |
| 1329 | 1366 | pretty::cat(head), |
| 1330 | 1367 | pretty::nest(1, pretty::cat(tail)), |
| @@ -1705,26 +1742,52 @@ impl<'a> Printer<'a> { |
| 1705 | 1742 | pretty::cat(items.iter().map(|i| self.item_doc(i))) |
| 1706 | 1743 | } |
| 1707 | 1744 | |
| 1708 | | − /// `f(a, label: b)`; a broken argument list hugs its first argument: |
| 1709 | | − /// the grammar keeps a call's `(` on the callee's line (a newline |
| 1710 | | − /// before it starts a new statement), so the list cannot move under. |
| 1745 | + /// `f a b` or `User(~name: "ada")` (ADR 0061). An application fits on |
| 1746 | + /// its line, or its arguments move whole under the callee, one per |
| 1747 | + /// line (ADR 0059 rev. 4's under-form): |
| 1748 | + /// |
| 1749 | + /// ```text |
| 1750 | + /// request |
| 1751 | + /// "GET" |
| 1752 | + /// "/" |
| 1753 | + /// headers |
| 1754 | + /// ``` |
| 1755 | + /// |
| 1756 | + /// A constructor's fields keep their parentheses and hug the first |
| 1757 | + /// one, commas leading. |
| 1711 | 1758 | fn call_expr(&self, node: &SyntaxNode) -> Doc<'a> { |
| 1712 | 1759 | let Seq { items, .. } = self.seq(node); |
| 1713 | | − pretty::cat(items.iter().map(|i| self.item_doc(i))) |
| 1760 | + let mut it = items.into_iter(); |
| 1761 | + let Some(callee) = it.next() else { |
| 1762 | + return self.raw(node); |
| 1763 | + }; |
| 1764 | + let callee = self.item_doc(&callee); |
| 1765 | + let Some(args) = it.next() else { |
| 1766 | + return callee; |
| 1767 | + }; |
| 1768 | + let args_doc = self.item_doc(&args); |
| 1769 | + if matches!(&args.el, NodeOrToken::Node(n) if arg_list_parened(n)) { |
| 1770 | + // Construction: the `(` hugs the constructor's name. |
| 1771 | + pretty::cat([callee, args_doc]) |
| 1772 | + } else { |
| 1773 | + self.under(callee, Doc::Line, args_doc, Doc::Nil) |
| 1774 | + } |
| 1714 | 1775 | } |
| 1715 | 1776 | |
| 1716 | | − /// `label: expr` or `expr` in a call. |
| 1777 | + /// `~name: expr`, `~name` or `expr` in a call (ADR 0061). |
| 1717 | 1778 | fn arg(&self, node: &SyntaxNode) -> Doc<'a> { |
| 1718 | 1779 | let Seq { items, .. } = self.seq(node); |
| 1719 | 1780 | pretty::cat(items.iter().map(|i| self.item_doc(i))) |
| 1720 | 1781 | } |
| 1721 | 1782 | |
| 1722 | | − /// `name: ` before an argument or a pattern. |
| 1783 | + /// `~name: ` or `~name` before an argument, pattern, parameter or type |
| 1784 | + /// (ADR 0061). |
| 1723 | 1785 | fn label(&self, node: &SyntaxNode) -> Doc<'a> { |
| 1724 | 1786 | let Seq { items, .. } = self.seq(node); |
| 1725 | 1787 | let mut docs = Vec::new(); |
| 1726 | 1788 | for item in items { |
| 1727 | 1789 | match item.el.kind() { |
| 1790 | + TILDE => docs.push(self.punct(&item, "~")), |
| 1728 | 1791 | COLON => docs.push(self.punct(&item, ": ")), |
| 1729 | 1792 | _ => docs.push(self.item_doc(&item)), |
| 1730 | 1793 | } |
| @@ -1983,8 +2046,8 @@ impl<'a> Printer<'a> { |
| 1983 | 2046 | } |
| 1984 | 2047 | } |
| 1985 | 2048 | |
| 1986 | | − /// `fn(params) -> T { body }`; broken parameters move whole under |
| 1987 | | − /// the `fn`. |
| 2049 | + /// `fn a b -> T { body }` (ADR 0061): a lambda has no name and no |
| 2050 | + /// `::`; broken parameters stack under the `fn`, one per line. |
| 1988 | 2051 | fn lambda(&self, node: &SyntaxNode) -> Doc<'a> { |
| 1989 | 2052 | let Seq { items, .. } = self.seq(node); |
| 1990 | 2053 | let mut head = Vec::new(); |
| @@ -1996,11 +2059,11 @@ impl<'a> Printer<'a> { |
| 1996 | 2059 | FN_KW => head.push(self.punct(&item, "fn")), |
| 1997 | 2060 | PARAM_LIST => { |
| 1998 | 2061 | if let NodeOrToken::Node(n) = &item.el |
| 1999 | | − && empty_brackets(n) |
| 2062 | + && has_params(n) |
| 2000 | 2063 | { |
| 2001 | | − head.push(self.item_doc(&item)); |
| 2064 | + params = Some(self.with_comments(&item, self.space_list(n))); |
| 2002 | 2065 | } else { |
| 2003 | | − params = Some(self.item_doc(&item)); |
| 2066 | + head.push(self.skipped(&item)); |
| 2004 | 2067 | } |
| 2005 | 2068 | } |
| 2006 | 2069 | BLOCK => block = Some(self.item_doc(&item)), |
| @@ -2012,7 +2075,7 @@ impl<'a> Printer<'a> { |
| 2012 | 2075 | } |
| 2013 | 2076 | } |
| 2014 | 2077 | let sig = match params { |
| 2015 | | − Some(p) => self.under(pretty::cat(head), Doc::SoftLine, p, pretty::cat(tail)), |
| 2078 | + Some(p) => self.under(pretty::cat(head), Doc::Line, p, pretty::cat(tail)), |
| 2016 | 2079 | None => pretty::group(pretty::cat([ |
| 2017 | 2080 | pretty::cat(head), |
| 2018 | 2081 | pretty::nest(1, pretty::cat(tail)), |
| @@ -2048,7 +2111,8 @@ impl<'a> Printer<'a> { |
| 2048 | 2111 | pretty::cat(docs) |
| 2049 | 2112 | } |
| 2050 | 2113 | |
| 2051 | | − /// `op(x) -> body` in a handler; the body follows the arm rule. |
| 2114 | + /// `op x -> body` in a handler (ADR 0061); the body follows the arm |
| 2115 | + /// rule. |
| 2052 | 2116 | fn handler_clause(&self, node: &SyntaxNode) -> Doc<'a> { |
| 2053 | 2117 | let Seq { items, .. } = self.seq(node); |
| 2054 | 2118 | let mut head = Vec::new(); |
| @@ -2063,6 +2127,14 @@ impl<'a> Printer<'a> { |
| 2063 | 2127 | arrow = Some(item); |
| 2064 | 2128 | } |
| 2065 | 2129 | COMMA if past_arrow => comma = Some(item), |
| 2130 | + PARAM_LIST => { |
| 2131 | + if let NodeOrToken::Node(n) = &item.el |
| 2132 | + && has_params(n) |
| 2133 | + { |
| 2134 | + head.push(self.t(" ")); |
| 2135 | + head.push(self.with_comments(&item, self.space_list(n))); |
| 2136 | + } |
| 2137 | + } |
| 2066 | 2138 | _ if past_arrow => body = Some(item), |
| 2067 | 2139 | _ => head.push(self.item_doc(&item)), |
| 2068 | 2140 | } |
| @@ -2291,60 +2363,61 @@ mod tests { |
| 2291 | 2363 | |
| 2292 | 2364 | #[test] |
| 2293 | 2365 | fn short_code_is_untouched() { |
| 2294 | | − let src = "fn f(x) {\n let y = x\n y\n}\n"; |
| 2366 | + let src = "fn f :: x {\n let y = x\n y\n}\n"; |
| 2295 | 2367 | assert_eq!(fmt(src), src); |
| 2296 | 2368 | assert_eq!(fmt("type T { A }\n"), "type T { A }\n"); |
| 2297 | 2369 | // Variants go one per line, the first hugging the `{`. |
| 2298 | 2370 | assert_eq!(fmt("type T { A B }\n"), "type T\n { A\n , B\n }\n"); |
| 2299 | | − assert_eq!(fmt("fn f() {\n f(1,2)\n}\n"), "fn f() {\n f(1, 2)\n}\n"); |
| 2371 | + assert_eq!(fmt("fn f :: {\n f 1 2\n}\n"), "fn f :: {\n f 1 2\n}\n"); |
| 2300 | 2372 | // An empty block is `{}`. |
| 2301 | | − assert_eq!(fmt("fn a() {\n}\n"), "fn a() {}\n"); |
| 2373 | + assert_eq!(fmt("fn a :: {\n}\n"), "fn a :: {}\n"); |
| 2302 | 2374 | // A function body always breaks, even for one short statement. |
| 2303 | | − assert_eq!(fmt("fn f() { f(a, b) }\n"), "fn f() {\n f(a, b)\n}\n"); |
| 2375 | + assert_eq!(fmt("fn f :: { f a b }\n"), "fn f :: {\n f a b\n}\n"); |
| 2304 | 2376 | } |
| 2305 | 2377 | |
| 2306 | 2378 | #[test] |
| 2307 | 2379 | fn refuses_broken_input() { |
| 2308 | | − assert_eq!(format("fn f( {"), Err(FormatError::SyntaxErrors)); |
| 2380 | + assert_eq!(format("fn f :: ( {"), Err(FormatError::SyntaxErrors)); |
| 2309 | 2381 | } |
| 2310 | 2382 | |
| 2311 | 2383 | #[test] |
| 2312 | 2384 | fn broken_lists_hug_the_first_element() { |
| 2313 | | − let src = "fn f() {\n let xs = [aaaaaaaaaaaaaaa, bbbbbbbbbbbbbbb, ccccccccccccccc, ddddddddddddddd, eeeeeeeeeeeeeee]\n}\n"; |
| 2385 | + let src = "fn f :: {\n let xs = [aaaaaaaaaaaaaaa, bbbbbbbbbbbbbbb, ccccccccccccccc, ddddddddddddddd, eeeeeeeeeeeeeee]\n}\n"; |
| 2314 | 2386 | assert_eq!( |
| 2315 | 2387 | fmt(src), |
| 2316 | | − "fn f() {\n let xs =\n [ aaaaaaaaaaaaaaa\n , bbbbbbbbbbbbbbb\n , ccccccccccccccc\n , ddddddddddddddd\n , eeeeeeeeeeeeeee\n ]\n}\n" |
| 2388 | + "fn f :: {\n let xs =\n [ aaaaaaaaaaaaaaa\n , bbbbbbbbbbbbbbb\n , ccccccccccccccc\n , ddddddddddddddd\n , eeeeeeeeeeeeeee\n ]\n}\n" |
| 2317 | 2389 | ); |
| 2318 | 2390 | // A list that fits once its surroundings broke rejoins. |
| 2319 | 2391 | assert_eq!( |
| 2320 | | − narrow("fn f() {\n g( a\n , [x, y]\n )\n}\n"), |
| 2321 | | − narrow("fn f() {\n g(a, [x, y])\n}\n") |
| 2392 | + narrow("fn f :: {\n g\n a\n [x, y]\n}\n"), |
| 2393 | + narrow("fn f :: {\n g a [x, y]\n}\n") |
| 2322 | 2394 | ); |
| 2323 | 2395 | } |
| 2324 | 2396 | |
| 2325 | 2397 | #[test] |
| 2326 | | − fn calls_hug_their_first_argument() { |
| 2327 | | − // The `(` stays on the callee's line (the grammar reads a newline |
| 2328 | | − // before it as a new statement); the first argument hugs it. |
| 2398 | + fn application_moves_under_the_callee() { |
| 2399 | + // ADR 0059 rev. 4's under-form: a broken application's arguments |
| 2400 | + // move whole under the callee, one per line (no commas exist to |
| 2401 | + // lead). |
| 2329 | 2402 | assert_eq!( |
| 2330 | | − narrow("fn f() {\n request(\"GET\", \"/\", an_argument, another)\n}\n"), |
| 2331 | | − "fn f() {\n request( \"GET\"\n , \"/\"\n , an_argument\n , another\n )\n}\n" |
| 2403 | + narrow("fn f :: {\n request \"GET\" \"/\" an_argument another_argument\n}\n"), |
| 2404 | + "fn f :: {\n request\n \"GET\"\n \"/\"\n an_argument\n another_argument\n}\n" |
| 2332 | 2405 | ); |
| 2333 | 2406 | } |
| 2334 | 2407 | |
| 2335 | 2408 | #[test] |
| 2336 | 2409 | fn a_one_element_tuple_keeps_its_comma() { |
| 2337 | 2410 | assert_eq!( |
| 2338 | | − fmt("fn f() {\n let t = (1,)\n t\n}\n"), |
| 2339 | | − "fn f() {\n let t = (1,)\n t\n}\n" |
| 2411 | + fmt("fn f :: {\n let t = (1,)\n t\n}\n"), |
| 2412 | + "fn f :: {\n let t = (1,)\n t\n}\n" |
| 2340 | 2413 | ); |
| 2341 | 2414 | assert_eq!( |
| 2342 | | − narrow("fn f() {\n let t = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n"), |
| 2343 | | − "fn f() {\n let t =\n (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n" |
| 2415 | + narrow("fn f :: {\n let t = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n"), |
| 2416 | + "fn f :: {\n let t =\n (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n" |
| 2344 | 2417 | ); |
| 2345 | 2418 | assert_eq!( |
| 2346 | | − narrow("fn f() {\n let t = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n"), |
| 2347 | | − "fn f() {\n let t =\n ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n )\n t\n}\n" |
| 2419 | + narrow("fn f :: {\n let t = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,)\n t\n}\n"), |
| 2420 | + "fn f :: {\n let t =\n ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n )\n t\n}\n" |
| 2348 | 2421 | ); |
| 2349 | 2422 | } |
| 2350 | 2423 | |
| @@ -2352,44 +2425,44 @@ mod tests { |
| 2352 | 2425 | fn pipes_and_operators_break_before_the_operator() { |
| 2353 | 2426 | assert_eq!( |
| 2354 | 2427 | narrow( |
| 2355 | | − "fn f() {\n xs |> list.map(double_the_number) |> list.sum |> list.fold(0, add)\n}\n" |
| 2428 | + "fn f :: {\n xs |> list.map double_the_number |> list.sum |> list.fold 0 add\n}\n" |
| 2356 | 2429 | ), |
| 2357 | | − "fn f() {\n xs\n |> list.map(double_the_number)\n |> list.sum\n |> list.fold(0, add)\n}\n" |
| 2430 | + "fn f :: {\n xs\n |> list.map double_the_number\n |> list.sum\n |> list.fold 0 add\n}\n" |
| 2358 | 2431 | ); |
| 2359 | 2432 | // A pipeline that fits stays on one line, however many pipes. |
| 2360 | | − let fits = "fn f() {\n xs |> list.map(f) |> list.filter(g) |> list.sum\n}\n"; |
| 2433 | + let fits = "fn f :: {\n xs |> list.map f |> list.filter g |> list.sum\n}\n"; |
| 2361 | 2434 | assert_eq!(fmt(fits), fits); |
| 2362 | 2435 | // A long value moves under the `=`, then the pipeline breaks. |
| 2363 | 2436 | assert_eq!( |
| 2364 | | − narrow("fn f() {\n let total = xs |> list.map(double_the_number) |> list.sum\n}\n"), |
| 2365 | | − "fn f() {\n let total =\n xs\n |> list.map(double_the_number)\n |> list.sum\n}\n" |
| 2437 | + narrow("fn f :: {\n let total = xs |> list.map double_the_number |> list.sum\n}\n"), |
| 2438 | + "fn f :: {\n let total =\n xs\n |> list.map double_the_number\n |> list.sum\n}\n" |
| 2366 | 2439 | ); |
| 2367 | 2440 | assert_eq!( |
| 2368 | | − narrow("fn f() {\n let b = aaaaaaaa && bbbbbbbb && cccccccc\n}\n"), |
| 2369 | | − "fn f() {\n let b =\n aaaaaaaa && bbbbbbbb && cccccccc\n}\n" |
| 2441 | + narrow("fn f :: {\n let b = aaaaaaaa && bbbbbbbb && cccccccc\n}\n"), |
| 2442 | + "fn f :: {\n let b =\n aaaaaaaa && bbbbbbbb && cccccccc\n}\n" |
| 2370 | 2443 | ); |
| 2371 | 2444 | } |
| 2372 | 2445 | |
| 2373 | 2446 | #[test] |
| 2374 | 2447 | fn match_arms_are_one_per_line_with_leading_commas() { |
| 2375 | | − let src = "fn f(x) {\n match x {\n Some(a) -> a\n , None -> 0\n }\n}\n"; |
| 2448 | + let src = "fn f :: x {\n match x {\n Some(a) -> a\n , None -> 0\n }\n}\n"; |
| 2376 | 2449 | assert_eq!(fmt(src), src); |
| 2377 | 2450 | // Trailing commas move to the front; the last one goes. |
| 2378 | 2451 | assert_eq!( |
| 2379 | | − fmt("fn f(x) {\n match x {\n Some(a) -> a,\n None -> 0,\n }\n}\n"), |
| 2452 | + fmt("fn f :: x {\n match x {\n Some(a) -> a,\n None -> 0,\n }\n}\n"), |
| 2380 | 2453 | src |
| 2381 | 2454 | ); |
| 2382 | 2455 | // An arm body broken after `->` rejoins when it fits. |
| 2383 | 2456 | assert_eq!( |
| 2384 | | − fmt("fn f(x) {\n match x {\n Some(a) ->\n a,\n }\n}\n"), |
| 2385 | | − "fn f(x) {\n match x {\n Some(a) -> a\n }\n}\n" |
| 2457 | + fmt("fn f :: x {\n match x {\n Some(a) ->\n a,\n }\n}\n"), |
| 2458 | + "fn f :: x {\n match x {\n Some(a) -> a\n }\n}\n" |
| 2386 | 2459 | ); |
| 2387 | 2460 | // A block body needs no comma in the source; it gets one anyway. |
| 2388 | 2461 | assert_eq!( |
| 2389 | 2462 | fmt( |
| 2390 | | − "fn f(x) {\n match x {\n A -> {\n g()\n 1\n }\n B -> 0\n }\n}\n" |
| 2463 | + "fn f :: x {\n match x {\n A -> {\n g ()\n 1\n }\n B -> 0\n }\n}\n" |
| 2391 | 2464 | ), |
| 2392 | | − "fn f(x) {\n match x {\n A -> {\n g()\n 1\n }\n , B -> 0\n }\n}\n" |
| 2465 | + "fn f :: x {\n match x {\n A -> {\n g ()\n 1\n }\n , B -> 0\n }\n}\n" |
| 2393 | 2466 | ); |
| 2394 | 2467 | } |
| 2395 | 2468 | |
| @@ -2397,22 +2470,21 @@ mod tests { |
| 2397 | 2470 | fn arm_comments_and_blank_lines_stay() { |
| 2398 | 2471 | // A comment on the comma's line stays at the end of that line. |
| 2399 | 2472 | assert_eq!( |
| 2400 | | − fmt("fn f(x) {\n match x {\n A -> 1, // one\n B -> 2,\n }\n}\n"), |
| 2401 | | − "fn f(x) {\n match x {\n A -> 1 // one\n , B -> 2\n }\n}\n" |
| 2473 | + fmt("fn f :: x {\n match x {\n A -> 1, // one\n B -> 2,\n }\n}\n"), |
| 2474 | + "fn f :: x {\n match x {\n A -> 1 // one\n , B -> 2\n }\n}\n" |
| 2402 | 2475 | ); |
| 2403 | 2476 | // ... and keeps the body on it once the comment trails the body. |
| 2404 | | − let led = "fn f(x) {\n match x {\n A -> 1 // one\n , B -> 2\n }\n}\n"; |
| 2477 | + let led = "fn f :: x {\n match x {\n A -> 1 // one\n , B -> 2\n }\n}\n"; |
| 2405 | 2478 | assert_eq!(narrow(led), led); |
| 2406 | 2479 | // A comment above an arm stays above it, before its comma; a blank |
| 2407 | 2480 | // line between arms is kept. |
| 2408 | 2481 | assert_eq!( |
| 2409 | | − fmt("fn f(x) {\n match x {\n A -> 1,\n\n // two\n B -> 2,\n }\n}\n"), |
| 2410 | | − "fn f(x) {\n match x {\n A -> 1\n\n // two\n , B -> 2\n }\n}\n" |
| 2482 | + fmt("fn f :: x {\n match x {\n A -> 1,\n\n // two\n B -> 2,\n }\n}\n"), |
| 2483 | + "fn f :: x {\n match x {\n A -> 1\n\n // two\n , B -> 2\n }\n}\n" |
| 2411 | 2484 | ); |
| 2412 | 2485 | // ... and stay there once the comma leads (the comment and the |
| 2413 | 2486 | // blank line then belong to the comma, in the arm above). |
| 2414 | | − let led = |
| 2415 | | − "fn f(x) {\n match x {\n A -> 1\n\n // two\n , B -> 2\n\n , C -> 3\n }\n}\n"; |
| 2487 | + let led = "fn f :: x {\n match x {\n A -> 1\n\n // two\n , B -> 2\n\n , C -> 3\n }\n}\n"; |
| 2416 | 2488 | assert_eq!(fmt(led), led); |
| 2417 | 2489 | } |
| 2418 | 2490 | |
| @@ -2420,16 +2492,16 @@ mod tests { |
| 2420 | 2492 | fn a_pattern_stays_whole_when_its_body_moves_under_the_arrow() { |
| 2421 | 2493 | // The body moves under `->`, so it takes no room on the pattern's |
| 2422 | 2494 | // line: the pattern does not break for it. |
| 2423 | | − let src = "fn f(xs) {\n match xs {\n [] -> True\n , [q, ..rest] ->\n q != column && q - column != distance && safe(column, rest, distance)\n }\n}\n"; |
| 2495 | + let src = "fn f :: xs {\n match xs {\n [] -> True\n , [q, ..rest] ->\n q != column && q - column != distance && safe column rest distance\n }\n}\n"; |
| 2424 | 2496 | assert_eq!(fmt(src), src); |
| 2425 | 2497 | // ... and when the body breaks too. |
| 2426 | | − let src = "fn f(xs) {\n match xs {\n [] -> True\n , [q, ..rest] ->\n q != col && q - col != distance && col - q != distance\n && safe(col, rest, distance + 1)\n }\n}\n"; |
| 2498 | + let src = "fn f :: xs {\n match xs {\n [] -> True\n , [q, ..rest] ->\n q != col && q - col != distance && col - q != distance\n && safe col rest (distance + 1)\n }\n}\n"; |
| 2427 | 2499 | assert_eq!(fmt(src), src); |
| 2428 | 2500 | } |
| 2429 | 2501 | |
| 2430 | 2502 | #[test] |
| 2431 | 2503 | fn a_long_comment_in_a_hugged_block_breaks_nothing_before_it() { |
| 2432 | | − let src = "fn f(a) {\n match a {\n A(chars, _, w, k, _, _) if k > 0 -> {\n // a comment long enough to pass the end of the line from the arm\n 1\n }\n , _ -> 0\n }\n}\n"; |
| 2504 | + let src = "fn f :: a {\n match a {\n A(chars, _, w, k, _, _) if k > 0 -> {\n // a comment long enough to pass the end of the line from the arm\n 1\n }\n , _ -> 0\n }\n}\n"; |
| 2433 | 2505 | assert_eq!(fmt(src), src); |
| 2434 | 2506 | } |
| 2435 | 2507 | |
| @@ -2437,9 +2509,9 @@ mod tests { |
| 2437 | 2509 | fn handler_clauses_have_leading_commas() { |
| 2438 | 2510 | assert_eq!( |
| 2439 | 2511 | fmt( |
| 2440 | | − "fn f() {\n handle {\n g()\n } with {\n ask() -> resume(1),\n return(x) -> x,\n }\n}\n" |
| 2512 | + "fn f :: {\n handle {\n g ()\n } with {\n ask -> resume 1,\n return x -> x,\n }\n}\n" |
| 2441 | 2513 | ), |
| 2442 | | − "fn f() {\n handle { g() } with {\n ask() -> resume(1)\n , return(x) -> x\n }\n}\n" |
| 2514 | + "fn f :: {\n handle { g () } with {\n ask -> resume 1\n , return x -> x\n }\n}\n" |
| 2443 | 2515 | ); |
| 2444 | 2516 | } |
| 2445 | 2517 | |
| @@ -2458,83 +2530,90 @@ mod tests { |
| 2458 | 2530 | |
| 2459 | 2531 | #[test] |
| 2460 | 2532 | fn effect_rows_hug_the_first_label() { |
| 2461 | | − let src = "fn f() -> Int / <io, fail | e> {\n 1\n}\n"; |
| 2533 | + let src = "fn f :: -> Int / <io, fail | e> {\n 1\n}\n"; |
| 2462 | 2534 | assert_eq!(fmt(src), src); |
| 2463 | 2535 | // A signature is one group: a long row moves the return type |
| 2464 | 2536 | // under the head, then the row breaks hugging its first label. |
| 2465 | 2537 | assert_eq!( |
| 2466 | | − narrow("fn f() -> Int / <io, fail, state<Int>, console, random | e> {\n 1\n}\n"), |
| 2467 | | − "fn f()\n -> Int /\n < io\n , fail\n , state<Int>\n , console\n , random\n | e\n > {\n 1\n}\n" |
| 2538 | + narrow("fn f :: -> Int / <io, fail, state<Int>, console, random | e> {\n 1\n}\n"), |
| 2539 | + "fn f ::\n -> Int /\n < io\n , fail\n , state<Int>\n , console\n , random\n | e\n > {\n 1\n}\n" |
| 2468 | 2540 | ); |
| 2469 | 2541 | } |
| 2470 | 2542 | |
| 2471 | 2543 | #[test] |
| 2472 | 2544 | fn if_stays_on_one_line_when_it_fits() { |
| 2473 | | − let src = "fn f(m) {\n if m { Ok(()) } else { Error(Wrong) }\n}\n"; |
| 2545 | + let src = "fn f :: m {\n if m { Ok(()) } else { Error(Wrong) }\n}\n"; |
| 2474 | 2546 | assert_eq!(fmt(src), src); |
| 2475 | 2547 | // When it does not fit, both branches break together. |
| 2476 | 2548 | assert_eq!( |
| 2477 | | − narrow("fn f(m) {\n if m { Ok(()) } else { Error(WrongPassword) }\n}\n"), |
| 2478 | | − "fn f(m) {\n if m {\n Ok(())\n } else {\n Error(WrongPassword)\n }\n}\n" |
| 2549 | + narrow("fn f :: m {\n if m { Ok(()) } else { Error(WrongPassword) }\n}\n"), |
| 2550 | + "fn f :: m {\n if m {\n Ok(())\n } else {\n Error(WrongPassword)\n }\n}\n" |
| 2479 | 2551 | ); |
| 2480 | 2552 | } |
| 2481 | 2553 | |
| 2482 | 2554 | #[test] |
| 2483 | | − fn signatures_move_under_their_head() { |
| 2555 | + fn signatures_stack_under_the_double_colon() { |
| 2556 | + // ADR 0061: a definition's signature is one group — it fits on |
| 2557 | + // one line, or breaks whole: the `::` holds the head line, the |
| 2558 | + // parameters stack one per line under it, then the return type |
| 2559 | + // and `where`. |
| 2484 | 2560 | assert_eq!( |
| 2485 | | − narrow("fn check(a: String, b: String) -> Result<(), E> / <users> {\n a\n}\n"), |
| 2486 | | − "fn check\n (a: String, b: String)\n -> Result<(), E> / <users> {\n a\n}\n" |
| 2561 | + narrow("fn check :: a: String b: String -> Result<(), E> / <users> {\n a\n}\n"), |
| 2562 | + "fn check ::\n a: String\n b: String\n -> Result<(), E> / <users> {\n a\n}\n" |
| 2487 | 2563 | ); |
| 2488 | | − // Longer still: the parameters break, then the row. |
| 2564 | + // Longer still: the row breaks for itself. |
| 2489 | 2565 | assert_eq!( |
| 2490 | 2566 | narrow( |
| 2491 | | − "fn check(a: String, b: String, c: String) -> Result<(), E> / <users, files> {\n a\n}\n" |
| 2567 | + "fn check :: a: String b: String c: String -> Result<(), E> / <users, files, console, random, blocking> {\n a\n}\n" |
| 2492 | 2568 | ), |
| 2493 | | − "fn check\n (a: String, b: String, c: String)\n -> Result<(), E> / <users, files> {\n a\n}\n" |
| 2569 | + "fn check ::\n a: String\n b: String\n c: String\n -> Result<(), E> /\n < users\n , files\n , console\n , random\n , blocking\n > {\n a\n}\n" |
| 2494 | 2570 | ); |
| 2495 | 2571 | assert_eq!( |
| 2496 | 2572 | narrow( |
| 2497 | | − "fn check(a_longer_parameter: String, another_longer: String) -> Int {\n a\n}\n" |
| 2573 | + "fn check :: a_longer_parameter: String another_longer: String -> Int {\n a\n}\n" |
| 2498 | 2574 | ), |
| 2499 | | − "fn check\n ( a_longer_parameter: String\n , another_longer: String\n )\n -> Int {\n a\n}\n" |
| 2575 | + "fn check ::\n a_longer_parameter: String\n another_longer: String\n -> Int {\n a\n}\n" |
| 2500 | 2576 | ); |
| 2501 | 2577 | } |
| 2502 | 2578 | |
| 2503 | 2579 | #[test] |
| 2504 | 2580 | fn comments_keep_their_place_and_force_breaks() { |
| 2505 | | − let src = "fn f() {\n // leading\n let x = 1 // trailing\n}\n"; |
| 2581 | + let src = "fn f :: {\n // leading\n let x = 1 // trailing\n}\n"; |
| 2506 | 2582 | assert_eq!(fmt(src), src); |
| 2507 | 2583 | // A comment after a call does not break it. |
| 2508 | 2584 | assert_eq!( |
| 2509 | | − fmt("fn f() {\n f([a, b]) // why\n}\n"), |
| 2510 | | − "fn f() {\n f([a, b]) // why\n}\n" |
| 2585 | + fmt("fn f :: {\n f [a, b] // why\n}\n"), |
| 2586 | + "fn f :: {\n f [a, b] // why\n}\n" |
| 2511 | 2587 | ); |
| 2512 | 2588 | // A comment inside a list breaks it, and everything around it. |
| 2513 | 2589 | assert_eq!( |
| 2514 | | − fmt("fn f() {\n f([a, // why\n b])\n}\n"), |
| 2515 | | − "fn f() {\n f( [ a // why\n , b\n ]\n )\n}\n" |
| 2590 | + fmt("fn f :: {\n f [a, // why\n b]\n}\n"), |
| 2591 | + "fn f :: {\n f\n [ a // why\n , b\n ]\n}\n" |
| 2516 | 2592 | ); |
| 2517 | 2593 | } |
| 2518 | 2594 | |
| 2519 | 2595 | #[test] |
| 2520 | 2596 | fn blank_lines_are_kept_up_to_one() { |
| 2521 | | − let src = "fn a() {}\n\n\n\nfn b() {}\n"; |
| 2522 | | − assert_eq!(fmt(src), "fn a() {}\n\nfn b() {}\n"); |
| 2597 | + let src = "fn a :: {}\n\n\n\nfn b :: {}\n"; |
| 2598 | + assert_eq!(fmt(src), "fn a :: {}\n\nfn b :: {}\n"); |
| 2523 | 2599 | } |
| 2524 | 2600 | |
| 2525 | 2601 | #[test] |
| 2526 | 2602 | fn strings_templates_and_html_are_verbatim() { |
| 2527 | | − let src = "fn f() {\n \"multi\n line string\"\n}\n"; |
| 2603 | + let src = "fn f :: {\n \"multi\n line string\"\n}\n"; |
| 2528 | 2604 | assert_eq!(fmt(src), src); |
| 2529 | | − let tpl = "fn f() {\n let page = pug`\n .card\n p Hello, {name}!\n `\n}\n"; |
| 2605 | + let tpl = "fn f :: {\n let page = pug`\n .card\n p Hello, {name}!\n `\n}\n"; |
| 2530 | 2606 | assert_eq!(fmt(tpl), tpl); |
| 2531 | | − let html = "fn f() {\n <div>\n <p>hi\n there</p>\n </div>\n}\n"; |
| 2607 | + let html = "fn f :: {\n <div>\n <p>hi\n there</p>\n </div>\n}\n"; |
| 2532 | 2608 | assert_eq!(fmt(html), html); |
| 2533 | 2609 | } |
| 2534 | 2610 | |
| 2535 | 2611 | #[test] |
| 2536 | 2612 | fn trailing_commas_in_lists_are_dropped() { |
| 2537 | | − assert_eq!(fmt("fn f() {\n f(a, b,)\n}\n"), "fn f() {\n f(a, b)\n}\n"); |
| 2613 | + assert_eq!( |
| 2614 | + fmt("fn f :: {\n f (a, b,)\n}\n"), |
| 2615 | + "fn f :: {\n f (a, b)\n}\n" |
| 2616 | + ); |
| 2538 | 2617 | } |
| 2539 | 2618 | |
| 2540 | 2619 | #[test] |
| @@ -2563,22 +2642,33 @@ mod tests { |
| 2563 | 2642 | #[test] |
| 2564 | 2643 | fn a_call_value_moves_under_the_let() { |
| 2565 | 2644 | assert_eq!( |
| 2566 | | − narrow("fn f() {\n let req = request(\"GETGET\", \"/path/path\", headers)\n}\n"), |
| 2567 | | − "fn f() {\n let req =\n request( \"GETGET\"\n , \"/path/path\"\n , headers\n )\n}\n" |
| 2645 | + narrow("fn f :: {\n let req = request \"GETGET\" \"/path/path\" headers\n}\n"), |
| 2646 | + "fn f :: {\n let req =\n request\n \"GETGET\"\n \"/path/path\"\n headers\n}\n" |
| 2568 | 2647 | ); |
| 2569 | 2648 | } |
| 2570 | 2649 | |
| 2571 | 2650 | #[test] |
| 2572 | 2651 | fn use_and_long_values() { |
| 2573 | | − let src = "fn f() {\n use a, b <- pairs(xs)\n a\n}\n"; |
| 2652 | + let src = "fn f :: {\n use a, b <- pairs xs\n a\n}\n"; |
| 2574 | 2653 | assert_eq!(fmt(src), src); |
| 2575 | 2654 | // No bindings: `use <-`. |
| 2576 | | − let bare = "fn f() {\n use <- spawn()\n 0\n}\n"; |
| 2655 | + let bare = "fn f :: {\n use <- spawn ()\n 0\n}\n"; |
| 2577 | 2656 | assert_eq!(fmt(bare), bare); |
| 2578 | 2657 | // Too long: the right-hand side moves under the `<-`. |
| 2579 | 2658 | assert_eq!( |
| 2580 | | − narrow("fn f() {\n use aaaaaaaaaa, bbbbbbbbbb <- pair(a, b)\n a\n}\n"), |
| 2581 | | − "fn f() {\n use aaaaaaaaaa, bbbbbbbbbb <-\n pair(a, b)\n a\n}\n" |
| 2659 | + narrow("fn f :: {\n use aaaaaaaaaa, bbbbbbbbbb <- pair aa bb\n a\n}\n"), |
| 2660 | + "fn f :: {\n use aaaaaaaaaa, bbbbbbbbbb <-\n pair aa bb\n a\n}\n" |
| 2582 | 2661 | ); |
| 2583 | 2662 | } |
| 2663 | + |
| 2664 | + #[test] |
| 2665 | + fn attributes_are_paren_free() { |
| 2666 | + let src = "@derive Eq Show\npub type User { User(name: String) }\n"; |
| 2667 | + assert_eq!(fmt(src), src); |
| 2668 | + let ext = "@extern c \"argon2id_hash_encoded\" blocking\nfn hash :: pw: String -> String / <ffi>\n"; |
| 2669 | + assert_eq!(fmt(ext), ext); |
| 2670 | + let nested = |
| 2671 | + "@extern c \"louise_k_map_each\" (blocking io)\nfn map_each :: f: fn(a) -> b -> Int\n"; |
| 2672 | + assert_eq!(fmt(nested), nested); |
| 2673 | + } |
| 2584 | 2674 | } |