Instance bool_Serializer : Serializer bool.

Lemma fold_append_unwrap' : forall {S A : Type} (f : byte -> S -> fold_state S A) (s : S) (b : byte) (tail : IOStreamWriter.t) (bin : list byte), ByteListReader.unwrap (ByteListReader.fold f s) (IOStreamWriter.unwrap (IOStreamWriter.append (fun _ => IOStreamWriter.putByte b) (fun _ => tail)) ++ bin) = match f b s with | Done a => Some(a, IOStreamWriter.unwrap tail ++ bin) | More s => ByteListReader.unwrap (ByteListReader.fold f s) (IOStreamWriter.unwrap tail ++ bin) | Error => None end.