Repository: HigherOrderCO/Bend
File: src/term/net_to_term.rs (Rust)

Code before:
        Term::Lam { bod, .. } => go(bod, s, rd),
        Term::App { tag, arg, .. } if *tag == Tag::string_scons_head() => go(arg, s, rd),
        Term::App { fun, arg, .. } => {
          go(fun, s, rd);
          go(arg, s, rd);
        }
        Term::Var { .. } => {}
        Term::Chn { .. }
        | Term::Lnk { .. }
        | Term::Let { .. }
        | Term::Tup { .. }
        | Term::Dup { .. }
        | Term::Sup { .. }
        | Term::Str { .. }
        | Term::List { .. }
        | Term::Opx { .. }
        | Term::Match { .. }
        | Term::Ref { .. }
        | Term::Era => rd.error(ReadbackError::InvalidStrTerm),
      }
    }
    go(term, &mut s, self);
    Term::Str { val: s }
  }

  fn decode_list(&mut self, term: &mut Term) -> Term {
    let mut els = Vec::new();
    fn go(t: &mut Term, els: &mut Vec<Term>, rd: &mut Reader<'_>) {
      match t {
        Term::Lam { tag, bod, .. } if *tag == Tag::list() => go(bod, els, rd),
        Term::App { tag, arg, .. } if *tag == Tag::list_lcons_head() => {
          if let Term::Lam { tag, bod, .. } = &mut **arg {
            if *tag == Tag::list() {
              els.push(rd.decode_list(bod));
            } else {
              els.push(*arg.clone());
            }
          } else {
            go(arg, els, rd)
          }
        }
        Term::App { fun, arg, .. } => {
          go(fun, els, rd);
          go(arg, els, rd);
        }
        Term::Var { .. } => {}
        other => els.push(other.clone()),
      }
    }
    go(term, &mut els, self);
    Term::List { els }

Review comment (suggestion):
can you call it `resugar_list` and `resugar_str` to be like `resugar_adts` (which maybe should be `resugar_constructors`)

Code after:
        Term::Lam { bod, .. } => go(bod, s, rd),
        Term::App { tag, arg, .. } if *tag == Tag::string_scons_head() => go(arg, s, rd),
        Term::App { fun, arg, .. } => {
          go(fun, s, rd);
          go(arg, s, rd);
        }
        Term::Var { .. } => {}
        Term::Chn { .. }
        | Term::Lnk { .. }
        | Term::Let { .. }
        | Term::Tup { .. }
        | Term::Dup { .. }
        | Term::Sup { .. }
        | Term::Str { .. }
        | Term::List { .. }
        | Term::Opx { .. }
        | Term::Match { .. }
        | Term::Ref { .. }
        | Term::Era => rd.error(ReadbackError::InvalidStrTerm),
      }
    }
    go(term, &mut s, self);
    Term::Str { val: s }
  }

  fn resugar_list(&mut self, term: &mut Term) -> Term {
    let mut els = Vec::new();
    fn go(t: &mut Term, els: &mut Vec<Term>, rd: &mut Reader<'_>) {
      match t {
        Term::Lam { tag, bod, .. } if *tag == Tag::list() => go(bod, els, rd),
        Term::App { tag, arg, .. } if *tag == Tag::list_lcons_head() => {
          if let Term::Lam { tag, bod, .. } = &mut **arg {
            if *tag == Tag::list() {
              els.push(rd.resugar_list(bod));
            } else {
              els.push(*arg.clone());
            }
          } else {
            go(arg, els, rd)
          }
        }
        Term::App { fun, arg, .. } => {
          go(fun, els, rd);
          go(arg, els, rd);
        }
        Term::Var { .. } => {}
        other => els.push(other.clone()),
      }
    }
    go(term, &mut els, self);
    Term::List { els }