| Newsgroups |
gmane.comp.lang.ocaml.beginners |
| Message-ID |
<[email protected]> |
---In [email protected], <monnier.florent@...> wrote :
"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."
Well, actually the repository I linked to is my own fork of the official cohttp repository.
Thus, the type error is 100% my own :)
The question is, how do I fix it?
Jon
---In [email protected], <monnier.florent@...> wrote :
2014-09-09 10:42 UTC−07:00, loldrup@... mailto:loldrup@... [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)
>
> This is how I construct the value 'r' seen above:
> let (r,w) = Async.Std.Pipe.create ();;
>
> 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.
>
> My full code can be seen here:
> https://github.com/loldrup/ocaml-cohttp/blob/master/examples/async/hello_world.ml 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 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