let switch l =
let default = ref None in
let cases =
List.filter_map l ~f:(function
| `Default d when !default <> None ->
failwith "Cannot build switch with >1 defaults"
| `Default d -> default := (Some d); None
| `Case t -> Some t)
in
make_switch ~default:(Option.value ~default:nop !default) cases