Skip to content
CCPEDIAby Unity Nodes
App Development

Can I override the Show instance for a template?

2 posts340 views6 likesLast activity Oct 2021

  1. georgOP 2

    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. 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 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.