From: Jiten Pathy <jpathy@fssrv.net>
To: John F Carr <jfc@mit.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] format strings
Date: Mon, 9 Feb 2015 08:28:09 -0800 [thread overview]
Message-ID: <CAL2Z3DC9A=mSzUDdhSxE_r2332BgHs=uUje9DW1uTKLbr4O4Jw@mail.gmail.com> (raw)
In-Reply-To: <F2D475AF-E374-4C34-B476-68A7ACDDB26B@exchange.mit.edu>
[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]
Right. what confuses me is, how the format type has 'a -> 'b instead of 'a.
On Feb 9, 2015 4:25 AM, "John F Carr" <jfc@mit.edu> wrote:
> Your wrapper returns a function. Type ‘a, the argument to that function,
> is determined by the first %-conversion in the format string. The function
> returns type ‘b. If your format argument has one %-conversion, type ‘b
> will be a string. If it has more than one, type ‘b will be a function
> accepting the remaining arguments.
>
> # let g = f “%d %d”;;
> val g : int -> int -> string = <fun>
> # let h = g 0;;
> val h : int -> string = <fun>
> # h 1;;
> - : string = "0 1"
>
> In the past partial application of printf family functions hasn’t worked
> well, so test before relying on behavior of the returned function.
>
> > On Feb 9, 2015, at 06:58 , Jiten Pathy <jpathy@fssrv.net> wrote:
> >
> > When i define a wrapper around format functions like
> >
> > let f s = (fun x -> Printf.sprintf s x);;
> >
> > val f : ('a -> 'b, unit, bytes) format -> 'a -> 'b = <fun>
> >
> > I am confused about the inferred type. where does this 'b comes from?
> >
> > --
> > Caml-list mailing list. Subscription management and archives:
> > https://sympa.inria.fr/sympa/arc/caml-list
> > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> > Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
[-- Attachment #2: Type: text/html, Size: 2060 bytes --]
next prev parent reply other threads:[~2015-02-09 16:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-09 11:58 Jiten Pathy
2015-02-09 12:25 ` John F Carr
2015-02-09 16:28 ` Jiten Pathy [this message]
2015-02-09 17:32 ` David Allsopp
2015-02-10 1:05 ` Jiten Pathy
2015-02-10 2:47 ` Jiten Pathy
2015-02-10 7:44 ` David Allsopp
2015-02-10 7:55 ` Jiten Pathy
2015-02-10 8:25 ` David Allsopp
2015-02-10 8:34 ` Jiten Pathy
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='CAL2Z3DC9A=mSzUDdhSxE_r2332BgHs=uUje9DW1uTKLbr4O4Jw@mail.gmail.com' \
--to=jpathy@fssrv.net \
--cc=caml-list@inria.fr \
--cc=jfc@mit.edu \
/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