caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] format type
@ 2002-11-03  7:08 Cezary Kaliszyk
  2002-11-04  4:00 ` Ken Wakita
  0 siblings, 1 reply; 5+ messages in thread
From: Cezary Kaliszyk @ 2002-11-03  7:08 UTC (permalink / raw)
  To: caml-list

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-11-05  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03  7:08 [Caml-list] format type Cezary Kaliszyk
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

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