[
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: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Polymorphic variant to string? |
On Wed, Nov 16, 2005 at 06:44:34PM +0000, Chris Campbell wrote: > Is there a general method for converting polymorphic variants to > strings? The method using camlp4 assumes the source is compiled with > it, which is not the case. Basically I want to print a list of > variants if a unit tests fail, so we can see exactly the contents of > the list at that point. You might want to try Std.dump in extlib. It only prints out the hash, but you can precalculate those given a list of variant names. rich@oirase:/tmp$ cat test.ml print_endline (Std.dump [ `Foo; `Bar; `Baz 123.0 ]) rich@oirase:/tmp$ ocamlfind ocamlc -package extlib test.ml -linkpkg -o test rich@oirase:/tmp$ ./test [3505894; 3303859; (3303867, 123.)] Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com