Codec for a list of T
s, tagged with the string list
.
Create an identical codec which adds (or expects, respectively) an additional top-level tag.
Create an identical codec which adds (or expects, respectively) an additional top-level tag.
The given tag can be anything acceptable as an XML attribute value, but should be globally unique. That is, no other codec should have the same tag. It is fine if there are multiple codecs for a type, as long as their tags are distinct, although that is not a requirement.
Transform a codec for a type T
into a codec for a type U
by applying
one of the two specified conversions.
Transform a codec for a type T
into a codec for a type U
by applying
one of the two specified conversions.
After creating a new instance using transform
, it is recommended to add
a new tag.
Codec for a pair of T
and U
, tagged with the string tuple
.
A type class representing the ability to convert a type to and from an XML representation.
For combinators to create codecs, refer to the companion object.
Contract
Instances of this class must satisfy the following contract: Decoding any value produced via
encode
must succeed, yielding the original value. ThemlType
field must contain a string representation of the corresponding type in Isabelle/ML.For the opposite direction, it is generally expected that a value which cannot be produced via
encode
should not decode cleanly. This is generally achieved by adding tags to the trees. For example, if the codec for typeFoo
for a given value would produce an XML documentt
before tagging, the XML document after tagging would be<tag name="foo">t</tag>
. Thetagged
method transforms a raw codec into a tagged codec. Nested tags are allowed (for example, when chaining multiple calls oftagged
), but produce additional overhead in the resulting XML documents.