From: "Harrison, John R" <johnh@ichips.intel.com>
To: "Caml list" <caml-list@inria.fr>
Cc: "Harrison, John R" <johnh@ichips.intel.com>
Subject: Printing of polymorphic values in #trace
Date: Tue, 2 May 2006 10:48:38 -0700 [thread overview]
Message-ID: <196F1D996F92CD46A542EA519DB8CE4703A2DD07@orsmsx409> (raw)
I wanted to suggest a little change to tracing. I can imagine that this
might be hard, depending on what type information is available at
certain times. But if it's moderately easy I think it would be worth the
effort.
When displaying the input and output values for a function, OCaml seems
to use the most general types, and therefore polymorphic functions often
fail to print anything useful. For example:
$ ocaml
Objective Caml version 3.08.2
# let identity x = x;;
val identity : 'a -> 'a = <fun>
# #trace identity;;
identity is now traced.
# identity 1;;
identity <-- <poly>
identity --> <poly>
- : int = 1
If on the other hand I explicitly constrain the type of "identity", I
get the effect I want:
# let identity (x:int) = x;;
val identity : int -> int = <fun>
# #trace identity;;
identity is now traced.
# identity 1;;
identity <-- 1
identity --> 1
- : int = 1
It would be nice if OCaml did this automatically, since the type
of the instance actually used is the same in each case.
John.
reply other threads:[~2006-05-02 17:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=196F1D996F92CD46A542EA519DB8CE4703A2DD07@orsmsx409 \
--to=johnh@ichips.intel.com \
--cc=caml-list@inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).