Cuihtlauac
cuihtlauac.bsky.social
Cuihtlauac
@cuihtlauac.bsky.social
Corecursive tinkerer, camler, globetrotter
February 4, 2025 at 4:13 PM
let ( >>= ) = Lwt.bind
let ( let* ) = Lwt.bind

(* Prints hello after world *)
let _ = f "hello" () >>= f "world"

(* Prints world after hello *)
let _ = let* u = f "hello" () in f "world" u

Can you write f? What's going on?
#ocaml #lwt
January 23, 2025 at 6:36 AM
#ocaml binding operator abuse

let ( let< ) ic f =
Fun.protect ~finally:(fun () -> In_channel.close ic) (fun () -> f ic)

let () =
let< ic = In_channel.open_text Sys.argv.(1) in
In_channel.input_lines ic
|> List.concat_map (String.split_on_char ' ')
|> List.iter print_string
January 15, 2025 at 10:12 AM