Browse thread
[Caml-list] Format
- Vasilij Karpow
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Vasilij Karpow <malc@b...> |
| Subject: | [Caml-list] Format |
I wonder if anyone can teach me properly outputing values of following type: type sexp = | Slist of (string * lsexp) | Satts of lsexp | Sbody of lsexp | Sattr of (string * string) | Sdata of string and lsexp = sexp list. Even default(and hence dumb) interactive ocaml toplevel printer does it better than my own attempts of abusing Format. let rec print_sexp pff = function | Slist (n, l) -> fprintf pff "@ @,@[<1>(%s %a)@]" n print_lsexp l | Sbody b -> print_lsexp pff b | Satts a -> fprintf pff "@[(%a)@]" print_lsexp a | Sattr (n, a) -> fprintf pff "@[%s: \"%s\"@ @]" n (attr_value a) | Sdata s -> fprintf pff "@ \"%s\"" (String.escaped s) and print_lsexp pff l = List.iter (print_sexp pff) l I must confess though, i do not fully understand what im doing here. So please anyone. P.S. Oh btw. this is NOT an assignment ;) -- mailto:malc@boblycat.com ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr