Skip to content

Commit

Permalink
Pretty print letrec
Browse files Browse the repository at this point in the history
  • Loading branch information
Kmeakin committed Jan 30, 2023
1 parent e417c62 commit 6de0471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions fathom/src/surface/distillation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ impl<'interner, 'arena, 'env> Context<'interner, 'arena, 'env> {
match core_term {
core::Term::ItemVar(_span, var) => match self.get_item_name(*var) {
Some(name) => Term::Name((), name),
None => todo!("misbound variable"), // TODO: error?
None => todo!("unbound item variable: `{var:?}`"), // TODO: error?
},
core::Term::LocalVar(_span, var) => match self.get_local_name(*var) {
Some(name) => Term::Name((), name),
None => todo!("misbound variable"), // TODO: error?
None => todo!("unbound local variable: `{var:?}`"), // TODO: error?
},
core::Term::MetaVar(_span, var) => match self.get_hole_name(*var) {
Some(name) => Term::Hole((), name),
Expand Down
14 changes: 8 additions & 6 deletions fathom/src/surface/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,20 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
self.concat([
self.text("let"),
self.space(),
self.ann_pattern(&def.pattern, def.r#type.as_ref()),
self.space(),
self.text("="),
self.softline(),
self.term(&def.expr),
self.let_def(def),
self.text(";"),
])
.group(),
self.line(),
self.term(body_expr),
]),
Term::Letrec(_, _, _) => todo!(),
Term::Letrec(_, defs, body_expr) => self.sequence(
false,
self.concat([self.text("letrec"), self.space()]),
defs.iter().map(|def| self.let_def(def)),
self.text(","),
self.concat([self.text(";"), self.line(), self.term(body_expr)]),
),
Term::If(_, cond_expr, then_expr, mut else_expr) => {
let mut branches = Vec::new();

Expand Down

0 comments on commit 6de0471

Please sign in to comment.