Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (37 sloc) 1.416 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 include Format
19
20 type 'a pprinter = Format.formatter -> 'a -> unit
21
22 let pp = Format.fprintf
23
24 let pp_fmt fmt = (fun oc -> Format.fprintf oc fmt)
25
26 let pp_fst pp fmt (a, _) = pp fmt a
27 let pp_snd pp fmt (_, b) = pp fmt b
28
29 let pp_list sep ?singleton p f l =
30 match l with
31 | [] -> ()
32 | h :: t ->
33 (match singleton, t with Some p, [] -> p f h | _ -> p f h);
34 let rec aux = function
35 | [] -> ()
36 | h :: t -> pp f sep; p f h; aux t in
37 aux t
38
39 let sprintf fmt =
40 Format.kfprintf (fun _ -> Format.flush_str_formatter ()) Format.str_formatter fmt
41
42 let ksprintf k fmt =
43 let k _ =
44 let s = Format.flush_str_formatter () in
45 k s
46 in
47 Format.kfprintf k Format.str_formatter fmt
48
49 let to_string pp a = FBuffer.sprintf "%a" pp a
Something went wrong with that request. Please try again.