From: "David J. Trombley" <swampy@spacebird.net>
To: "Olivier Andrieu" <andrieu@ijm.jussieu.fr>
Cc: <caml-list@inria.fr>, <hmaon@bumba.net>
Subject: Re: [Caml-list] format4 query
Date: Wed, 19 May 2004 12:13:32 -0400 [thread overview]
Message-ID: <006f01c43dbc$4642deb0$10015c0a@word> (raw)
In-Reply-To: <20040519.092218.74745648.oandrieu@nerim.net>
Right, as I said I can get simple examples to work. But I
can't get syntax such as
# let g (l : listener) (k : int) fmt =
match k with
0 -> 0
| x -> Printf.kprintf l fmt; k;;
val g : listener -> int -> ('a, unit, string, unit)
format4 -> int = <fun>
to function, as you can see the format type has been
inferred to a type that is not useful at all.
I'd like to use kprintf as a side effect to a function which
evaluates to some type, but I would not like that type or
the unit type of a ; evaluation to affect the format type.
-dj
----- Original Message -----
From: "Olivier Andrieu" <andrieu@ijm.jussieu.fr>
To: <swampy@spacebird.net>
Cc: <caml-list@inria.fr>; <hmaon@bumba.net>
Sent: Wednesday, May 19, 2004 3:22 AM
Subject: Re: [Caml-list] format4 query
> David J. Trombley [Wed, 19 May 2004]:
> >
> > Suppose I have
> >
> > type listener = string -> unit
> >
> > which is intended to receive a string type as a value.
> >
> > Could someone demonstrate a function that takes a
listener
> > and a format as arguments, and uses sprintf to obtain a
> > string, and then calls the listener with the string
> > argument?
>
> That is precisely what kprintf does.
>
> # type listener = string -> unit;;
> type listener = string -> unit
> # let f (l : listener) fmt = Printf.kprintf l fmt ;;
> val f : listener -> ('a, unit, string, unit) format4 -> 'a
= <fun>
> # f print_endline "%s %d" "abc" 23 ;;
> abc 23
> - : unit = ()
>
> --
> Olivier
>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-05-19 16:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-19 6:15 David J. Trombley
2004-05-19 7:22 ` Olivier Andrieu
2004-05-19 16:13 ` David J. Trombley [this message]
2004-05-19 17:20 ` Damien Doligez
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='006f01c43dbc$4642deb0$10015c0a@word' \
--to=swampy@spacebird.net \
--cc=andrieu@ijm.jussieu.fr \
--cc=caml-list@inria.fr \
--cc=hmaon@bumba.net \
/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