On 14/04/2008, at 9:22 PM, pepe wrote:
Alternatively, with some effort one can create a type-agnostic
version of unsafeShow, which would print things in a more raw
format, but probably sufficient anyway. I don't think it would work
with unboxed values in general, although it can be made to work
with the standard types. Actually, Bernie Pope wrote some code for
this [1, see GHC Heap Printing library] some time ago, although
with the new primitives and changes made for :print in GHC 6.8,
this would be way easier nowadays. No need to use StablePtrs, no
need to turn on profiling, and above all, no C needed :)
And as a bonus this would work out of GHCi too.
Yes, an almost-universal printer would be possible now that we have
data constructor names attached to info tables.
I'd sort of planned to do that, and then got side-tracked.
Of course, this won't be able to print functions in any helpful way,
unless we attach source code information to
functions as well (which may be worth doing anyway?).
One thing to watch out for is cycles in data structures. You may not
want to try to detect them, but at least you should
be lazy in generating the printable representation of values.
And then there is the question of whether to evaluate thunks during
Perhaps such a printer would also be useful for the GHCi debugger in
cases where it can't infer the right types?
Haskell-Cafe mailing list