Just wondering if there are any guarantees provided by the Daml language/platform regarding the stability of the formats used by show instances when generating Text
serialisations of datatypes between SDKs? Is this something we can rely on across SDK upgrades, or where we care about format stability, should we be abstracting away from Show
to allow room to accomodate any future change?
It’s safe to assume that the invariants listed under class Show will continue to hold. I don’t think anyone should count on the exact details of the format not changing.
Broadly speaking, the output of Show
is meant to be a transient format, rather than one for permanent storage. That said, if you have a parser that can deal with variation in the categories that documentation mentions–whitespace, parenthesization, fixity–then it’s probably good enough, albeit somewhat inefficient.
Slightly extending Stephen’s answer.
We provide a strong guarantee of stability for Show instance formatting for the builtin types (namely Int
, Numeric
, BigNumeric
, Text
, Bool
, Party
, Date
, and Time
). We really try hard to maintain stability of the standard library including the formatting for the other types, but we cannot guarantee that we will never change it in the future. It is worth noting that any such changes would be considered as breaking, and as such clearly marked in the SDK’s CHANGELOGs.
In general, we strongly discourage relying on the Show instance formatting (except for builtin types). The general purpose of the instance is to provide human-readable representation of a data and not to provide a proper serialization format. To serialize general data, we advice the user to define their own format, relying on Show instance for the builtin types only.