ml - Are there other ways to deconstruct option types in OCaml? -
ocaml's alternative type useful in cases have functions might not homecoming anything. when utilize in many places, find cumbersome handle some
case , none
case time in match ... with
.
for example,
let env2 = list.map (fun ((it,ie),v,t) -> match t | t -> (v,t) | none -> begin match | -> (v,it) | none -> failwith "cannot infer local vars" end) ls_res in
are there other ways deconstruct alternative type in concise manner?
for simple cases, can match several things @ once:
match t, | t, _ -> (v, t) | none, -> (v, it) | none, none -> failwith "cannot infer local vars"
this time. i'm told compiler build (it doesn't generate pair).
ocaml ml code-readability
No comments:
Post a Comment