Require Vector String.
(* These functions are either missing obvious implicits, or have implicit arguments that are not marked "maximally inserted", which means they cannot easily be used with map or fmap. *)
Arguments Some {_} _.
Arguments cons {_} _ _.
Arguments option_map {_ _} _ _.
Arguments Vector.nil {_}.
Arguments Vector.cons {_} _ {_} _.
(* This section gives instances for various type constructors, including pairs and lists. *)
Section BasicCombinators.
Variables A B : Type.
Variable sA : Serializer A.
Variable sB : Serializer B.
Definition option_serialize (x : option A) : IOStreamWriter.t :=
match x with
| Some a => IOStreamWriter.append (fun _ => serialize true)
(fun _ => serialize a)
| None => serialize false
end.
Definition option_deserialize : ByteListReader.t (option A) :=
b <- deserialize ;;
match b with
| true => Some <$> deserialize
| false => ByteListReader.ret None
end.

(* Specifications: *)
Lemma option_serialize_deserialize_id :
serialize_deserialize_id_spec option_serialize option_deserialize.