From: David Brown <caml@davidb.org>
To: caml-list@inria.fr
Subject: [Caml-list] Insufficient polymorphism in local let.
Date: Thu, 22 Mar 2012 21:58:18 -0700 [thread overview]
Message-ID: <20120323045817.GA26450@davidb.org> (raw)
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 }
next reply other threads:[~2012-03-23 4:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-23 4:58 David Brown [this message]
2012-03-23 5:12 ` Gabriel Scherer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120323045817.GA26450@davidb.org \
--to=caml@davidb.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).