#line 671 "/home/travis/build/felix-lang/felix/src/packages/lists.fdoc"
  open class Assoc_list
  {
    typedef assoc_list[A,B] = List::list[A*B];
  
    // check is the key (left element) of a pair
    // satisfies the predicate
    fun mem[A,B] (eq:A -> bool) (xs:assoc_list[A,B]) : bool =>
      List::mem (fun (a:A, b:B) => eq a) xs;
    ;
  
    // check is the key (left element) of a pair
    // satisfies the relation to given element
    fun mem[A,B,T] (eq:A * T -> bool) (xs:assoc_list[A,B]) (e:T) : bool =>
      mem (fun (a:A) => eq(a, e)) xs;
    ;
  
    instance[A,B] Set[assoc_list[A,B], A] {
      fun mem[A,B with Eq[A]] (xs:assoc_list[A,B]) (e:A) : bool =>
        mem eq of (A * A) xs e
      ;
    }
  
    // find optionally the first value whose associate key satisfies
    // the given predicate
    fun find[A,B] (eq:A -> bool) (xs:assoc_list[A,B]) : opt[B] =>
      match xs with
      | #Empty => None[B]
      | Snoc (t,(a, b)) => if eq(a) then Some b else find eq t endif
      endmatch
    ;
  
    // find optionally the first value whose associate key (left slot)
    // satisfies the given relation to the given element (right slot)
    fun find[A,B,T] (eq:A * T -> bool) (xs:assoc_list[A,B]) (e:T) : opt[B] =>
      find (fun (a:A) => eq (a, e)) xs;
    ;
  
    fun find[A,B with Eq[A]] (xs:assoc_list[A,B]) (e:A) : opt[B] =>
      find eq of (A * A) xs e
    ;
  }