From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 5CC427F6CB for ; Mon, 9 Feb 2015 17:28:10 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jpathy@fssrv.net) identity=pra; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="jpathy@fssrv.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jpathy@fssrv.net designates 209.85.212.173 as permitted sender) identity=mailfrom; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="jpathy@fssrv.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f173.google.com) identity=helo; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jpathy@fssrv.net"; x-sender="postmaster@mail-wi0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DyAQB839hUlK3UVdFcDoNKWgSCfrAfjW6BYAEJhXECgRIHQwEBAQEBARABAQEBBwsLCRIwhAwBAQEDARIRBBkBASwLAQQLCwQHDQ0dAgIiEgEFAQoSBhMSEId3AwkIDaVkPjGKPnCEYgEFizsDhToBAQEBAQEBAQIBAQEBAQEBAQEBAREGCo9qBAeCLTsRgTGEVQqFTYhEhVyBGDaNZIF0EiOBFYIhH4ETXh0xgkIBAQE X-IPAS-Result: A0DyAQB839hUlK3UVdFcDoNKWgSCfrAfjW6BYAEJhXECgRIHQwEBAQEBARABAQEBBwsLCRIwhAwBAQEDARIRBBkBASwLAQQLCwQHDQ0dAgIiEgEFAQoSBhMSEId3AwkIDaVkPjGKPnCEYgEFizsDhToBAQEBAQEBAQIBAQEBAQEBAQEBAREGCo9qBAeCLTsRgTGEVQqFTYhEhVyBGDaNZIF0EiOBFYIhH4ETXh0xgkIBAQE X-IronPort-AV: E=Sophos;i="5.09,544,1418079600"; d="scan'208";a="120962501" Received: from mail-wi0-f173.google.com ([209.85.212.173]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Feb 2015 17:28:09 +0100 Received: by mail-wi0-f173.google.com with SMTP id bs8so5374516wib.0 for ; Mon, 09 Feb 2015 08:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fssrv.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kVcOZ+1CTx3HHiQH935Y7nTPCp+7plB9oYGQ/BaRJBQ=; b=cXJwZwMXJvMOtzNlsuySKRuLNkpF60GZJElg2CVQUGtCuhAOp9iKdTliN/JtgjJSv3 CX4L7gxCK9Z3qdHtcAjGURQtdeC2WvzROLkB9dw1zKajvlg1RIcBiW1unZD0c1eo5T8c wt4NaCvGfph1dJo1nNpNc1fQQssZsIm835oZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=kVcOZ+1CTx3HHiQH935Y7nTPCp+7plB9oYGQ/BaRJBQ=; b=EKRHU5FJ4UQb2joMJfVwxwyDiemaDKsEmp2jJ1AhQd1LyEdZET2LQ8+y1JBdgkuOMc uY6Ksq+9JRKiVHup381YA0j1SujZfBGvLH1UfQPNIOkxP08Im8lTd/UyYuee45dHmhJF KlOcHET15CMQoKtKKdUgKgp1s2bzSmwx4SeAsIGCvZlhCUZDPsyent2yroPJuzgdqYEJ TNWmc8tX2lZ1u7iwEEZhIRXCgdoIBRAs7JkRzqH+vh6p6bOnwqaQjrV3Rb/uS79cJ52c Ln3TMVS7JbIiFJMLuL+sNv9UBdZRQmnv4vyxktmYYOLy/mNmztjqu1XLBEQCZGt2+yAj Mn8w== X-Gm-Message-State: ALoCoQm4szGi50GLqQx74VnWvU1sOvrWWCjwla6YXt81hoChmBe9ftnfrmCDFAdp4t42SKrgvX92 MIME-Version: 1.0 X-Received: by 10.180.92.199 with SMTP id co7mr37441762wib.47.1423499289595; Mon, 09 Feb 2015 08:28:09 -0800 (PST) Received: by 10.27.226.67 with HTTP; Mon, 9 Feb 2015 08:28:09 -0800 (PST) Received: by 10.27.226.67 with HTTP; Mon, 9 Feb 2015 08:28:09 -0800 (PST) In-Reply-To: References: Date: Mon, 9 Feb 2015 08:28:09 -0800 Message-ID: From: Jiten Pathy To: John F Carr Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=f46d043c07767ea8c0050eaa411b Subject: Re: [Caml-list] format strings --f46d043c07767ea8c0050eaa411b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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" wrote: > Your wrapper returns a function. Type =E2=80=98a, the argument to that f= unction, > is determined by the first %-conversion in the format string. The functi= on > returns type =E2=80=98b. If your format argument has one %-conversion, t= ype =E2=80=98b > will be a string. If it has more than one, type =E2=80=98b will be a fun= ction > accepting the remaining arguments. > > # let g =3D f =E2=80=9C%d %d=E2=80=9D;; > val g : int -> int -> string =3D > # let h =3D g 0;; > val h : int -> string =3D > # h 1;; > - : string =3D "0 1" > > In the past partial application of printf family functions hasn=E2=80=99t= worked > well, so test before relying on behavior of the returned function. > > > On Feb 9, 2015, at 06:58 , Jiten Pathy wrote: > > > > When i define a wrapper around format functions like > > > > let f s =3D (fun x -> Printf.sprintf s x);; > > > > val f : ('a -> 'b, unit, bytes) format -> 'a -> 'b =3D > > > > 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 > > --f46d043c07767ea8c0050eaa411b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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.= =C2=A0 Type =E2=80=98a, the argument to that function, is determined by the= first %-conversion in the format string.=C2=A0 The function returns type = =E2=80=98b.=C2=A0 If your format argument has one %-conversion, type =E2=80= =98b will be a string.=C2=A0 If it has more than one, type =E2=80=98b will = be a function accepting the remaining arguments.

# let g =3D f =E2=80=9C%d %d=E2=80=9D;;
val g : int -> int -> string =3D <fun>
# let h =3D g 0;;
val h : int -> string =3D <fun>
# h 1;;
- : string =3D "0 1"

In the past partial application of printf family functions hasn=E2=80=99t w= orked 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 =3D (fun x -> Printf.sprintf s x);;
>
> val f : ('a -> 'b, unit, bytes) format -> 'a -> &= #39;b =3D <fun>
>
> I am confused about the inferred type. where does this 'b comes fr= om?
>
> --
> Caml-list mailing list.=C2=A0 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

--f46d043c07767ea8c0050eaa411b--