Add an `of_string` function to simplify the construction from OCaml values.