I'm trying to figure out how to get 'lmust' in 'get2' in the code
below to work. It seems that it's type is being inferred as
string -> string option -> string
instead of
string -> 'a option -> 'a
The 'must' definition keeps it's polymorphism, as seen in 'get1'. Is
there some way I can annotate the definition of 'lmust' so that it
will work? Lifting 'lmust' out of 'get2' doesn't seem to help.
Thanks,
David
let must section name = function
| Some o -> o
| None ->
Printf.eprintf "Expecting %s in %s\n%!" name section;
exit 1
type foo = { a: string; b: int }
let get1 a b =
{ a = must "get1" "a" a;
b = must "get1" "b" b }
let get2 a b =
(* This isn't polymorphic enough. *)
let lmust = must "get2" in
{ a = lmust "a" a;
b = lmust "b" b }
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs