Skip to content

Commit

Permalink
feat: Bump version of pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jun 27, 2017
1 parent 68b3bb9 commit 29808fc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
41 changes: 27 additions & 14 deletions base/src/pretty_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn pretty_pattern<'a, Id>(arena: &'a Arena<'a>,
chain![arena;
field.0.as_ref(),
",",
arena.newline()
arena.space()
]
})),
arena.concat(fields.iter().map(|field| {
Expand All @@ -38,21 +38,32 @@ pub fn pretty_pattern<'a, Id>(arena: &'a Arena<'a>,
" = ",
pretty_pattern(arena, new_name),
",",
arena.newline()
arena.space()
]
}
None => {
chain![arena;
field.0.as_ref(),
",",
arena.newline()
arena.space()
]
}
}
})),
"}"
]
}
Pattern::Tuple { ref elems, .. } => {
chain![arena;
"(",
arena.concat(elems
.iter()
.map(|elem| pretty_pattern(arena, elem))
.intersperse(arena.text(",").append(arena.space()))
),
")"
]
}
}
}

Expand Down Expand Up @@ -119,14 +130,14 @@ pub fn pretty_expr<'a, Id>(arena: &'a Arena<'a>, expr: &'a Expr<Id>) -> DocBuild
ref typ => arena.text(": ").append(pretty_type(arena, typ)),
},
"=",
arena.newline()
arena.space()
.append(pretty(&bind.expr))
.group(),
arena.newline()
].group().nest(INDENT)
})),
"in",
arena.newline(),
arena.space(),
pretty(body)
]
}
Expand All @@ -150,7 +161,7 @@ pub fn pretty_expr<'a, Id>(arena: &'a Arena<'a>, expr: &'a Expr<Id>) -> DocBuild
"| ",
pretty_pattern(arena, &alt.pattern),
" ->",
arena.newline(),
arena.space(),
pretty(&alt.expr).group().nest(INDENT),
arena.newline()
]
Expand All @@ -171,7 +182,7 @@ pub fn pretty_expr<'a, Id>(arena: &'a Arena<'a>, expr: &'a Expr<Id>) -> DocBuild
chain![arena;
field.name.as_ref(),
",",
arena.newline()
arena.space()
]
})),
arena.concat(exprs.iter().map(|field| {
Expand All @@ -181,22 +192,22 @@ pub fn pretty_expr<'a, Id>(arena: &'a Arena<'a>, expr: &'a Expr<Id>) -> DocBuild
Some(ref expr) => {
chain![arena;
" =",
arena.newline(),
arena.space(),
pretty(&expr)
]
},
None => arena.nil(),
},
",",
arena.newline()
arena.space()
]
})),
"}"
]
}
Expr::Tuple(ref exprs) => {
Expr::Tuple{ ref elems, .. } => {
arena.text("(")
.append(arena.concat(exprs.iter().map(|elem| pretty(elem).append(", "))))
.append(arena.concat(elems.iter().map(|elem| pretty(elem).append(", "))))
.append(")")
.group()
}
Expand All @@ -211,14 +222,16 @@ pub fn pretty_expr<'a, Id>(arena: &'a Arena<'a>, expr: &'a Expr<Id>) -> DocBuild
arena.text(arg.id.as_ref()).append(" ")
})),
"=",
arena.space()
.append(pretty_type(arena, &bind.alias.unresolved_type()))
.group(),
arena.newline()
.append(pretty_type(arena, &bind.alias.unresolved_type()))
.group()
].group().nest(INDENT)
})),
arena.newline(),
arena.space(),
"in",
arena.newline(),
arena.space(),
pretty(body)
]
}
Expand Down
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gluon_base = { path = "../base", version = "0.4.2" } # GLUON

[dev-dependencies]
collect-mac = "0.1.0"
pretty = "0.1.0"
pretty = { version = "0.2.0", git = "https://github.com/Marwes/pretty.rs" }
pretty_assertions = "0.2.0"

[build-dependencies]
Expand Down

0 comments on commit 29808fc

Please sign in to comment.