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.

Lemma option_serialize_deserialize_id :
serialize_deserialize_id_spec option_serialize option_deserialize.