From: Richard Jones <rich@annexia.org>
To: Chris Campbell <cyberdanx@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Polymorphic variant to string?
Date: Thu, 17 Nov 2005 13:44:45 +0000 [thread overview]
Message-ID: <20051117134445.GA19578@furbychan.cocan.org> (raw)
In-Reply-To: <c22844d10511161044v4fb3a4b6i@mail.gmail.com>
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
prev parent reply other threads:[~2005-11-17 13:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-16 18:44 Chris Campbell
2005-11-16 21:29 ` [Caml-list] " Jacques Garrigue
2005-11-17 13:44 ` Richard Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051117134445.GA19578@furbychan.cocan.org \
--to=rich@annexia.org \
--cc=caml-list@yquem.inria.fr \
--cc=cyberdanx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox