Can I override the Show instance for a template?
- georgOP 2
I want to define a custom Show instance for my template so that I can pass it directly to
debugand get pretty-printed output. Is there a way to override the default Show implementation? If not, what would a sensible workaround be? - cocreature 4
I don’t think you can override it at the moment. I’d also generally recommend against doing so. It’s very convenient if
showproduces 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 -> Textand then instead ofdebugusetrace: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.