Notation serialize_deserialize_id_spec s d :=
  (forall a bytes,
      ByteListReader.unwrap d (IOStreamWriter.unwrap (s a) ++ bytes) = Some(a, bytes)).(* This is the class of serializable types, which is the main entrypoint to
   Cheerios. Instances are required to show that `deserialize` can correctly
   recognize a piece of `serialize`d data at the prefix of an arbitrary
   bitstream. *)
Class Serializer (A : Type) : Type :=
  {
    serialize : A -> IOStreamWriter.t;
    deserialize : ByteListReader.t A;
    serialize_deserialize_id : serialize_deserialize_id_spec serialize deserialize
  }.(* This is the class of serializable types, which is the main entrypoint to
   Cheerios. Instances are required to show that `deserialize` can correctly
   recognize a piece of `serialize`d data at the prefix of an arbitrary
   bitstream. *)
Class Serializer (A : Type) : Type :=
  {
    serialize : A -> IOStreamWriter.t;
    deserialize : ByteListReader.t A;
    serialize_deserialize_id : serialize_deserialize_id_spec serialize deserialize
  }.(* This is the class of serializable types, which is the main entrypoint to
   Cheerios. Instances are required to show that `deserialize` can correctly
   recognize a piece of `serialize`d data at the prefix of an arbitrary
   bitstream. *)
Class Serializer (A : Type) : Type :=
  {
    serialize : A -> IOStreamWriter.t;
    deserialize : ByteListReader.t A;
    serialize_deserialize_id : serialize_deserialize_id_spec serialize deserialize
  }.(* This is the class of serializable types, which is the main entrypoint to
   Cheerios. Instances are required to show that `deserialize` can correctly
   recognize a piece of `serialize`d data at the prefix of an arbitrary
   bitstream. *)
Class Serializer (A : Type) : Type :=
  {
    serialize : A -> IOStreamWriter.t;
    deserialize : ByteListReader.t A;
    serialize_deserialize_id : serialize_deserialize_id_spec serialize deserialize
  }.

(* Specifications: *)
Lemma serialize_deserialize_id_nil : forall A (sA : Serializer A) a, ByteListReader.unwrap deserialize (IOStreamWriter.unwrap (serialize a)) = Some (a, []).