123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051openCoreopenAsyncletread_charreader=match%mapReader.read_charreaderwith|`Okc->Okc|`Eof->Error`Connection_closedletread_stringreader=match%mapReader.read_linereaderwith|`Eof->Error`Connection_closed|`Oks->Oksletflush_linereader=read_stringreader|>Deferred.Result.map~f:ignoreletread_intreader=read_stringreader|>Deferred.Result.map~f:int_of_stringletread_bulk~lenreader=lets=Bytes.createleninmatch%mapReader.really_readreaderswith|`Eof_->Error`Connection_closed|`Ok->Ok(Bytes.to_strings)letrecread_respreader=letopenDeferred.Result.Let_syntaxinmatch%bindread_charreaderwith|'+'->read_stringreader|>Deferred.Result.map~f:(funs->Resp.Strings)|'-'->read_stringreader|>Deferred.Result.map~f:(funs->Resp.Errors)|':'->read_intreader|>Deferred.Result.map~f:(funi->Resp.Integeri)|'$'->(match%bindread_intreaderwith|-1->(* No extra newline *)returnResp.Null|len->let%binddata=read_bulk~lenreaderinlet%bind()=flush_linereaderinreturn(Resp.Bulkdata))|'*'->let%bindlength=read_intreaderinletrecinneracc=function|0->returnacc|n->let%bindelem=read_respreaderininner(elem::acc)(n-1)inlet%bindelements=inner[]lengthinreturn(Resp.Array(List.revelements))|unknown->Log.Global.debug"Unparseable type tag %C"unknown;Deferred.return@@Error`Unexpected