Browse thread
Printing of polymorphic values in #trace
- Harrison, John R
[
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: | Harrison, John R <johnh@i...> |
| Subject: | Printing of polymorphic values in #trace |
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.