Skip to content

format6

Weng Shiwei edited this page Jan 8, 2021 · 27 revisions
Value or type Note 'a 'b 'c 'd 'e 'f rest type
Definitions
format6 'a 'b 'c 'd 'e 'f
format ('a, 'b, 'c, 'c) format4` 'a 'b 'c 'c 'c 'c
format4 ('a, 'b, 'c, 'c, 'c, 'd) format6 'a 'b 'c 'c 'c 'd
Scanf.scanner ('a, Scanf.Scanning.scanbuf, 'b, 'c, 'a -> 'd, 'd) format6 -> 'c 'a scanbuf 'b 'c 'a -> 'd 'd 'c
Manual
Printf
Scanf
Format
Paper 'functional_type = 'argument_sequence -> 'result_type 'low_level_device 'poly_printer_result 'poly_reader_functional_type = 'poly_reader_sequence -> 'poly_reader_result 'poly_reader_result 'result_type
Printf where 'argument_sequence is the type of sequence of arguments to print or value to read a polymorphic pretty-printer, which prints value of 't has type 'low_level_device -> 't -> 'poly_printer_result %a or %t n/a n/a the result type of printf-like functions
Scanf 'functional_type is also the type of receiver function a polymorphic reader, which reads value of 't has type 'low_level_device -> 't n/a 'poly_reader_sequence is the type of sequence of polymorphic readers required by all the %r the result type of 'poly_reader_functional_type the result type of the receiver function for scanf-like functions
Examples fmt omit CamlinternalFormatBasics for simplicity
("%d" : _ format6) Format (Int (Int_d, No_padding, No_precision, End_of_format), "%d") int -> 'a 'b 'c 'd 'd 'a
("%d %d" : _ format6) Format (Int (Int_d, No_padding, No_precision, Char_literal ( , Int (Int_d, No_padding, No_precision, End_of_format))), "%d %d") int -> int -> 'a 'b 'c 'd 'd 'a
("%a" : _ format6) Format (Alpha End_of_format, "%a") ('a -> 'b -> 'c) -> 'b -> 'd 'a 'c 'e 'e 'd
("%a %a" : _ format6) Format (Alpha (Char_literal ( , Alpha End_of_format)), "%a %a") ('a -> 'b -> 'c) -> 'b -> ('a -> 'd -> 'c) -> 'd -> 'e 'a 'c 'f 'f 'e
("%r" : _ format6) Format (Reader End_of_format, "%r") 'a -> 'b 'c 'd ('c -> 'a) -> 'e 'e 'b
("%r %r" : _ format6) Format (Reader (Char_literal ( , Reader End_of_format)), "%r %r") 'a -> 'b -> 'c 'd 'e ('d -> 'a) -> ('d -> 'b) -> 'f 'f 'c
Scanf.sscanf string -> ('a, 'b, 'c, 'd) Scanf.scanner
Scanf.scanner ('a, Scanf.Scanning.scanbuf, 'b, 'c, 'a -> 'd, 'd) format6 -> 'c 'a scanbuf 'b 'c 'a -> 'd 'd 'c
"%d %d" let fmt = format_of_string "%d %d" in let _ = Scanf.sscanf "1 2" fmt (fun x y -> x = y) in fmt int -> int -> bool scanbuf '_weak1 (int -> int -> bool) -> bool (int -> int -> bool) -> bool bool
"%r %r" let fmt = format_of_string "%r %r" in let _ = Scanf.sscanf "f1 b1" fmt scan_foo scan_bar (fun x y -> true) in fmt" in let _ = Scanf.sscanf "1 2" fmt (fun x y -> x = y) in fmt int -> int -> bool scanbuf '_weak1 (int -> int -> bool) -> bool (int -> int -> bool) -> bool bool

Clone this wiki locally