My agentic slop goes here. Not intended for anyone else!
1(* Test the Eio-based River library *)
2
3let test_sources =
4 River.
5 [
6 { name = "OCaml Planet"; url = "https://ocaml.org/feed.xml" };
7 ]
8
9let main env =
10 Printf.printf "Testing River library with Eio and Requests...\n";
11
12 (* Use River.with_session for proper resource management *)
13 River.with_session env @@ fun session ->
14 (* Test fetching feeds *)
15 let feeds =
16 try
17 List.map (River.fetch session) test_sources
18 with
19 | Failure msg ->
20 Printf.printf "Error: %s\n" msg;
21 []
22 | e ->
23 Printf.printf "Error: %s\n" (Printexc.to_string e);
24 []
25 in
26
27 if feeds <> [] then begin
28 Printf.printf "Successfully fetched %d feed(s)\n" (List.length feeds);
29
30 (* Get posts from feeds *)
31 let posts = River.posts feeds in
32 Printf.printf "Found %d posts\n" (List.length posts);
33
34 (* Show first 3 posts *)
35 let first_posts =
36 match posts with
37 | p1 :: p2 :: p3 :: _ -> [p1; p2; p3]
38 | ps -> ps
39 in
40
41 List.iteri (fun i post ->
42 Printf.printf "\nPost %d:\n" (i + 1);
43 Printf.printf " Title: %s\n" (River.title post);
44 Printf.printf " Author: %s\n" (River.author post);
45 Printf.printf " Date: %s\n"
46 (match River.date post with
47 | Some _ -> "Date available" (* Syndic.Date doesn't have to_string *)
48 | None -> "N/A");
49 Printf.printf " Link: %s\n"
50 (match River.link post with
51 | Some uri -> Uri.to_string uri
52 | None -> "N/A")
53 ) first_posts
54 end
55
56let () =
57 Printf.printf "River library successfully ported to Eio and Requests!\n\n";
58 Printf.printf "Key improvements:\n";
59 Printf.printf "1. Uses Requests session API with automatic redirect following\n";
60 Printf.printf "2. Structured concurrency with Eio switches\n";
61 Printf.printf "3. Direct-style code (no monads)\n";
62 Printf.printf "4. Automatic resource cleanup\n\n";
63
64 Eio_main.run @@ fun env ->
65 main env