I want to define a custom Show instance for my template so that I can pass it directly to debug
and get pretty-printed output. Is there a way to override the default Show implementation? If not, what would a sensible workaround be?
2 Likes
I don’t think you can override it at the moment. I’d also generally recommend against doing so. It’s very convenient if show
produces a valid Daml expression or at least something very close to it.
What you can do instead is to define a function of type pretty : YourTemplate -> Text
and then instead of debug
use trace
:
trace (pretty yourTemplate) (pure ())
If someone wants to add traceM : Action m => Text -> m ()
to make this a bit more convenient, I’ll gladly accept a PR.
4 Likes