makeUnionCodec = (selectCodecForRead, selectCodecForWrite) => {
  /**
   * @param {SyrupReader} syrupReader
   * @returns {SyrupCodec}
   */
  const read = syrupReader => {
    const codec = selectCodecForRead(syrupReader);
    return codec.read(syrupReader);
  };
  /**
   * @param {any} value
   * @param {SyrupWriter} syrupWriter
   */
  const write = (value, syrupWriter) => {
    const codec = selectCodecForWrite(value);
    codec.write(value, syrupWriter);
  };
  return freeze({ read, write });
}
@param {function(SyrupReader): SyrupCodec} selectCodecForRead
@param {function(any): SyrupCodec} selectCodecForWrite
@returns {SyrupCodec}