Error in dev version of Real World OCaml, section "Example: Searching Definitions with DuckDuckGo"


#1

“Pipe.to_list” mentioned in the paragraph below, can’t be found anywhere in the code examples in this section of the book? Maybe the code examples changed without also updating the corresponding text in the book, or the other way around? Thanks for clarifying!

Quoted text:
“In this case, the HTTP body probably isn’t very large, so we call Pipe.to_list to collect the strings from the pipe as a single deferred list of strings. We then join those strings using String.concat and pass the result through our parsing function.”


#2

I think it’s referencing the example above, if you scroll up a bit, you should see the example as copied here

(* Execute the DuckDuckGo search *)
let get_definition word =
  Cohttp_async.Client.get (query_uri word)
  >>= fun (_, body) ->
  Pipe.to_list body
  >>| fun strings ->
  (word, get_definition_from_json (String.concat strings))

#3

Neither of you say which book you’re referring to.


#4

Whoops sorry - forgot to put that in my answer.

So it’s Chapter 18 in Real World OCaml.

(I actually found the chapter via Googling the quoted text, and meant to put the link in the answer, but forgot to.)


#5

It’s not in the v2 development version of the book:

https://dev.realworldocaml.org/concurrent-programming.html


#6

Thanks for the catch. The code got simplified to follow a change in Cohttp’s API, but the text wasn’t updated. I’ll do that.

y