semantic_versions.ml
let of_string input =
try
Scanf.sscanf input "%u.%u.%u-%s" (fun v1 v2 v3 v4 -> (v1, v2, v3, Some v4))
with _ -> Scanf.sscanf input "%u.%u.%u" (fun v1 v2 v3 -> (v1, v2, v3, None))
let to_string (v1, v2, v3, v4) =
match v4 with
| None -> Printf.sprintf "%u.%u.%u" v1 v2 v3
| Some s -> Printf.sprintf "%u.%u.%u-%s" v1 v2 v3 s