caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Cezary Kaliszyk <ck189400@zodiac.mimuw.edu.pl>
To: caml-list@inria.fr
Subject: [Caml-list] format type
Date: Sun, 3 Nov 2002 08:08:58 +0100	[thread overview]
Message-ID: <20021103070858.GB24702@zodiac.mimuw.edu.pl> (raw)

[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

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

[-- Attachment #2: Type: application/pgp-signature, Size: 254 bytes --]

             reply	other threads:[~2002-11-03 10:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-03  7:08 Cezary Kaliszyk [this message]
2002-11-04  4:00 ` Ken Wakita
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=20021103070858.GB24702@zodiac.mimuw.edu.pl \
    --to=ck189400@zodiac.mimuw.edu.pl \
    --cc=caml-list@inria.fr \
    /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).