import preserves, std/tables, std/options type PCompoundKind* {.pure.} = enum `rec`, `arr`, `dict` PCompoundRec* {.preservesRecord: "rec".} = object `label`*: Value `fields`*: seq[Pattern] PCompoundArr* {.preservesRecord: "arr".} = object `items`*: seq[Pattern] PCompoundDict* {.preservesRecord: "dict".} = object `entries`*: Table[Value, Pattern] `PCompound`* {.preservesOr.} = object case orKind*: PCompoundKind of PCompoundKind.`rec`: `rec`*: PCompoundRec of PCompoundKind.`arr`: `arr`*: PCompoundArr of PCompoundKind.`dict`: `dict`*: PCompoundDict Reject* {.preservesRecord: "reject".} = object `pattern`*: Pattern CaveatsFieldKind* {.pure.} = enum `present`, `invalid`, `absent` CaveatsFieldPresent* {.preservesDictionary.} = object `caveats`*: seq[Caveat] CaveatsFieldInvalid* {.preservesDictionary.} = object `caveats`*: Value CaveatsFieldAbsent* {.preservesDictionary.} = object `CaveatsField`* {.preservesOr.} = object case orKind*: CaveatsFieldKind of CaveatsFieldKind.`present`: `present`*: CaveatsFieldPresent of CaveatsFieldKind.`invalid`: `invalid`*: CaveatsFieldInvalid of CaveatsFieldKind.`absent`: `absent`*: CaveatsFieldAbsent SturdyDescriptionDetail* {.preservesDictionary.} = object `key`*: seq[byte] `oid`*: Value PAnd* {.preservesRecord: "and".} = object `patterns`*: seq[Pattern] SturdyStepDetail* = Parameters Rewrite* {.preservesRecord: "rewrite".} = object `pattern`*: Pattern `template`*: Template ParametersCaveats* = Option[Value] ParametersOid* = Value ParametersSig* = seq[byte] `Parameters`* {.preservesDictionary.} = object `caveats`*: Option[Value] `oid`*: Value `sig`*: seq[byte] TRef* {.preservesRecord: "ref".} = object `binding`*: BiggestInt PBind* {.preservesRecord: "bind".} = object `pattern`*: Pattern Lit* {.preservesRecord: "lit".} = object `value`*: Value TCompoundKind* {.pure.} = enum `rec`, `arr`, `dict` TCompoundRec* {.preservesRecord: "rec".} = object `label`*: Value `fields`*: seq[Template] TCompoundArr* {.preservesRecord: "arr".} = object `items`*: seq[Template] TCompoundDict* {.preservesRecord: "dict".} = object `entries`*: Table[Value, Template] `TCompound`* {.preservesOr.} = object case orKind*: TCompoundKind of TCompoundKind.`rec`: `rec`*: TCompoundRec of TCompoundKind.`arr`: `arr`*: TCompoundArr of TCompoundKind.`dict`: `dict`*: TCompoundDict SturdyPathStepDetail* = Parameters `PAtom`* {.preservesOr, pure.} = enum `Boolean`, `Double`, `SignedInteger`, `String`, `ByteString`, `Symbol` PDiscard* {.preservesRecord: "_".} = object TemplateKind* {.pure.} = enum `TAttenuate`, `TRef`, `Lit`, `TCompound` `Template`* {.acyclic, preservesOr.} = ref object case orKind*: TemplateKind of TemplateKind.`TAttenuate`: `tattenuate`*: TAttenuate of TemplateKind.`TRef`: `tref`*: TRef of TemplateKind.`Lit`: `lit`*: Lit of TemplateKind.`TCompound`: `tcompound`*: TCompound CaveatKind* {.pure.} = enum `Rewrite`, `Alts`, `Reject`, `unknown` `Caveat`* {.preservesOr.} = object case orKind*: CaveatKind of CaveatKind.`Rewrite`: `rewrite`*: Rewrite of CaveatKind.`Alts`: `alts`*: Alts of CaveatKind.`Reject`: `reject`*: Reject of CaveatKind.`unknown`: `unknown`*: Value PNot* {.preservesRecord: "not".} = object `pattern`*: Pattern SturdyRef* {.preservesRecord: "ref".} = object `parameters`*: Parameters WireRefKind* {.pure.} = enum `mine`, `yours` WireRefMine* {.preservesTuple.} = object `field0`* {.preservesLiteral: "0".}: tuple[] `oid`*: Oid WireRefYours* {.preservesTuple.} = object `field0`* {.preservesLiteral: "1".}: tuple[] `oid`*: Oid `attenuation`* {.preservesTupleTail.}: seq[Caveat] `WireRef`* {.preservesOr.} = object case orKind*: WireRefKind of WireRefKind.`mine`: `mine`*: WireRefMine of WireRefKind.`yours`: `yours`*: WireRefYours TAttenuate* {.preservesRecord: "attenuate".} = object `template`*: Template `attenuation`*: seq[Caveat] Oid* = BiggestInt Alts* {.preservesRecord: "or".} = object `alternatives`*: seq[Rewrite] PatternKind* {.pure.} = enum `PDiscard`, `PAtom`, `PEmbedded`, `PBind`, `PAnd`, `PNot`, `Lit`, `PCompound` `Pattern`* {.acyclic, preservesOr.} = ref object case orKind*: PatternKind of PatternKind.`PDiscard`: `pdiscard`*: PDiscard of PatternKind.`PAtom`: `patom`*: PAtom of PatternKind.`PEmbedded`: `pembedded`* {.preservesLiteral: "Embedded".}: bool of PatternKind.`PBind`: `pbind`*: PBind of PatternKind.`PAnd`: `pand`*: PAnd of PatternKind.`PNot`: `pnot`*: PNot of PatternKind.`Lit`: `lit`*: Lit of PatternKind.`PCompound`: `pcompound`*: PCompound proc `$`*(x: PCompound | Reject | CaveatsField | SturdyDescriptionDetail | PAnd | SturdyStepDetail | Rewrite | Parameters | TRef | PBind | Lit | TCompound | SturdyPathStepDetail | PDiscard | Template | Caveat | PNot | SturdyRef | WireRef | TAttenuate | Oid | Alts | Pattern): string = `$`(toPreserves(x)) proc encode*(x: PCompound | Reject | CaveatsField | SturdyDescriptionDetail | PAnd | SturdyStepDetail | Rewrite | Parameters | TRef | PBind | Lit | TCompound | SturdyPathStepDetail | PDiscard | Template | Caveat | PNot | SturdyRef | WireRef | TAttenuate | Oid | Alts | Pattern): seq[byte] = encode(toPreserves(x))