Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] format type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ken Wakita <wakita@i...>
Subject: Re: [Caml-list] format type

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