From: "Richard W.M. Jones" <rich@annexia.org>
To: caml-list@inria.fr
Subject: [Caml-list] Returning printf from a function
Date: Thu, 23 Aug 2018 10:15:52 +0100 [thread overview]
Message-ID: <20180823091552.vq5oizsushwfivgz@annexia.org> (raw)
This is a problem we hit from time to time and I don't think I've ever
really understood why it happens. This made up example shows the
essence:
----------------------------------------------------------------------
let get_printer out =
if out then Printf.printf else Printf.fprintf stderr
let () =
let printer = get_printer true in
printer "hello\n";
printer "goodbye %s\n" "everyone" (* line 7 *)
----------------------------------------------------------------------
$ ocamlopt test2.ml
File "test2.ml", line 7, characters 2-9:
Error: This function has type (unit, out_channel, unit) format -> unit
It is applied to too many arguments; maybe you forgot a `;'.
Type inference in line 6 seems to overspecify the inferred type of
printer, so that we get the error on line 7.
Why? And how to fix it?
Rich.
next reply other threads:[~2018-08-23 9:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-23 9:15 Richard W.M. Jones [this message]
2018-08-23 9:28 ` Florian Angeletti
2018-08-23 9:48 ` Richard W.M. Jones
2018-08-23 10:08 ` Florian Angeletti
2018-08-23 10:23 ` Richard W.M. Jones
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=20180823091552.vq5oizsushwfivgz@annexia.org \
--to=rich@annexia.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