News for hackers. Stuff that matters.
Re:OCaml Programming: Correct and Efficient and Beautiful by Mk2000 on Sunday July 27, 2025 @09:16AM (#44701117)
I really like Ocaml, but the error handling is very bad, some libraries use Option/Result, some use exceptions, the inconsistency makes it a little hard to work with. I much prefer Rust in this regard.
Re:OCaml Programming: Correct and Efficient and Beautiful by mbac32768 on Monday July 28, 2025 @09:59AM (#44710945)
doesn't the Rust ecosystem also inconsistently mix Option and Result?

anyway, it's a fairly trivial wrapper to handle the odd annoying thing that raises

Option.try_with (fun () -> thing_that_exns ())

Result.try_with (fun () -> thing_that_exns ())

(it would be nice if you could tell if something raises by the type signature somehow though)