caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* format polymorphism
@ 2006-08-06 23:33 Christophe TROESTLER
  2006-08-09  7:42 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe TROESTLER @ 2006-08-06 23:33 UTC (permalink / raw)
  To: O'Caml Mailing List

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-09 22:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-06 23:33 format polymorphism Christophe TROESTLER
2006-08-09  7:42 ` [Caml-list] " Jacques Garrigue
2006-08-09 22:51   ` [Caml-list] format polymorphism & campl4 Christophe TROESTLER

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).