Re: Type error: `Eof isn't the same as `Eof ?

"Florent Monnier [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAE1DttBJ0vhbLsbJNao5ro0XPa1Ld8VXiHbac0TvP1reUtQZKA@mail.gmail.com>
2014-09-09 10:42 UTC−07:00, [email protected] [ocaml_beginners] wrote:
> I have this code that tries to log the output of a pipe:
>
>
>    Async.Std.print_string (match (Async.Std.Pipe.read r) with
>                            | `Eof -> "an empty string"
>                            | `Ok text -> text)
>
>
>
>  However, I get this type error when compiling:
>
>
>  File "hello_world.ml", line 57, characters 29-33:
> Error: This pattern matches values of type [? `Eof ]
>        but a pattern was expected which matches values of type
>          [ `Eof | `Ok of string ] Async_conduit.io
>
>
>
>  Should I qualify these `Eof and `Ok somehow?
>
>
>
>  What I am trying to do is to log the content of the body of a POST request.
> The body content is to be salvaged through a pipe.
>
>
>  The full code can be seen here:
>
> https://github.com/loldrup/ocaml-cohttp/blob/master/examples/async/hello_world.ml

If I look at the documentation online for the function Async.Std.Pipe.read:

https://ocaml.janestreet.com/ocaml-core/111.28.00/doc/async/#Std.Pipe

I see that its signature is:
val read : ?consumer:Consumer.t -> 'a Reader.t -> [ `Eof | `Ok of 'a ]
Deferred.t

Indeed the returned type is not [ `Eof | `Ok of 'a ] , the API of
asunc probably changed since this hello-world was written.

So either you raise an issue on the github page of ocaml-cohttp,
either you send them a patch.

Florent
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.