#line 1134 "/home/travis/build/felix-lang/felix/src/packages/lists.fdoc"
  class LS_expr
  {
    union lsexpr[T,L] = | Leaf of T | Tree of L * list[lsexpr[T,L]];
  
    fun fold_left[T,L,U] (_f:U->T->U) (_g:U->L->U) (init:U) (x:lsexpr[T,L]):U =>
      match x with
      | Leaf a => _f init a
      | Tree (a,b) => List::fold_left (LS_expr::fold_left _f _g) (_g init a) b
    ;
  
    proc iter[T,L] (_f:T->void) (_g:L->void) (x:lsexpr[T,L]) {
      match x with
      | Leaf a => _f a;
      | Tree (a,b) => _g a; List::iter (LS_expr::iter _f _g) b;
      endmatch;
    }
  
    fun map[T,L,U,V] (_f:T->U) (_g:L->V) (x:lsexpr[T,L]):lsexpr[U,V] =>
      match x with
      | Leaf a => Leaf[U,V] (_f a)
      | Tree (a,b) => Tree ( _g a, List::map (LS_expr::map _f _g) b )
    ;
  
    instance[T,L with Str[T], Str[L]] Str[lsexpr[T,L]] {
      noinline fun str(x:lsexpr[T,L])=>
        match x with
        | Leaf a => str a
        | Tree (a,b) => str a + "(" + str b  + ")"
      ;
    }
  
  }
  
  open[T,L with Str[T], Str[L]] Str[LS_expr::lsexpr[T,L]];