caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Printing of polymorphic values in #trace
@ 2006-05-02 17:48 Harrison, John R
  0 siblings, 0 replies; only message in thread
From: Harrison, John R @ 2006-05-02 17:48 UTC (permalink / raw)
  To: Caml list; +Cc: Harrison, John R

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-02 17:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-02 17:48 Printing of polymorphic values in #trace Harrison, John R

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).