Closed phadej closed 1 year ago
Related: https://github.com/input-output-hk/plutus/issues/3164
Dumping arbitrary values is not easy, we'd need an on-chain Show class, along with showing builtins for all the builtin types. It would be easy to accidentally incur a dependency on Show, which would bring in a lot of bulky code (since it will have lots of strings in it). So while this would be nice, it's quite a lot of work and I'd be a little concerned about using it...
we'd need an on-chain Show class,
I don't think so. I'll be perfectly fine with emulator dumping some version of internal representation. Definitely not Show
, that would be expensive/slow. trace
is for debugging. Having something closer to anythingToString
then `show. If it's
trace :: a -> b -> b -- no restriction on a
Then Plutus won't be able to observe how values are serialized, and that is completely fine.
What are the semantics of that? I don't want to add something that exposes the innards in a non-principled way. Then we can't change the implementation! If we could make it available only off-chain that might work, but at the moment we don't have an easy way of doing that.
AFAIK on-chain cannot expect the trace
d messages now either. From the formalization perspective the traced messages could be PLC-values (instead of Text
). I haven't looked at the formalization, so I don't know what you do now. I think even having a subclass of Maybe Text
as traced messages would be enough to ensure ordering of trace messages (as if textual traces are ordered, then by parametricity of trace
all other messages are too).
Currently trace can dump only
Text
values. That is very limiting. Allowing to dump arbitrary values (includingData
)
@zliu41 @michaelpj given #4777 our current answer seems to be "won't do"? Could you remind me why this PR was closed?
We're also working on a debugger which will probably alleviate the need for a polymorphic version of trace
.
We added the PlutusTx.Show
class last year so I think this issue can be closed.
PlutusTx.Show
does not require new builtins. All instances can be written using existing stuff.And yes, Show
is expensive. A production script is supposed to have trace
removed via remove-trace
.
Great, thanks a lot.
Currently
trace
can dump onlyText
values. That is very limiting. Allowing to dump arbitrary values (includingData
) would be very helpful for print-style debugging.