caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe TROESTLER <Christophe.Troestler@umh.ac.be>
To: "O'Caml Mailing List" <caml-list@inria.fr>
Subject: format polymorphism
Date: Mon, 07 Aug 2006 01:33:12 +0200 (CEST)	[thread overview]
Message-ID: <20060807.013312.243185382.Christophe.Troestler@umh.ac.be> (raw)

Hi,

Could someone tell me why, say "%s", is of type

  'a. (string -> 'b, 'a, 'b) format

instead of

  'a 'b. (string -> 'b, 'a, 'b) format

I am asking this because if one wants to use the same format string
both for reading and printing in a given function, one needs the
latter type:

  type 'a fmt = { fmt: 'b 'c. ('a,'b,'c) format }
  fun  (s: _ fmt) -> Printf.printf s.fmt, Scanf.sscanf "string" s.fm

However, I cannot instantiate the type [_ fmt].  This is in contrast
with

  let s = ("%s": (_,_,_) format) in
  Printf.printf s, Scanf.sscanf "string" s

which works as intended.  I think this may have been discussed before;
I just can't remember the reason.  Also, is there a safe way of using
Obj.magic to make it work ?

Regards,
ChriS


             reply	other threads:[~2006-08-06 23:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-06 23:33 Christophe TROESTLER [this message]
2006-08-09  7:42 ` [Caml-list] " Jacques Garrigue
2006-08-09 22:51   ` [Caml-list] format polymorphism & campl4 Christophe TROESTLER

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=20060807.013312.243185382.Christophe.Troestler@umh.ac.be \
    --to=christophe.troestler@umh.ac.be \
    --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).