caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ken Wakita <wakita@is.titech.ac.jp>
To: Cezary Kaliszyk <ck189400@zodiac.mimuw.edu.pl>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] format type
Date: Mon, 04 Nov 2002 13:00:06 +0900	[thread overview]
Message-ID: <B9EC1FD6.11DA2%wakita@is.titech.ac.jp> (raw)
In-Reply-To: <20021103070858.GB24702@zodiac.mimuw.edu.pl>


Did you try "%t"?

Printf.printf "%t": (out_channel -> unit) -> unit = <fun>

You could simply ignore out_channel if you are not interested.

Ken Wakita

> From: Cezary Kaliszyk <ck189400@zodiac.mimuw.edu.pl>
> Date: Sun, 3 Nov 2002 08:08:58 +0100
> To: caml-list@inria.fr
> Subject: [Caml-list] format type
> 
> I'm trying to write a function that takes a format and a function and
> applies some (got from elsewere) arguments to the function.
> 
> All works ok for nonempty format.
> Ie: 
> myfun "%c%s"
> is of type:
> (char -> string -> unit) -> unit
> 
> IS IT POSSIBLE (with the current implementation) of the format type type
> checking to pass some format that would require a (unit -> unit)
> function?
> 
> Ie: I'd like:
> myfun ""
> to be of type:
> (unit -> unit) -> unit
> 
> If such construnction is not possible at all perheapes some new
> identifier "%?" should be added to fromat type type checking. This
> argument would take exacly one argument of type unit.
> 
> My current implementation:
> 
> let receive (fmt : (('a, unit, unit) format)) (f : 'a) : unit =
> let fmt_str = string_of_format fmt in
> let rec parse f i =
>   match fmt.[i] with
>     ...
>       I call recursively:
>         parse (lazified ((forced f) with applied arg)) (i + 1)
>     ...
> in
> Obj.magic (parse (fun () -> f) 0) ()
> ;;
> 
> The only known workaround for me for now is to pass "%t" and
> make my function not (unit -> unit) but ('a -> unit).
> 
> Writing code with changed types just for the sake of the language is
> very bad. And with "%t" 'a seems to be (unit -> unit).
> 
> Cezary Kaliszyk
> -- 
> 

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


  reply	other threads:[~2002-11-04  4:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-03  7:08 Cezary Kaliszyk
2002-11-04  4:00 ` Ken Wakita [this message]
2002-11-04  7:54   ` Alessandro Baretta
2002-11-04 11:03     ` Cezary Kaliszyk
2002-11-04 11:56       ` Alessandro Baretta

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=B9EC1FD6.11DA2%wakita@is.titech.ac.jp \
    --to=wakita@is.titech.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=ck189400@zodiac.mimuw.edu.pl \
    /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).