#line 1090 "/home/travis/build/felix-lang/felix/src/packages/lists.fdoc"
  class S_expr
  {
    union sexpr[T] = Leaf of T | Tree of list[sexpr[T]];
  
    fun fold_left[T,U] (_f:U->T->U) (init:U) (x:sexpr[T]):U =>
      match x with
      | Leaf a => _f init a
      | Tree b => List::fold_left (S_expr::fold_left _f) init b
    ;
  
    proc iter[T] (_f:T->void) (x:sexpr[T]) {
      match x with
      | Leaf a => _f a;
      | Tree b => List::iter (S_expr::iter _f) b;
      endmatch;
    }
  
    fun map[T,U] (_f:T->U) (x:sexpr[T]):sexpr[U] =>
      match x with
      | Leaf a => Leaf (_f a)
      | Tree b => Tree ( List::map (S_expr::map _f) b )
    ;
  
    instance[T with Eq[T]] Set[sexpr[T],T] {
      fun \(\in\) (elt:T, x:sexpr[T]) =>
        fold_left (fun (acc:bool) (v:T) => acc or v == elt) false x;
    }
    instance[T with Str[T]] Str[sexpr[T]] {
      noinline fun str(x:sexpr[T])=>
        match x with
        | Leaf a => str a
        | Tree b => str b
      ;
    }
  
  }
  
  open[T with Str[T]] Str[S_expr::sexpr[T]];
  open[T with Eq[T]] Set[S_expr::sexpr[T],T];