Things you didn't know you could do in OCaml!
Did you know you could do these in OCaml?
match int_of_string n with
| exception _ -> ...
| _ -> ...
You can catch exceptions as if they were patterns in match expressions.
Also, remember you can locally open modules? If it’s just a line or two you could instead of, for instance
let f =
let open List in
init 10 Fun.id |> rev
do this
let f =
List.(init 10 Fun.id |> rev)
It doesn’t just work this way. You can also do this with lists,
arrays, and inside of records. Here’s an example using the arbitrary
precision numbers module Z
[| Z.zero; Z.one |]
versus
Z.[| zero; one |]
Cool. If you’ve got suggesions, or other interesting OCaml syntax, feel free to contact my email and I surely add them to this list.