We need Eq to use RequiredVersion in tests. And we need ToJSON for
structured logging.
The current Show instance was custom and doesn't render a valid
Haskell syntax, which is an anti-pattern. The reason for this is that
the requiredVersionCompare member was itself a function, so we
couldn't just derive a stockShow. By removing that member, and
instead holding a new RequiredVersionOp enumeration that can be
converted to it, we can now derive stockEq and Show. The new
requiredVersionOpToText and requiredVersionOpCompare functions will
need to be kept in sync, but I don't see them changing very frequently
(and we have great tests here).
We retain the more human-readable format in the new ToJSON instance,
because we need it in FromJSON (to parse Yaml correctly) and it must
of course round-trip with ToJSON.
https://app.asana.com/0/13211253278157/1203652238195585/f
We need
Eq
to useRequiredVersion
in tests. And we needToJSON
for structured logging.The current
Show
instance was custom and doesn't render a valid Haskell syntax, which is an anti-pattern. The reason for this is that therequiredVersionCompare
member was itself a function, so we couldn't just derive astock
Show
. By removing that member, and instead holding a newRequiredVersionOp
enumeration that can be converted to it, we can now derivestock
Eq
andShow
. The newrequiredVersionOpToText
andrequiredVersionOpCompare
functions will need to be kept in sync, but I don't see them changing very frequently (and we have great tests here).We retain the more human-readable format in the new
ToJSON
instance, because we need it inFromJSON
(to parse Yaml correctly) and it must of course round-trip withToJSON
.