packages feed

hydra-ext (empty) → 0.17.0

raw patch · 59 files changed

+23426/−0 lines, 59 filesdep +basedep +bytestringdep +containers

Dependencies added: base, bytestring, containers, hydra-kernel, hydra-rdf, scientific

Files

+ CHANGELOG.md view
@@ -0,0 +1,1372 @@+# Hydra changelog++All notable changes to the Hydra project are documented in this file.++This changelog tracks changes across all Hydra implementations+(Haskell, Java, Python, Scala, TypeScript, Clojure, Common Lisp, Emacs Lisp, Scheme)+and supporting infrastructure.++The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)+and [Apache TinkerPop](https://github.com/apache/tinkerpop/blob/master/CHANGELOG.asciidoc).++Pre-1.0 versions are listed below.+Untagged versions correspond to in-repository version bumps that were not pushed as Git tags or Hackage releases;+they are documented here for completeness.++---++## [0.17.0] - 2026-07-01++Major themes: first-class support for effects and I/O in the kernel, TypeScript and+Scala reaching publishable parity with the other hosts, and continued maturation of+the published-host build model.++### Highlights++- **Effects and I/O** ([#286](https://github.com/CategoricalData/hydra/issues/286),+  [#288](https://github.com/CategoricalData/hydra/issues/288),+  [#494](https://github.com/CategoricalData/hydra/issues/494)): a new `effect` variant+  on `hydra.core.Type` for representing effectful computations; new kernel modules+  `hydra.file` (`FilePath`, `FileType`, `FileStatus`, `FileExtension`), `hydra.time`+  (`Timespec`), and `hydra.error.file`; new primitive libraries `hydra.lib.effects`,+  `hydra.lib.files`, and `hydra.lib.text` with byte-level I/O; and a new+  `EffectfulTestCase` mechanism so the common test suite can exercise effectful+  primitives across hosts.+- **TypeScript is a complete implementation**+  ([#462](https://github.com/CategoricalData/hydra/issues/462)): self-hosts and passes+  the common test suite, with a per-package npm publish pipeline+  ([#492](https://github.com/CategoricalData/hydra/issues/492)).+- **Scala publishing**: per-package Maven Central publish infrastructure+  ([#491](https://github.com/CategoricalData/hydra/issues/491)).+- **Published-host build model**: published mode now compiles the kernel from the+  co-generated `dist/haskell` rather than Hackage, removing the need for a+  `haskell=local` shim ([#500](https://github.com/CategoricalData/hydra/issues/500));+  the oil-and-water principle and cold-build workflow for `dist/haskell` are documented+  ([#376](https://github.com/CategoricalData/hydra/issues/376)).+- **Kernel hygiene**: `uniqueLabel` (apostrophe suffixes) replaced by `chooseUniqueLabel`+  (numeric suffixes) in `hydra.names`+  ([#436](https://github.com/CategoricalData/hydra/issues/436)).++### Implementations++Eight hosts self-host and pass the common test suite across five families: Haskell,+Java, Python, Scala, and the four Lisp dialects (Clojure, Common Lisp, Scheme, Emacs+Lisp), with TypeScript now joining as a complete host/target. Go remains a "head bud"+(the coder still has emission bugs and the head's runtime is largely placeholder; it+does not yet host the test suite).++### New Features++- Translingual cross-reference convention for `doc` strings: doc-escape tags render to+  each host's native doc syntax (Javadoc, Haddock, Sphinx, TSDoc)+  ([#433](https://github.com/CategoricalData/hydra/issues/433)).+- Neo4j JSON-artifact validation demo, exercised across Java, Python, Haskell, and+  TypeScript ([#510](https://github.com/CategoricalData/hydra/issues/510)).++### Improvements++- The Java/Maven publish set now covers every official Hydra target language, one coder+  package per implementation family+  ([#468](https://github.com/CategoricalData/hydra/issues/468)).+- JVM Maven artifact groups are bifurcated to `net.fortytwo.hydra.java` and+  `net.fortytwo.hydra.scala`, so the Java and Scala (and future Clojure) publish sets+  never collide on coordinates+  ([#519](https://github.com/CategoricalData/hydra/issues/519)).+- Host-specific third-party integrations (the former `bindings/` tree) are folded into+  `overlay/`, unifying hand-written host-native source under one tree+  ([#511](https://github.com/CategoricalData/hydra/issues/511)).+- The coder de-parameterizes context and error types, simplifying generated coder+  signatures ([#518](https://github.com/CategoricalData/hydra/issues/518)).+- TypeScript-to-Java generation now emits the `hydra.lib.*` aggregate namespace+  interfaces (`Maps`, `Strings`, etc.)+  ([#499](https://github.com/CategoricalData/hydra/issues/499)).++---++## [0.16.1] - 2026-06-16++Major themes: the first release built by bootstrapping from previously published+packages, the first full 9 × 9 cross-implementation bootstrapping sweep, and+published-package self-containment fixes for the artifacts that bootstrap rests on.++### Highlights++- **Bootstrap from published packages**: the build links the published 0.16.0 hosts+  (Hackage / Maven Central / PyPI) and uses them to build the next version of Hydra,+  resting on 0.16.0's forward-compatibility guarantees — the published-host consume+  model with a `--local-host` shim, used for the first time in a release+  ([#370](https://github.com/CategoricalData/hydra/issues/370)). 0.16.1 still builds+  against **local** Haskell and Python hosts (`hostOverrides`), because the published+  0.16.0 artifacts it would otherwise consume are the very ones being repaired below.+- **First full 9 × 9 bootstrapping sweep** — every implementation generating every+  other; dozens of cross-host issues surfaced and fixed+  ([#409](https://github.com/CategoricalData/hydra/issues/409), ongoing).+- **Published-package self-containment**: relocate each host's hand-written runtime+  into `overlay/<lang>/hydra-kernel/` so it ships inside the published `hydra-kernel`+  artifact — Python `hydra.python.util` into the wheel+  ([#461](https://github.com/CategoricalData/hydra/issues/461),+  [#472](https://github.com/CategoricalData/hydra/issues/472)) and the Haskell+  authoring DSL + `Libraries`/`Terms` into the sdist+  ([#473](https://github.com/CategoricalData/hydra/issues/473)). Generalized to a+  uniform `overlay/ = transform(packages) + copy(overlay)` model across all hosts+  ([#434](https://github.com/CategoricalData/hydra/issues/434)).+- **Kernel self-containment via generated `hydra.lib.*` registries**: primitive+  names are derived from generated `PrimitiveDefinition` def-modules rather than+  hand-written name strings, in every host+  ([#473](https://github.com/CategoricalData/hydra/issues/473)).+- **In-memory encode/decode synthesis**: derived `hydra.{encode,decode}.*` modules+  are synthesized at build time and excluded from `dist/`, with the synthesizer (not+  inference) as the authority for their annotations+  ([#448](https://github.com/CategoricalData/hydra/issues/448),+  [#476](https://github.com/CategoricalData/hydra/issues/476)).+- **Release hardening**: Apache source-release compliance (signed source archive,+  LICENSE/NOTICE bundling, KEYS) ([#441](https://github.com/CategoricalData/hydra/issues/441)),+  per-package publish orchestrators ([#449](https://github.com/CategoricalData/hydra/issues/449)),+  and packaging-boundary verification gated in CI and at publish time+  ([#472](https://github.com/CategoricalData/hydra/issues/472)).++### New features++- Published-host consume model wired through `bin/sync.sh` for all three hosts+  (`--published-host` default, `--local-host` shim), with the version basis keyed+  off `hydra.json` and the `VERSION` file retired+  ([#370](https://github.com/CategoricalData/hydra/issues/370),+  [#347](https://github.com/CategoricalData/hydra/issues/347)).+- Java and Python coder DSL sources made the sole source of truth; the legacy+  Haskell DSL copies were deleted and cross-package references resolve by name+  ([#346](https://github.com/CategoricalData/hydra/issues/346)).+- Per-host `verify-distribution.sh` self-containment gates (Haskell stages the+  per-package trio and `stack build`s it; Python installs the wheels into an+  isolated venv and imports the kernel modules; Java resolves the published jars+  from an offline consumer), run in CI and as a hard gate in `bin/prepare-release.sh`+  ([#472](https://github.com/CategoricalData/hydra/issues/472)).+- Apache-compliant canonical source archive: signed + checksummed `git archive`+  tarball as the release of record, root `NOTICE`, `KEYS`, and a release-verify CI+  workflow ([#441](https://github.com/CategoricalData/hydra/issues/441)).+- Per-package publish orchestrators `publish-maven.sh` / `publish-pypi.sh` with+  dependency-closure and leaves-first ordering checks+  ([#449](https://github.com/CategoricalData/hydra/issues/449)).+- `hydra-typescript` published as a target Java/Maven + PyPI artifact+  ([#468](https://github.com/CategoricalData/hydra/issues/468)).+- Java coder emits a fluent builder for every generated record type+  ([#465](https://github.com/CategoricalData/hydra/issues/465)); Python coder emits+  per-field `with_<field>` copy-update methods and a fluent builder+  ([#466](https://github.com/CategoricalData/hydra/issues/466)).++### Improvements++- Drop the vestigial `InferenceContext` parameter from the `Primitive.implementation`+  carrier across all hosts; add a graph-free `funT` coder and six `lists` default+  implementations ([#446](https://github.com/CategoricalData/hydra/issues/446)).+- Derive package routing from declared modules; split derived generation into broad+  `mainDslModules` and scoped `mainEncodingModules`+  ([#474](https://github.com/CategoricalData/hydra/issues/474),+  [#475](https://github.com/CategoricalData/hydra/issues/475)).+- Hash JSON content into the per-package input digest; add `digest-check+  refresh-input` and a CI guard that force-regenerates and diffs+  `dist/haskell/hydra-{java,python}` ([#469](https://github.com/CategoricalData/hydra/issues/469)).+- Per-package inference seeds downstream packages from each package's full universe+  while inferring only write targets, fixing `hydra-scala` inference within the CI+  heap budget; declare the `hydra-java` dependency in `hydra-scala` for cold+  ordering ([#470](https://github.com/CategoricalData/hydra/issues/470)).+- Remove the vestigial `Lib/Defaults` registry and empty `defaultLibModules`+  manifest field from all hosts ([#437](https://github.com/CategoricalData/hydra/issues/437)).+- Bundle LICENSE + NOTICE into Java jars (`META-INF`) and Python wheels+  (`dist-info`); declare Apache-2.0 in the Scala build+  ([#441](https://github.com/CategoricalData/hydra/issues/441)).+- Mark lazy parameters on the Scala and Common Lisp primitive registries so eager+  coders thunk correctly ([#453](https://github.com/CategoricalData/hydra/issues/453),+  [#477](https://github.com/CategoricalData/hydra/issues/477),+  [#425](https://github.com/CategoricalData/hydra/issues/425)).+- Staging-loop WIP-commit gate to keep `WIP:` commits off `origin/main`+  ([#466](https://github.com/CategoricalData/hydra/issues/466)).++### Bug fixes++- **Python wheel self-containment**: the `hydra-kernel` wheel now ships+  `hydra.python.util`; gated by a packaging-boundary smoke test in CI and+  `publish-pypi.sh` ([#472](https://github.com/CategoricalData/hydra/issues/472),+  [#461](https://github.com/CategoricalData/hydra/issues/461)).+- **Haskell sdist self-containment**: track the generated `Hydra/Dsl/Terms.hs`+  (was gitignored) so the committed dist exports `ToPrimName`, fixing the cold+  build of the published `hydra-kernel`+  ([#473](https://github.com/CategoricalData/hydra/issues/473)).+- Decode synthesizer threads the fully-applied result type into wrap/record/union+  decoder bodies, so derived decoders emit `DataRow<v>` rather than raw `DataRow`,+  fixing Java and Scala generic decode compilation+  ([#476](https://github.com/CategoricalData/hydra/issues/476)).+- Scala coder emits explicit type arguments for polymorphic non-primitive+  references under a type application (e.g. `requireField`), fixing `Any`-inference+  of curried decoder lambda parameters in `decode/typed`+  ([#434](https://github.com/CategoricalData/hydra/issues/434)).+- Common Lisp and Emacs Lisp: move the hand-written runtime to a dialect-tier path+  so it no longer collides with the generated `hydra.lib.*` def-modules+  ([#434](https://github.com/CategoricalData/hydra/issues/434)).+- Python coder uses the binding `TypeScheme` as the authoritative source for+  parameter and return types ([#488](https://github.com/CategoricalData/hydra/issues/488));+  fixes a duplicate `self` parameter in builders+  ([#478](https://github.com/CategoricalData/hydra/issues/478)).+- Sort term definitions by name in source-file generation so non-Haskell hosts emit+  deterministic alphabetical Haskell output (host-independent of `Maps.elems`+  iteration order) ([#489](https://github.com/CategoricalData/hydra/issues/489)).+- Java coder serializes the `static` method modifier (previously a non-exhaustive+  case) ([#465](https://github.com/CategoricalData/hydra/issues/465)); JavaDoc+  `@link`/`@param` sanitization for strict doclint+  ([#449](https://github.com/CategoricalData/hydra/issues/449)).+- Scala host writer appends a trailing newline when missing, fixing a Lisp-target+  byte mismatch ([#463](https://github.com/CategoricalData/hydra/issues/463)).+- Clojure host: silent wrapping `bigint_to_int{8,16,32,64}` casts per the kernel+  contract ([#483](https://github.com/CategoricalData/hydra/issues/483)); load-order+  and `--kernel-only` filter fixes after kernel renames+  ([#425](https://github.com/CategoricalData/hydra/issues/425)); load the+  `hydra-haskell` baseline for Clojure→Haskell rebuilds+  ([#487](https://github.com/CategoricalData/hydra/issues/487),+  [#460](https://github.com/CategoricalData/hydra/issues/460)).+- Lisp-dialect bootstrap fixes: emit JSON object entries as 2-element `Pair` lists+  rather than dotted cons ([#452](https://github.com/CategoricalData/hydra/issues/452),+  also fixing [#16](https://github.com/CategoricalData/hydra/issues/16)); read+  module names via the correct struct accessor+  ([#471](https://github.com/CategoricalData/hydra/issues/471)); drop stale+  surplus flag arguments from `generate-source-files` calls+  ([#457](https://github.com/CategoricalData/hydra/issues/457),+  [#458](https://github.com/CategoricalData/hydra/issues/458),+  [#464](https://github.com/CategoricalData/hydra/issues/464)); rename eta-wrapped+  projection/unwrap parameters to avoid kernel shadowing+  ([#428](https://github.com/CategoricalData/hydra/issues/428)); propagate a+  non-zero exit from the Scheme test runner on failures and fix Scheme float+  scientific-notation formatting for `|x| >= 1e7`+  ([#447](https://github.com/CategoricalData/hydra/issues/447)).+- Cross-host target dispatch: Common Lisp and Clojure hosts dispatch Scala and+  TypeScript targets ([#482](https://github.com/CategoricalData/hydra/issues/482),+  [#483](https://github.com/CategoricalData/hydra/issues/483)); Scala/Java host+  target-dispatch completions ([#5](https://github.com/CategoricalData/hydra/issues/5),+  [#7](https://github.com/CategoricalData/hydra/issues/7),+  [#17](https://github.com/CategoricalData/hydra/issues/17)).+- TypeScript test runtime reads the kernel JSON field names `body`/`signature`+  (not legacy `term`/`typeScheme`); `lists.nub` dedups by canonical JSON+  ([#485](https://github.com/CategoricalData/hydra/issues/485)).+- Sync robustness: always reassemble `dist/python` under `HYDRA_IN_SYNC` to heal+  partial-dist state ([#480](https://github.com/CategoricalData/hydra/issues/480));+  persist the run dir on bootstrap prep-phase failures+  ([#481](https://github.com/CategoricalData/hydra/issues/481)); complete per-host+  static deps so the bootstrap demo finds fresh dist+  ([#445](https://github.com/CategoricalData/hydra/issues/445)).+- Pin the Python target test interpreter to Python ≥ 3.12+  ([#486](https://github.com/CategoricalData/hydra/issues/486)); Emacs Lisp / Scheme+  target test-runner re-copy robustness+  ([#456](https://github.com/CategoricalData/hydra/issues/456)).+- JavaDoc Pages publish rewritten to build a combined site from the CI-generated+  `dist/java/` artifact, fixing the failure mode where `pages.yml` ran against a+  bare checkout with no `dist/java/` present+  ([#450](https://github.com/CategoricalData/hydra/issues/450)).++### Documentation++- Document the `overlay/` self-containment model, the published-host consume model+  for all three hosts, the `hydra.json` version / host-version basis, and a+  migration-shims recipe ([#434](https://github.com/CategoricalData/hydra/issues/434),+  [#370](https://github.com/CategoricalData/hydra/issues/370),+  [#347](https://github.com/CategoricalData/hydra/issues/347)).+- Document the kernel self-containment / `hydra.lib.*` def-module model and the+  derived-module no-inference invariant+  ([#473](https://github.com/CategoricalData/hydra/issues/473),+  [#466](https://github.com/CategoricalData/hydra/issues/466)); generated Java and+  Python record builders documented in the DSL guides+  ([#465](https://github.com/CategoricalData/hydra/issues/465),+  [#466](https://github.com/CategoricalData/hydra/issues/466)).+- Use absolute GitHub URLs in package READMEs so links resolve when published+  standalone ([#454](https://github.com/CategoricalData/hydra/issues/454)); bundle a+  README into each Python package dir for sdist metadata+  ([#418](https://github.com/CategoricalData/hydra/issues/418)).++---++## [0.16.0] - 2026-06-09++Major themes: primitive-metadata reification, self-hosting coder DSLs with all+eight hosts passing the common test suite, finalized `hydra.packaging`, and a+deep kernel-vocabulary cleanup.++### Highlights++- **`PrimitiveDefinition` and per-namespace registry modules** with host-independent+  specs for every standard-library primitive ([#156](https://github.com/CategoricalData/hydra/issues/156), [#319](https://github.com/CategoricalData/hydra/issues/319)).+- **Self-hosting coder DSLs; all eight hosts pass the common test suite**, including+  the completed TypeScript head ([#344](https://github.com/CategoricalData/hydra/issues/344), [#126](https://github.com/CategoricalData/hydra/issues/126)).+- **Finalized `hydra.packaging`** and a unified `Module.dependencies` field ([#369](https://github.com/CategoricalData/hydra/issues/369), [#354](https://github.com/CategoricalData/hydra/issues/354)).+- **Kernel-vocabulary cleanup**: `maybe`→`optional` across kernel and hosts, plus+  order-preserving JSON objects ([#401](https://github.com/CategoricalData/hydra/issues/401), [#398](https://github.com/CategoricalData/hydra/issues/398)).++### New features++- Reify `PrimitiveDefinition` in `hydra.packaging` with per-namespace `hydra.lib.<sub>` registries ([#156](https://github.com/CategoricalData/hydra/issues/156)).+- Host-independent `comments` specifications for all standard-library primitives ([#319](https://github.com/CategoricalData/hydra/issues/319)).+- Kernel-oriented style checks in `hydra.validate.*` ([#321](https://github.com/CategoricalData/hydra/issues/321), [#351](https://github.com/CategoricalData/hydra/issues/351), [#352](https://github.com/CategoricalData/hydra/issues/352)), on a reshaped validation API ([#320](https://github.com/CategoricalData/hydra/issues/320)).+- Promote the JSON Schema coder to a full DSL coder ([#350](https://github.com/CategoricalData/hydra/issues/350)).+- Transpose coder sources into host-native DSLs for self-hosting ([#344](https://github.com/CategoricalData/hydra/issues/344), [#358](https://github.com/CategoricalData/hydra/issues/358)).+- `Term`-typed annotations replacing `Map<Name, Term>` ([#386](https://github.com/CategoricalData/hydra/issues/386)).+- Language-specific EDSL features on the kernel `Language` ([#233](https://github.com/CategoricalData/hydra/issues/233)).+- Primitive-metadata-driven laziness in eager coders ([#391](https://github.com/CategoricalData/hydra/issues/391)).+- `/test` skill and `bin/test.sh` for target-language test validation ([#387](https://github.com/CategoricalData/hydra/issues/387)).+- Automatic differentiation: a `grad` transform ([#324](https://github.com/CategoricalData/hydra/issues/324)).+- `hydra.show.error.pg` for `InvalidGraphError` ([#374](https://github.com/CategoricalData/hydra/issues/374)).++### Improvements++- Finalize `hydra.packaging`: `Binding`→`TypeDefinition`, `Module`/`Package` `comments`, `moduleName` cleanup ([#369](https://github.com/CategoricalData/hydra/issues/369), [#396](https://github.com/CategoricalData/hydra/issues/396), [#402](https://github.com/CategoricalData/hydra/issues/402), [#404](https://github.com/CategoricalData/hydra/issues/404)).+- Merge `Module.termDependencies`/`typeDependencies` into one `dependencies` field ([#354](https://github.com/CategoricalData/hydra/issues/354)).+- Resolve the `maybe`/`optional` ambiguity across kernel and all hosts ([#401](https://github.com/CategoricalData/hydra/issues/401)).+- Order-preserving JSON objects; order-sensitive `Value` equality ([#398](https://github.com/CategoricalData/hydra/issues/398)).+- Rename `Namespace`→`ModuleName` ([#316](https://github.com/CategoricalData/hydra/issues/316)) and the phantom DSL types to `Typed*` ([#397](https://github.com/CategoricalData/hydra/issues/397)).+- Move from a type-class enum to type-class names ([#275](https://github.com/CategoricalData/hydra/issues/275)).+- Repackage "eval lib" modules as kernel lib modules; promote remaining sources ([#260](https://github.com/CategoricalData/hydra/issues/260), [#355](https://github.com/CategoricalData/hydra/issues/355), [#356](https://github.com/CategoricalData/hydra/issues/356)).+- Reshape `hydra.context` into `InferenceContext` ([#368](https://github.com/CategoricalData/hydra/issues/368)).+- Streamline the Haskell, Java, Python, and Scala syntax models, re-pinning Java to SE 21 and Python to the 3.14 PEG grammar ([#297](https://github.com/CategoricalData/hydra/issues/297)).+- Adopt persistent immutable collections across hosts ([#359](https://github.com/CategoricalData/hydra/issues/359), [#360](https://github.com/CategoricalData/hydra/issues/360), [#361](https://github.com/CategoricalData/hydra/issues/361), [#362](https://github.com/CategoricalData/hydra/issues/362)).+- Migrate underscored kernel definition names to camelCase ([#348](https://github.com/CategoricalData/hydra/issues/348)).+- Tidy qualified/unqualified imports in the Haskell DSL sources ([#308](https://github.com/CategoricalData/hydra/issues/308)).+- Eliminate the `Hydra.Module.Compat` shim ([#315](https://github.com/CategoricalData/hydra/issues/315)).+- Homogenize writer conventions across target languages ([#339](https://github.com/CategoricalData/hydra/issues/339)).+- Disambiguate format-version field naming across JSON metadata ([#412](https://github.com/CategoricalData/hydra/issues/412)).+- Per-package DSL→JSON build with per-package incremental inference ([#381](https://github.com/CategoricalData/hydra/issues/381), [#395](https://github.com/CategoricalData/hydra/issues/395)).+- Prune stale `dist/` outputs; self-heal digests; exclude digests from VCS; reconcile drift; fail loud ([#357](https://github.com/CategoricalData/hydra/issues/357), [#393](https://github.com/CategoricalData/hydra/issues/393), [#405](https://github.com/CategoricalData/hydra/issues/405), [#378](https://github.com/CategoricalData/hydra/issues/378), [#379](https://github.com/CategoricalData/hydra/issues/379), [#392](https://github.com/CategoricalData/hydra/issues/392), [#414](https://github.com/CategoricalData/hydra/issues/414)).+- Accept all valid (host, target) pairs in the generation drivers ([#421](https://github.com/CategoricalData/hydra/issues/421)).+- Move Gradle build infrastructure into `heads/java/`; remove top-level `pixi.toml` ([#384](https://github.com/CategoricalData/hydra/issues/384), [#385](https://github.com/CategoricalData/hydra/issues/385)).+- Eliminate post-generation test patches; fix loader/runner kludges; re-enable test timing ([#307](https://github.com/CategoricalData/hydra/issues/307), [#309](https://github.com/CategoricalData/hydra/issues/309), [#311](https://github.com/CategoricalData/hydra/issues/311)).+- Performance/benchmarks and usability assessments ([#277](https://github.com/CategoricalData/hydra/issues/277), [#283](https://github.com/CategoricalData/hydra/issues/283)).+- Split the Hackage distribution into per-package distributions ([#418](https://github.com/CategoricalData/hydra/issues/418)).++### Bug fixes++- Encode `uint32` JSON literals as numbers, not strings ([#431](https://github.com/CategoricalData/hydra/issues/431)).+- Satisfy or suppress warnings in generated Java ([#349](https://github.com/CategoricalData/hydra/issues/349)).+- Restore JSON parser test cases (polymorphic case handling, ordering fallback) ([#336](https://github.com/CategoricalData/hydra/issues/336)).+- Keep annotations through `termAlternatives`/`typeAlternatives` adaptation ([#353](https://github.com/CategoricalData/hydra/issues/353)).+- Scala host decodes module JSON containing term definitions ([#342](https://github.com/CategoricalData/hydra/issues/342)).+- Java coder: fix exponential `let`-bound `cases` cost ([#372](https://github.com/CategoricalData/hydra/issues/372)) and explicit type args on `PersistentMap.ofEntries` ([#394](https://github.com/CategoricalData/hydra/issues/394)).+- Python-host codegen: drop extra `pyStringToPyStrings` wrapping ([#367](https://github.com/CategoricalData/hydra/issues/367)).+- `escape_literal_char` no longer mangles RDF triples ([#363](https://github.com/CategoricalData/hydra/issues/363)).+- Sync robustness: stale coder JSON, omitted native modules, dead helper, bad source dirs ([#406](https://github.com/CategoricalData/hydra/issues/406), [#400](https://github.com/CategoricalData/hydra/issues/400), [#411](https://github.com/CategoricalData/hydra/issues/411), [#408](https://github.com/CategoricalData/hydra/issues/408)).+- Cross-host self-hosting fixes (Scala, TypeScript, and the four Lisp dialects) ([#422](https://github.com/CategoricalData/hydra/issues/422), [#423](https://github.com/CategoricalData/hydra/issues/423), [#424](https://github.com/CategoricalData/hydra/issues/424), [#429](https://github.com/CategoricalData/hydra/issues/429), [#444](https://github.com/CategoricalData/hydra/issues/444), [#366](https://github.com/CategoricalData/hydra/issues/366), [#389](https://github.com/CategoricalData/hydra/issues/389), [#407](https://github.com/CategoricalData/hydra/issues/407), [#425](https://github.com/CategoricalData/hydra/issues/425), [#426](https://github.com/CategoricalData/hydra/issues/426), [#427](https://github.com/CategoricalData/hydra/issues/427), [#432](https://github.com/CategoricalData/hydra/issues/432), [#438](https://github.com/CategoricalData/hydra/issues/438), [#439](https://github.com/CategoricalData/hydra/issues/439), [#443](https://github.com/CategoricalData/hydra/issues/443)).++### Removed++- Removed the `bigfloat` literal type from `FloatType` and `FloatValue` ([#330](https://github.com/CategoricalData/hydra/issues/330)).+  Arbitrary-precision floating-point values were inconsistently supported+  across host languages (Java/Scala in particular lacked a true IEEE 754+  arbitrary-precision implementation), and nothing in the codebase relied on+  them. `FloatType` and `FloatValue` now have only `float32` and `float64`+  variants. Removed library primitives: `bigfloatToBigint`, `bigfloatToFloat32`,+  `bigfloatToFloat64`, `bigintToBigfloat`, `float32ToBigfloat`,+  `float64ToBigfloat`, `readBigfloat`, `showBigfloat`, `roundBigfloat`. New+  primitives `float32ToFloat64` and `float64ToFloat32` (the latter lossy)+  replace the removed bigfloat-routed conversions.+- Removed `heads/haskell/bin/assemble-hackage-sdist.sh` ([#418](https://github.com/CategoricalData/hydra/issues/418)), the 0.15-era+  bridge that flattened the multi-source-dir Haskell head into one self-contained+  `hydra` sdist. Superseded by the per-package assembler (see Improvements).++### Documentation++- Comprehensive documentation refresh for 0.16 ([#383](https://github.com/CategoricalData/hydra/issues/383))+  spanning nine tracks across READMEs, `docs/`, the wiki, CLAUDE.md, and+  in-source kernel comments.+- New `docs/json-format.md` reference describing the canonical JSON wire format+  (tagged-union duality, optional-field rules, IEEE 754 sentinels, integer+  threshold).+- New wiki pages: `Design` (rationale behind each major choice) and `Inference`+  (HM type inference with class constraints).+- Cross-checked every prose doc against current code; corrected drift in+  primitive-checking sections of `docs/recipes/maintenance.md`, the `Primitive`+  shape in `docs/implementation.md` and `docs/recipes/adding-primitives.md`,+  and the build-system narrative.+- Wove motivation ("the why") through the existing doc surface rather than+  collecting it into separately-titled sidebars; landed an inference-overview+  centerpiece on the wiki ([#377](https://github.com/CategoricalData/hydra/issues/377)).+- Aligned doc vocabulary with the LambdaGraph paper and the literature review+  for the design space Hydra inhabits.+- Net-new READMEs for `packages/hydra-kernel`, `packages/hydra-ext`,+  `packages/hydra-coq`, and `packages/hydra-wasm`; top-level `README.md`+  now carries a canonical packages table.+- Audited and refreshed the Claude surface: CLAUDE.md "Where to look up X"+  table extended with rows for `docs/getting-started.md`, `docs/json-format.md`,+  and the `Design` / `Inference` wiki pages; hard-rules block reordered by+  violation frequency; `claude/pitfalls.md` superseded entries folded into+  `docs/troubleshooting.md` / recipes.+- Project-descriptor strings reviewed and aligned across 24 build / packaging+  files (Hackage synopsis, Maven Central description, PyPI / conda-forge+  classifiers, Hydra-format `package.json` files).+- `docs/index.html` (the GitHub Pages landing page) refreshed with audience+  hops into wiki Concepts / Design, `docs/getting-started.md`, and the GitHub+  repo, plus the full published-artifact list across Hackage, Maven Central,+  PyPI, and conda-forge.+- In-source kernel-code rationale comments added at key Sources sites covering+  injection / pair / either / unit-void duality, error taxonomy, variant+  records, inference-context threading, validation profiles, reduction state,+  lexical filters, name mangling, scoping, variable handling, defaults+  integration, and Tarjan SCC choice rationale. JSON encode/decode modules+  cross-reference `docs/json-format.md`.+- Filed `Primitive.implementation` carrier-simplification follow-up+  ([#446](https://github.com/CategoricalData/hydra/issues/446))+  to drop the unused `InferenceContext` and `Graph` parameters once the+  `Lib/Defaults/` integration ([#437](https://github.com/CategoricalData/hydra/issues/437))+  lands.++---++## [0.15.0] - 2026-04-29++A structural-cleanup release.+The repository is reorganized into a three-tree+`packages/` (DSL sources) / `heads/` (per-host runtime) / `dist/` (generated output)+layout ([#290](https://github.com/CategoricalData/hydra/issues/290)), the kernel is simplified ([#251](https://github.com/CategoricalData/hydra/issues/251), [#292](https://github.com/CategoricalData/hydra/issues/292), [#332](https://github.com/CategoricalData/hydra/issues/332)), and Java + Python now+ship as per-package publishable artifacts on Maven Central / PyPI / conda-forge+([#305](https://github.com/CategoricalData/hydra/issues/305)).+Incremental, content-hash-based caches accelerate the sync pipeline ([#247](https://github.com/CategoricalData/hydra/issues/247)).+Three new generation-only targets — Coq ([#326](https://github.com/CategoricalData/hydra/issues/326)), WebAssembly ([#325](https://github.com/CategoricalData/hydra/issues/325)), and an+automatic-differentiation demo ([#324](https://github.com/CategoricalData/hydra/issues/324)) — are in progress as Claude collaborations.++### Highlights++- **Three-tree repository layout**: `packages/` (DSL), `heads/` (host runtime),+  `dist/` (generated) ([#290](https://github.com/CategoricalData/hydra/issues/290)).+- **Per-package distributions** for Java (4 Maven artifacts) and Python (5 wheels):+  `hydra-kernel`, `hydra-pg`, `hydra-rdf`, `hydra-{java,python}`, plus `hydra-ext`+  on PyPI ([#305](https://github.com/CategoricalData/hydra/issues/305)).+- **Kernel simplifications**: `Function`/`Elimination` removed ([#332](https://github.com/CategoricalData/hydra/issues/332)),+  `FunctionPrimitive` removed ([#251](https://github.com/CategoricalData/hydra/issues/251)), `Hydra.Ext.*` prefix retired ([#331](https://github.com/CategoricalData/hydra/issues/331)),+  `Context` error wrapper gone ([#292](https://github.com/CategoricalData/hydra/issues/292)).+- **Incremental caches** across the sync pipeline; ~70x speedup on no-op resync ([#247](https://github.com/CategoricalData/hydra/issues/247)).+- **JSON kernel format v1** with formal wire-format spec and four-field rename ([#343](https://github.com/CategoricalData/hydra/issues/343)).+- **Three new generation-only targets** (in progress): Coq ([#326](https://github.com/CategoricalData/hydra/issues/326)), WebAssembly ([#325](https://github.com/CategoricalData/hydra/issues/325)),+  automatic-differentiation demo ([#324](https://github.com/CategoricalData/hydra/issues/324)).++### New features++- Per-package distributions ([#305](https://github.com/CategoricalData/hydra/issues/305)): standalone Maven / PyPI / conda-forge builds,+  generated `build.gradle` / `pyproject.toml` per package, transitive dep resolution.+- JSON kernel format v1 ([#343](https://github.com/CategoricalData/hydra/issues/343)): formal spec at `docs/json-format.md`,+  four-field rename to `typeScheme`, `Module` field reorder, `formatVersion` stamp.+- `decimal` literal type in the kernel ([#338](https://github.com/CategoricalData/hydra/issues/338)) across all hosts.+- Type-directed JSON encoder with idiomatic optional encoding ([#314](https://github.com/CategoricalData/hydra/issues/314), [#318](https://github.com/CategoricalData/hydra/issues/318)).+- Incremental type inference plus content-hash caches ([#247](https://github.com/CategoricalData/hydra/issues/247)).+- Coq generation target ([#326](https://github.com/CategoricalData/hydra/issues/326), in progress): `hydra-coq` package, 131/131 `.v` files pass `coqc`.+- WebAssembly target ([#325](https://github.com/CategoricalData/hydra/issues/325), in progress): `hydra-wasm` package, M4 closure mechanism.+- Automatic-differentiation demo ([#324](https://github.com/CategoricalData/hydra/issues/324), in progress): symbolic source-to-source.+- `hydra.show.error` module ([#265](https://github.com/CategoricalData/hydra/issues/265)): consolidated error-message builders.+- `hydra.lib.maybes.toList` primitive ([#257](https://github.com/CategoricalData/hydra/issues/257)).+- NaN / Inf round-tripping through JSON and per-language serdes ([#312](https://github.com/CategoricalData/hydra/issues/312), [#318](https://github.com/CategoricalData/hydra/issues/318), [#330](https://github.com/CategoricalData/hydra/issues/330)).+- Typeclass inference test group ([#274](https://github.com/CategoricalData/hydra/issues/274)).+- Term and type linters ([#232](https://github.com/CategoricalData/hydra/issues/232)).+- Validation for modules and graphs ([#155](https://github.com/CategoricalData/hydra/issues/155)).+- User-defined-function (UDF) support and DSL-vs-primitive overrides+  ([#62](https://github.com/CategoricalData/hydra/issues/62), [#63](https://github.com/CategoricalData/hydra/issues/63), [#102](https://github.com/CategoricalData/hydra/issues/102), [#158](https://github.com/CategoricalData/hydra/issues/158)).+- Stale-source detection across sync entrypoints ([#228](https://github.com/CategoricalData/hydra/issues/228)).++### Improvements++- Sync infrastructure: matrix tool, per-package orchestrator, per-language wrappers ([#290](https://github.com/CategoricalData/hydra/issues/290)).+- TestGraph post-generation patches eliminated; DSL emits `TestEnv` refs directly.+- Minimized standard imports in generated Haskell ([#161](https://github.com/CategoricalData/hydra/issues/161)); improved auto-aliases ([#322](https://github.com/CategoricalData/hydra/issues/322)).+- Removed kernel term dependencies from the interpreter ([#257](https://github.com/CategoricalData/hydra/issues/257)).+- Removed `Graph` and `Context` arguments from primitive implementations ([#266](https://github.com/CategoricalData/hydra/issues/266)).+- Refactored kernel term modules: split rewriting/schemas, renamed show.meta → codegen,+  moved `Coder` to `coders`, merged `extract.helpers` ([#221](https://github.com/CategoricalData/hydra/issues/221)).+- Removed Aeson and HsYAML dependencies; YAML coder moved to `hydra-ext` ([#261](https://github.com/CategoricalData/hydra/issues/261)).+- Lisp recursive let bindings via SCC ([#341](https://github.com/CategoricalData/hydra/issues/341)); parenthesis cleanup ([#84](https://github.com/CategoricalData/hydra/issues/84)).+- Everything-to-everything bootstrapping demo ([#254](https://github.com/CategoricalData/hydra/issues/254)).+- Re-enabled skipped Python tests; `disabledForPython` retired ([#263](https://github.com/CategoricalData/hydra/issues/263)).+- Promoted host-specific code in `packages/` into per-head locations ([#337](https://github.com/CategoricalData/hydra/issues/337)).+- Migrated `hydra.common` Java module out ([#10](https://github.com/CategoricalData/hydra/issues/10)).+- Test infrastructure unification under `UniversalTestCase` ([#246](https://github.com/CategoricalData/hydra/issues/246)).+- Default property graph → RDF mapping ([#296](https://github.com/CategoricalData/hydra/issues/296)).+- 13 unsafe partial primitives replaced with `Maybe`-returning alternatives ([#201](https://github.com/CategoricalData/hydra/issues/201)).+- Java generated code uses standard `java.util` collection interfaces ([#313](https://github.com/CategoricalData/hydra/issues/313)).+- `Term.union` renamed to `Term.inject` ([#334](https://github.com/CategoricalData/hydra/issues/334)).+- Inconsistencies in domain DSLs cleaned up ([#219](https://github.com/CategoricalData/hydra/issues/219)).+- Coder packages moved out of hydra-haskell ([#182](https://github.com/CategoricalData/hydra/issues/182)).+- Java package-naming scheme revised ([#223](https://github.com/CategoricalData/hydra/issues/223)).+- Decimal used (instead of bigfloat) for JSON numbers ([#340](https://github.com/CategoricalData/hydra/issues/340)).+- Hydra kernel moved out of hydra-haskell ([#282](https://github.com/CategoricalData/hydra/issues/282)).++### Bug fixes++- `substInTypeScheme` capture-unsafe substitution under nested forall binders.+- Java `Float64` arithmetic primitives corrected for current `PrimitiveFunction` API.+- Clojure decimal handling: value-based equality, `BigInteger` return from `decimal_to_bigint`.+- Scheme runtime R7RS imports for `sets.scm` / `maps.scm` / `eithers.map_set`.+- Python coder defaults corrected from `Py.Name` to `Py.Expression`.+- Scala host JSON-decode failure on modules containing term definitions ([#342](https://github.com/CategoricalData/hydra/issues/342)).+- Lisp coder mutually-recursive let bindings for Clojure ([#341](https://github.com/CategoricalData/hydra/issues/341)).++### Documentation++- Documentation refresh for the 0.15 packaging restructure ([#290](https://github.com/CategoricalData/hydra/issues/290), [#331](https://github.com/CategoricalData/hydra/issues/331)); CLAUDE.md,+  READMEs, recipes, demos, and seven wiki pages updated.+- Code-generation recipe rewritten for the per-package dist layout ([#282](https://github.com/CategoricalData/hydra/issues/282)).+- New `maintenance.md` recipe consolidates non-source-file scans, stale generated+  detection, design-violation checks, and freshness checks.+- Documentation style guide added at `docs/documentation-style-guide.md`.+- Cross-worktree messaging protocol documented in CLAUDE.md.+- Decimal type documented in the lexicon and per-language READMEs ([#338](https://github.com/CategoricalData/hydra/issues/338)).+- JSON encoding format docs updated for idiomatic optional encoding ([#314](https://github.com/CategoricalData/hydra/issues/314)).++---++## [0.14.1] - 2026-03-30++Patch release.+Regenerates all implementations after a fix to the group eval primitive ([#281](https://github.com/CategoricalData/hydra/issues/281)),+and relocates the property-graph and RDF/SHACL "ext" modules into hydra-java and hydra-python.++### Improvements++- Moved PG, RDF, and SHACL ext modules from hydra-ext into hydra-java and hydra-python.++### Bug fixes++- Group eval primitive fix; all targets regenerated ([#281](https://github.com/CategoricalData/hydra/issues/281)).+- JavaDoc HTML-entity escaping in generated `DestructuringPattern.java`.++---++## [0.14.0] - 2026-03-29++Major release adding four new complete Hydra implementations — Scala ([#273](https://github.com/CategoricalData/hydra/issues/273)),+Clojure ([#278](https://github.com/CategoricalData/hydra/issues/278)), Common Lisp, and Scheme — bringing the total to seven bootstrapping hosts+(plus Emacs Lisp, which passes the test suite but does not yet participate in bootstrapping).+Also includes kernel simplifications, an Avro bidirectional coder ([#301](https://github.com/CategoricalData/hydra/issues/301)),+eval primitives ([#281](https://github.com/CategoricalData/hydra/issues/281)), new demos, and significant performance work on the Scheme host.++### Highlights++- **Four new complete implementations**: Hydra-Scala ([#273](https://github.com/CategoricalData/hydra/issues/273)), Hydra-Clojure ([#278](https://github.com/CategoricalData/hydra/issues/278)),+  Hydra-Common Lisp, and Hydra-Scheme pass the common test suite and can serve as+  bootstrapping hosts.+  The four Lisp dialects share a single coder and serializer.+- **Kernel simplifications**: removed `RowType`/`WrappedType` ([#82](https://github.com/CategoricalData/hydra/issues/82)),+  unified `Graph`/`TypeContext`/`InferenceContext` ([#192](https://github.com/CategoricalData/hydra/issues/192)),+  replaced `Module.elements` with `Module.definitions` ([#214](https://github.com/CategoricalData/hydra/issues/214)),+  consolidated error types ([#268](https://github.com/CategoricalData/hydra/issues/268)), and promoted all staging modules to DSL sources ([#267](https://github.com/CategoricalData/hydra/issues/267)).+- **Avro bidirectional coder** ([#301](https://github.com/CategoricalData/hydra/issues/301)) with property graph pipeline demo.+- **Scheme bootstrap performance**: 58 minutes → 5.7 minutes via O(1) vhash data structures+  and IEEE 754 float precision fixes.++### Breaking changes++- Removed legacy adapter framework; replaced by the staging-promoted variant ([#236](https://github.com/CategoricalData/hydra/issues/236), [#295](https://github.com/CategoricalData/hydra/issues/295)).+- Replaced legacy Flow monad with Either ([#245](https://github.com/CategoricalData/hydra/issues/245)).+- Removed `Module.elements`; use `Module.definitions` ([#214](https://github.com/CategoricalData/hydra/issues/214)).+- Removed `RowType` and `WrappedType` ([#82](https://github.com/CategoricalData/hydra/issues/82)).+- Renamed `hydra.accessors` to `hydra.paths` ([#271](https://github.com/CategoricalData/hydra/issues/271)).+- Renamed `hydra.tarjan` and merged into `hydra.sorting` ([#220](https://github.com/CategoricalData/hydra/issues/220)).+- Merged `hydra.constraints` into `hydra.query` ([#272](https://github.com/CategoricalData/hydra/issues/272)).+- Moved `hydra.workflow` to hydra-ext ([#270](https://github.com/CategoricalData/hydra/issues/270)).+- Consolidated `hydra.compute` into `hydra.util` ([#269](https://github.com/CategoricalData/hydra/issues/269)).+- Removed `hydra.describe` ([#216](https://github.com/CategoricalData/hydra/issues/216)) and types from `hydra.mantle` ([#217](https://github.com/CategoricalData/hydra/issues/217)).+- Replaced `OtherError` with task-specific error types ([#268](https://github.com/CategoricalData/hydra/issues/268)).+- Java: lowered minimum Java version to 11 ([#249](https://github.com/CategoricalData/hydra/issues/249)).+- Java: `Pair` replaces `Tuple2` ([#252](https://github.com/CategoricalData/hydra/issues/252)); `Comparable` implemented for generated classes ([#131](https://github.com/CategoricalData/hydra/issues/131)).++### New features++- Hydra-Scala ([#273](https://github.com/CategoricalData/hydra/issues/273)): complete implementation, sbt/Scala 3, 3043 tests.+- Hydra-Lisp: Clojure ([#278](https://github.com/CategoricalData/hydra/issues/278)), Common Lisp, Emacs Lisp, Scheme — four dialects,+  one coder. CI workflows for Clojure, Common Lisp, and Scheme.+- Avro bidirectional coder ([#301](https://github.com/CategoricalData/hydra/issues/301)) with demo.+- Eval primitives ([#281](https://github.com/CategoricalData/hydra/issues/281)): Logic, Equality, Math, collections, and Groups.+- Generated DSL modules ([#180](https://github.com/CategoricalData/hydra/issues/180)): `hydra.dsls` generates DSL helpers from type modules.+- New demos: GraphQL+JSON ([#279](https://github.com/CategoricalData/hydra/issues/279)), PG validation ([#284](https://github.com/CategoricalData/hydra/issues/284)), SHACL ([#294](https://github.com/CategoricalData/hydra/issues/294)), Avro+PG.+- Packaging module ([#290](https://github.com/CategoricalData/hydra/issues/290)): `hydra.packaging` with `Package` type and validation.+- New primitives: `lists.foldr` ([#280](https://github.com/CategoricalData/hydra/issues/280)), `maybes.toList`, float rounding ([#264](https://github.com/CategoricalData/hydra/issues/264), [#285](https://github.com/CategoricalData/hydra/issues/285)).+- Cross-language benchmarking suite ([#234](https://github.com/CategoricalData/hydra/issues/234)).+- Limited typeclass inference ([#164](https://github.com/CategoricalData/hydra/issues/164)).+- Standardized validation patterns across modules ([#291](https://github.com/CategoricalData/hydra/issues/291)).++### Improvements++- Promoted all staging modules to DSL sources ([#267](https://github.com/CategoricalData/hydra/issues/267)).+- Removed legacy adapters, JSON/YAML coders, grammar framework ([#236](https://github.com/CategoricalData/hydra/issues/236), [#295](https://github.com/CategoricalData/hydra/issues/295)).+- Java: efficient immutable data structures ([#193](https://github.com/CategoricalData/hydra/issues/193)); flattened term naming.+- Java: hidden specialized collection classes in type-level files ([#313](https://github.com/CategoricalData/hydra/issues/313)).+- Inference error messages improved ([#231](https://github.com/CategoricalData/hydra/issues/231)).+- Combined nested let bindings in the Haskell coder ([#248](https://github.com/CategoricalData/hydra/issues/248)).+- Simplified `hydra.adapt.simple` ([#255](https://github.com/CategoricalData/hydra/issues/255)).+- Removed Haskell operators dependency from tests ([#288](https://github.com/CategoricalData/hydra/issues/288)).+- Regression tests for non-Haskell/Java coders ([#85](https://github.com/CategoricalData/hydra/issues/85)).+- Regex support added ([#293](https://github.com/CategoricalData/hydra/issues/293)).+- `hydra.annotations.isNativeType` revisited ([#214](https://github.com/CategoricalData/hydra/issues/214)).+- Migrated grammar-generated models ([#295](https://github.com/CategoricalData/hydra/issues/295)).+- `<<= -shouldBe-> <<~` operator change ([#276](https://github.com/CategoricalData/hydra/issues/276)).+- Minimize Generation.hs ([#225](https://github.com/CategoricalData/hydra/issues/225)).+- Implemented missing Flows primitives ([#183](https://github.com/CategoricalData/hydra/issues/183)).+- Removed JavaDocs from the repository ([#262](https://github.com/CategoricalData/hydra/issues/262)).+- Floating-point test portability fixes for Linux CI ([#264](https://github.com/CategoricalData/hydra/issues/264), [#285](https://github.com/CategoricalData/hydra/issues/285)).+- Moved YAML coder to hydra-ext ([#224](https://github.com/CategoricalData/hydra/issues/224)).+- Minimized native Python and Java primitives in favor of DSL implementations ([#244](https://github.com/CategoricalData/hydra/issues/244)).+- Removed the `disabledForPython` test tag ([#250](https://github.com/CategoricalData/hydra/issues/250)).++### Release tooling++- 0.14 release tracking ([#304](https://github.com/CategoricalData/hydra/issues/304)).++### Documentation++- Thorough cleanup of user documentation ([#302](https://github.com/CategoricalData/hydra/issues/302), [#303](https://github.com/CategoricalData/hydra/issues/303)).+- Coding style guide added to wiki.+- Updated 'new implementation' recipe with learnings from Clojure head ([#278](https://github.com/CategoricalData/hydra/issues/278)).++---++## [0.13.0] - 2026-02-27++Major release completing Hydra-Python ([#66](https://github.com/CategoricalData/hydra/issues/66)) and Hydra-Java ([#166](https://github.com/CategoricalData/hydra/issues/166)) as self-hosting Hydra implementations+and demonstrating mutual self-hosting across all three languages.+Significant improvements to type inference, type checking, rewriting, and adaptation.+New language features include first-class Either types, typeclass inference, binary data support,+and a native JSON parser/writer.+Comprehensive tooling for cross-implementation bootstrapping+and provisional support for Go, Rust, and JavaScript targets.++### Highlights++- **Mutual self-hosting across three implementations**: Hydra is now fully self-hosting+  in Haskell ([#179](https://github.com/CategoricalData/hydra/issues/179)), Java, and Python, and can cross-generate between every combination+  of host and target language (9 paths total).+- **Hydra-Java is complete** ([#166](https://github.com/CategoricalData/hydra/issues/166)): all kernel and generation tests pass.+- **Hydra-Python is complete** ([#66](https://github.com/CategoricalData/hydra/issues/66)): 100% test parity with Haskell.+- **Language coders promoted into the Hydra kernel** ([#176](https://github.com/CategoricalData/hydra/issues/176)): Haskell, Java, and Python+  coders are now defined as Hydra DSL modules, making them self-hosting.+- **Either type support** ([#210](https://github.com/CategoricalData/hydra/issues/210)) with full inference, checking, and library support.+- **Native JSON parser and writer** ([#188](https://github.com/CategoricalData/hydra/issues/188), [#243](https://github.com/CategoricalData/hydra/issues/243), [#253](https://github.com/CategoricalData/hydra/issues/253)): Hydra's own JSON parser and writer+  replace the Aeson dependency; bootstrap-from-JSON architecture for cross-implementation+  code generation.++### Breaking changes++- Renamed `Optional` to `Maybe` throughout the codebase ([#204](https://github.com/CategoricalData/hydra/issues/204)):+  `hydra.lib.optionals` → `hydra.lib.maybes`; all `optional` variants renamed to `maybe`.+- Removed unlabeled product and sum types; replaced with pair types ([#212](https://github.com/CategoricalData/hydra/issues/212)).+- Renamed `hydra.core.TypedTerm` to `hydra.core.TypeApplicationTerm`.+- Renamed `hydra.json` to `hydra.json.model`.+- Renamed `hydra.lib.maps.remove` to `hydra.lib.maps.delete`.+- Removed deprecated `hydra.decoding` module.+- Removed old `hydra.mantle.Either` type (replaced by core `Either`).+- Removed `hydra.lib.tuples` library.+- Removed C# coder stub (C# syntax model remains).+- DSL syntax migration: removed `OverloadedStrings` for term expressions ([#238](https://github.com/CategoricalData/hydra/issues/238)).+- Removed `Hydra.Dsl.ShorthandTypes` ([#222](https://github.com/CategoricalData/hydra/issues/222)).++### New features++- Self-hosting in Haskell ([#179](https://github.com/CategoricalData/hydra/issues/179)) and full mutual cross-generation (Haskell ↔ Java ↔ Python).+- New bootstrapping demo validating all 9 paths across 249 modules.+- Promoted Haskell, Java, and Python coders from staging code into Hydra DSL sources ([#176](https://github.com/CategoricalData/hydra/issues/176)).+- JSON-as-source-of-truth bootstrapping architecture ([#243](https://github.com/CategoricalData/hydra/issues/243), [#253](https://github.com/CategoricalData/hydra/issues/253)):+  new executables and scripts enabling `bootstrap-from-json` for cross-implementation+  code generation.+- Generated term encoders and decoders replace legacy hand-coded modules ([#47](https://github.com/CategoricalData/hydra/issues/47)).+- Hydra-Python completion ([#66](https://github.com/CategoricalData/hydra/issues/66)): restructured project layout with `src/main` and+  `src/gen-main` ([#191](https://github.com/CategoricalData/hydra/issues/191)); full library implementations including `hydra.lib.flows`;+  `@lru_cache` optimization for nullary bindings; PyPy compatibility.+- Hydra-Java completion ([#166](https://github.com/CategoricalData/hydra/issues/166)): all kernel and generation tests pass; deep changes+  to Java coder; `Lazy` utility class for delayed evaluation; array-type support+  in Java serde; tail-call optimization in the Java coder; `Tuple` implements `Comparable`.+- Either type ([#210](https://github.com/CategoricalData/hydra/issues/210)): `EitherType`, `either` term constructor, `hydra.lib.eithers` library+  with `either`, `map`, `mapList`, `mapMaybe`, `bimap`, `bind`, `fromLeft`, `fromRight`,+  `isLeft`, `isRight`, `lefts`, `rights`, `partitionEithers`.+- Pair type as a core construct ([#211](https://github.com/CategoricalData/hydra/issues/211)).+- Void type ([#237](https://github.com/CategoricalData/hydra/issues/237)): uninhabited `void` type as the dual of `unit`; type-level only.+- Native JSON parser and writer ([#188](https://github.com/CategoricalData/hydra/issues/188), [#242](https://github.com/CategoricalData/hydra/issues/242)):+  bidirectional JSON encoder/decoder; replaces the Aeson dependency;+  cross-checked via a special test runner.+- Typeclass inference ([#164](https://github.com/CategoricalData/hydra/issues/164)):+  type schemes with typeclass constraints via `TypeVariableMetadata`;+  typeclass metadata on primitive definitions; Haskell coder uses typeclass info.+- Binary/`ByteString` support ([#172](https://github.com/CategoricalData/hydra/issues/172)): binary data via `ByteString` instead of `String`;+  Haskell coder uses `Data.ByteString`; new `binaryToBytes` primitive.+- Parser combinators: new `hydra.parsing` module with combinator types and DSL.+- Higher-order primitive interpreter ([#198](https://github.com/CategoricalData/hydra/issues/198)): all primitives are fully interpretable+  across all three implementations; legacy `requiresInterp` tag removed.+- Let hoisting and flattening: hoisting polymorphic let terms;+  refined hoisting for monomorphic bindings inside polymorphic ones;+  more efficient `liftLambdaAboveLet` ([#202](https://github.com/CategoricalData/hydra/issues/202));+  case-statement hoisting ([#241](https://github.com/CategoricalData/hydra/issues/241)); subterm hoisting helpers.+- Provisional language targets: Go ([#65](https://github.com/CategoricalData/hydra/issues/65)), Rust (with experimental type-level coder),+  JavaScript (syntax model, serde, DSL, generated sources), and Java/Python syntax DSLs.+- New adapter framework ([#236](https://github.com/CategoricalData/hydra/issues/236)): all external coders refactored+  (Haskell, YAML, Scala, JSON Schema, C++, PDL, Protobuf, GraphQL).+- Compact labeled records and variants ([#122](https://github.com/CategoricalData/hydra/issues/122)).+- New primitives:+  `hydra.lib.lists.find`, `hydra.lib.lists.partition`,+  `hydra.lib.flows.withDefault`, `hydra.lib.flows.foldl`,+  `hydra.lib.math.{max,min,abs,pred,signum,succ,even,odd}`,+  `hydra.lib.pairs.bimap`, `hydra.lib.eithers.bind`,+  `hydra.lib.literals.binaryToBytes`, complete `readXxx`/`showXxx` families,+  `hydra.lexical.chooseUniqueName`, `neg` renamed to `negate`,+  full floating-point math primitives in Python ([#208](https://github.com/CategoricalData/hydra/issues/208)).+- DeepCore DSL: a layer one level deeper than the Meta DSLs,+  for programs that construct programs that construct terms.+- `typeOf` implementation ([#168](https://github.com/CategoricalData/hydra/issues/168)).+- Implement `Comparable` for generated Java classes ([#131](https://github.com/CategoricalData/hydra/issues/131)); update of Hydra-Java ([#166](https://github.com/CategoricalData/hydra/issues/166)).+- Compact labeled records exploration ([#122](https://github.com/CategoricalData/hydra/issues/122)).+- Comparison primitives without typeclasses ([#187](https://github.com/CategoricalData/hydra/issues/187)).+- Investigated core support for Either and Flow monads ([#200](https://github.com/CategoricalData/hydra/issues/200)).++### Improvements++- Type system:+  - Refactored `hydra.inference` to create new module `hydra.checking`.+  - Inference checks after unification to prevent schema names from being unified+    with inferred type variables.+  - Type application terms preserved when preparing application terms for Python.+  - Sanity-check tuple projection index against arity during inference.+  - Bind lost type variables in term annotations.+  - Made `extendTypeContextForLet` tolerant of untyped bindings.+- Code generation:+  - Python: support for deeply-nested match statements; more complete `let` support;+    Pythonic syntax for polymorphic function definitions; refinements for complex+    case-hoisting scenarios; performance improvements ([#209](https://github.com/CategoricalData/hydra/issues/209), [#239](https://github.com/CategoricalData/hydra/issues/239), [#240](https://github.com/CategoricalData/hydra/issues/240)); inline+    let/case rewriting for Python targets ([#203](https://github.com/CategoricalData/hydra/issues/203)).+  - Java: method declaration style consistent with calling style.+  - Haskell: standardized typeclass names.+  - Increased maximum trace depth to support more complex sources.+- Common test suite promotion: all tests promoted into a shared, implementation-independent+  test kernel ([#213](https://github.com/CategoricalData/hydra/issues/213)).+- Statically-compiled test suite in Haskell ([#207](https://github.com/CategoricalData/hydra/issues/207)).+- Included all Hydra kernel types in test schema ([#205](https://github.com/CategoricalData/hydra/issues/205)).+- Reorganized Haskell DSL definitions; standardized imports.+- Added TODO comments to all unsafe primitives ([#201](https://github.com/CategoricalData/hydra/issues/201)).+- New `rewriteAndFoldTerm` utility for simultaneous rewriting and folding.+- Lexical helper for dereferencing schema types through aliases.+- Made JSON parser lazy with new `lazy` parser combinator.+- More efficient substitution helpers for empty substitutions.+- Precomputed type/inference context in kernel test runner for performance.+- Property graph encoding and decoding modules promoted into DSL.+- `hydra.tabular` and `hydra.pg.graphson` modules promoted into DSL.+- `hydra.show.*` modules generated into Java and Python.+- Aligned epsilon encoding with the LambdaGraph spec ([#89](https://github.com/CategoricalData/hydra/issues/89)).+- Fixed asymmetry of introductions and eliminations ([#86](https://github.com/CategoricalData/hydra/issues/86), [#134](https://github.com/CategoricalData/hydra/issues/134)).+- Minimized inferred type annotations ([#114](https://github.com/CategoricalData/hydra/issues/114)).+- Investigated combining products with records, sums with unions ([#196](https://github.com/CategoricalData/hydra/issues/196), [#212](https://github.com/CategoricalData/hydra/issues/212)).+- Refined type reduction in adapters ([#144](https://github.com/CategoricalData/hydra/issues/144)).+- Investigation of unification issues ([#163](https://github.com/CategoricalData/hydra/issues/163)).+- Refactored RowType ([#82](https://github.com/CategoricalData/hydra/issues/82)).+- LLM-assisted PG schemas and mappings ([#171](https://github.com/CategoricalData/hydra/issues/171)).+- Simplified unit-valued variants in Python ([#206](https://github.com/CategoricalData/hydra/issues/206)).+- Checked for inconsistencies between Term/TTerm and Type/TType DSLs ([#218](https://github.com/CategoricalData/hydra/issues/218)).+- GenPG demo: refactored to support Haskell, Python, and Java; Python runner;+  Java generation; finalized output format.+- Testing: extended test runners for let hoisting (Haskell, Python, Java);+  floating-point precision tests; ordering tests for `hydra.lib.maps`/`hydra.lib.sets`;+  inference tests for inferred System F terms; case-hoisting test cases; new JSON coder tests;+  thorough test cases for all primitives ([#199](https://github.com/CategoricalData/hydra/issues/199)).++### Bug fixes++- Fixed interpreter bugs causing test failures ([#235](https://github.com/CategoricalData/hydra/issues/235)).+- Fixed bug in type checking in connection with dead code.+- Fixed bug in `removeTypesFromTerm`.+- Fixed bug in `typeOfMap`.+- Fixed 32-bit max int value in `hydra.constants`.+- Fixed numeric precision in Python.+- Added `BigDecimal` support and fixed `uint8` (short) support in Java.+- Fixed Haskell coder with respect to imports for binary literals.+- Excluded `Prelude.encodeFloat` and `Prelude.decodeFloat` from generated Haskell+  due to name collisions.+- Fixed consistency issues in Python primitives:+  `hydra.lib.sets.toList`, `hydra.lib.maps.union` (precedence),+  `hydra.lib.strings.lines`, `hydra.lib.strings.readString` (dequoting),+  `hydra.lib.lists.apply`, `hydra.lib.maps.toList`.+- Fixed Haskell type signature of `hydra.lists.span`.+- Fixed issue with eta expansion of typed terms.+- Fixed shadowing issue in generated encoding modules.+- Added missing alternatives in `hydra.rewriting.rewriteTermM`.++### Documentation++- Updated main README with complete implementation status.+- Added Documentation sections to all implementation READMEs.+- Fixed outdated Code-organization.md (Python now uses `src/gen-main`).+- Fixed incorrect code paths in Implementation.md.+- Added Java section to Testing wiki.+- Comprehensive developer recipes in `docs/recipes/`.+- Documentation for tail-call optimization implementation.+- Added Haddock comments to Haskell primitives.+- Created wiki page on the release process ([#194](https://github.com/CategoricalData/hydra/issues/194)).++### Community++- Accepted babeloff's `isTrivialTerm` changes.++---++## [0.12.0] - 2025-08-28++A consolidation release: significant Python progress, kernel-level cleanup,+and a wave of bookkeeping closures for Hydra-Java module ports.++### Breaking changes++- Removed `hydra.decoding` module ([#190](https://github.com/CategoricalData/hydra/issues/190)).+- Flattened dependency tiers; eliminated tier-1, tier-2, tier-3 organization ([#184](https://github.com/CategoricalData/hydra/issues/184)).+- Removed `typed` term variant ([#173](https://github.com/CategoricalData/hydra/issues/173), [#162](https://github.com/CategoricalData/hydra/issues/162)).+- Module naming changes: moved tabular and relational modules into kernel ([#152](https://github.com/CategoricalData/hydra/issues/152)).+- Standardized on uncurried helper functions in term-level DSLs ([#174](https://github.com/CategoricalData/hydra/issues/174)).+- Renamed `hydra.lib.flows.traverseOptional` to `hydra.lib.flows.mapOptional`.+- Eliminated camel-cased namespace parts from the kernel ([#152](https://github.com/CategoricalData/hydra/issues/152)).+- Replaced list and optional eliminations with primitive functions ([#150](https://github.com/CategoricalData/hydra/issues/150)).+- Moved `Hydra.Ext` to hydra-ext ([#178](https://github.com/CategoricalData/hydra/issues/178)); moved 'ext' sources into hydra-ext ([#189](https://github.com/CategoricalData/hydra/issues/189)).++### New features++- Significant progress toward Hydra-Python completion:+  generated all kernel types and terms into Python;+  added `Decimal` support for bigfloat values;+  environment tracking for variable scoping;+  generated `hydra.languages` into Python;+  `__hash__` and `__eq__` on serializable generated classes ([#160](https://github.com/CategoricalData/hydra/issues/160)).+- Designated `unit` term and type variants ([#186](https://github.com/CategoricalData/hydra/issues/186)).+- `hydra.lib.flows.mapElems` and `hydra.lib.flows.mapKeys` utilities.+- Promoted JSON coder into the DSL ([#181](https://github.com/CategoricalData/hydra/issues/181)).+- Promoted JSON utilities into the DSL ([#181](https://github.com/CategoricalData/hydra/issues/181)).+- C# coder ([#139](https://github.com/CategoricalData/hydra/issues/139)).+- GQL model and parser ([#140](https://github.com/CategoricalData/hydra/issues/140)).+- Tabular adapters ([#142](https://github.com/CategoricalData/hydra/issues/142)).+- Type-level C++ coder ([#170](https://github.com/CategoricalData/hydra/issues/170)).+- Variable-types-to-Haskell-typedefs transformation ([#70](https://github.com/CategoricalData/hydra/issues/70)).+- A newline at the end of each generated file ([#154](https://github.com/CategoricalData/hydra/issues/154)).+- Refactor kernel modules and primitives by connectivity ([#177](https://github.com/CategoricalData/hydra/issues/177)).++### Improvements++- Condensed repeated elements in error traces ([#165](https://github.com/CategoricalData/hydra/issues/165)).+- Fixed transitive schema dependencies ([#185](https://github.com/CategoricalData/hydra/issues/185)).+- Improved adapter solution with respect to literals.+- Better handling of type variables in Python coder.+- Enhanced term-level Python generation with proper ordering to minimize forward references.+- Topo-sort helper function for dependency management.+- Updated all Python libraries with latest changes.+- Distinguished between deannotation and detyping of terms.+- Adapted primitives when applying language constraints to a graph.+- Use unqualified names where possible in generated code ([#153](https://github.com/CategoricalData/hydra/issues/153)).+- Eliminated `Data.Graph` (containers) dependency ([#167](https://github.com/CategoricalData/hydra/issues/167)).+- "Close the loop" demonstration ([#175](https://github.com/CategoricalData/hydra/issues/175)).+- Implemented `typeOf` ([#168](https://github.com/CategoricalData/hydra/issues/168)).++### Bug fixes++- Fixed System F terms for records and case statements ([#168](https://github.com/CategoricalData/hydra/issues/168)).+- Fixed issue with transitive type-level module dependencies ([#185](https://github.com/CategoricalData/hydra/issues/185)).+- Corrected handling of variable references in Python application terms.+- Fixed nullary functions in Python (added empty parens).+- Added missing alternatives in `hydra.rewriting.rewriteTermM`.++### Bookkeeping++- Closed long-standing Hydra-Java module-port issues+  ([#9](https://github.com/CategoricalData/hydra/issues/9), [#11](https://github.com/CategoricalData/hydra/issues/11), [#15](https://github.com/CategoricalData/hydra/issues/15), [#16](https://github.com/CategoricalData/hydra/issues/16), [#18](https://github.com/CategoricalData/hydra/issues/18), [#19](https://github.com/CategoricalData/hydra/issues/19), [#20](https://github.com/CategoricalData/hydra/issues/20), [#21](https://github.com/CategoricalData/hydra/issues/21), [#22](https://github.com/CategoricalData/hydra/issues/22), [#23](https://github.com/CategoricalData/hydra/issues/23), [#25](https://github.com/CategoricalData/hydra/issues/25), [#44](https://github.com/CategoricalData/hydra/issues/44), [#45](https://github.com/CategoricalData/hydra/issues/45));+  most of the underlying work shipped in earlier releases.+- Closed Hydra-Java DSL-port issues ([#24](https://github.com/CategoricalData/hydra/issues/24), [#26](https://github.com/CategoricalData/hydra/issues/26), [#27](https://github.com/CategoricalData/hydra/issues/27), [#28](https://github.com/CategoricalData/hydra/issues/28), [#29](https://github.com/CategoricalData/hydra/issues/29)) and+  the Scala/Avro tracking issues ([#77](https://github.com/CategoricalData/hydra/issues/77), [#81](https://github.com/CategoricalData/hydra/issues/81)); these had been resolved+  by earlier releases (Scala in 0.14.0, Avro bidi in 0.14.0).++### Documentation++- Updated Hydra-Haskell README.+- Updated Hydra-Java README with corrected links.+- Updated JavaDocs.++---++## [0.11.0] - 2025-03-16++Untagged in-repository version.+A type-inference rebase release: major restructuring of inference internals+to align with Algorithm W, plus a sweeping removal of explicit type annotations+across the kernel.++### Highlights++- **Inference rebased on Algorithm W** ([#118](https://github.com/CategoricalData/hydra/issues/118)): unify-early strategy ([#146](https://github.com/CategoricalData/hydra/issues/146)),+  infinite-type checks restored ([#116](https://github.com/CategoricalData/hydra/issues/116)), recursive-element inference ([#90](https://github.com/CategoricalData/hydra/issues/90)),+  unified handling of elements and let bindings ([#112](https://github.com/CategoricalData/hydra/issues/112)), minimized manual+  type annotations ([#119](https://github.com/CategoricalData/hydra/issues/119)).+- **`hydra.inference` module** introduced for inference type definitions;+  substitution and unification moved up a level.++### Breaking changes++- Argument order of `Logic.ifElse` changed ([#147](https://github.com/CategoricalData/hydra/issues/147)).++### New features++- Inference test cases promoted into the common test suite ([#148](https://github.com/CategoricalData/hydra/issues/148));+  added "kernel examples" inference tests; more recursion / mutual recursion cases.++### Improvements++- Removed type annotations across all kernel sources ([#119](https://github.com/CategoricalData/hydra/issues/119)).+- Migrated to fully-applied primitive library DSLs ([#157](https://github.com/CategoricalData/hydra/issues/157)).+- Aligned `Graph` and `Element` with `LetBinding` ([#159](https://github.com/CategoricalData/hydra/issues/159)).+- `hydra.core.Unit` recognized by the Haskell coder.+- Refactored inference tests.++### Bug fixes++- Fix for underdetermined type in `hydra.decode`.++---++## [0.10.0] - 2025-02-19++Untagged in-repository version.+Adds Hydra-Python (initial completion), a GraphSON coder,+provisional Hydra-Go support, and dot-separated namespace conventions.++### Highlights++- **Hydra-Python initial completion** ([#80](https://github.com/CategoricalData/hydra/issues/80), [#66](https://github.com/CategoricalData/hydra/issues/66)): Python coder, generated kernel+  modules in Python, and full library implementations across kernel namespaces.+- **GraphSON coder** ([#79](https://github.com/CategoricalData/hydra/issues/79)).+- **Provisional Hydra-Go** ([#65](https://github.com/CategoricalData/hydra/issues/65)).+- **Namespace formatting** standardized to dot-separated form ([#151](https://github.com/CategoricalData/hydra/issues/151)).++### Breaking changes++- All namespaces use dot-separated form ([#151](https://github.com/CategoricalData/hydra/issues/151)).++### New features++- Hydra-Python: Python coder; generated `hydra.coreEncoding`, `hydra.strip`,+  `hydra.literals` and other kernel modules in Python; tuple-expression support;+  updated `hydra.constants` in Python.+- GraphSON coder ([#79](https://github.com/CategoricalData/hydra/issues/79)).+- Provisional Hydra-Go ([#65](https://github.com/CategoricalData/hydra/issues/65)).+- `string-to-char-list` and `char-list-to-string` primitives ([#149](https://github.com/CategoricalData/hydra/issues/149)).+- Restored normalization for generated term variables ([#145](https://github.com/CategoricalData/hydra/issues/145)).++### Improvements++- Re-leveled dependency tiers ([#135](https://github.com/CategoricalData/hydra/issues/135)).+- Updated all Java, Haskell, hydra-ext, and Python primitives to current sources.++---++## [0.9.0] - 2025-01-06++Untagged in-repository version.+Bootstraps Hydra-Python and the JSON Schema coder; introduces a fluent Java DSL for flows.++### Highlights++- **JSON Schema coder** ([#141](https://github.com/CategoricalData/hydra/issues/141)).+- **Python coder scaffold**: serde, language constraints, and generated Haskell+  sources for Python.+- **Fluent-style Java DSL for flows** ([#143](https://github.com/CategoricalData/hydra/issues/143)).++### New features++- JSON Schema coder ([#141](https://github.com/CategoricalData/hydra/issues/141)).+- Python coder scaffold and serde.+- Provisional Python language constraints module.+- Fluent-style Java DSL for flows ([#143](https://github.com/CategoricalData/hydra/issues/143)); moved Flows DSL into `hydra.dsl`.+- New `hydra.coders` DSL.+- New DSL functions for core variants.++### Improvements++- Generalized `Namespaces` so it can be used for languages other than Haskell.+- Local-name-only Python type aliases (the directory tree provides the namespace).+- Coders DSL used to simplify Java language-constraint sources.+- Removed redundant productions in the Python grammar.+- Added unit tests for fluent flows.++### Documentation++- Updated JavaDocs for 0.9.0.++---++## [0.8.1] - 2024-09-24++Patch release.++### Improvements++- Generalized the property graph merging utility to accept type systems other than Hydra Core.++---++## [0.8.0] - 2024-09-09++C# support ([#139](https://github.com/CategoricalData/hydra/issues/139)), Graphviz DOT coder, term accessors, and a small breaking change in Java+to support Spark.++### Breaking changes++- Made `FlowException` serializable for Spark support (may affect existing error handling).++### New features++- C# syntax module based on the Microsoft ANTLR grammar ([#139](https://github.com/CategoricalData/hydra/issues/139)).+- Graphviz DOT coder ([#136](https://github.com/CategoricalData/hydra/issues/136)):+  full support for lambdas and recursive `let` statements;+  compact 'accessor graph' visualization option;+  customizable label styles;+  highlighted let-bound terms; edge labels.+- Term accessor type to facilitate lenses and path-aware transformations.+- OpenGQL grammar and generated Haskell for the OpenGQL model ([#140](https://github.com/CategoricalData/hydra/issues/140)).++### Improvements++- Added `</>` as alternative to `@@` application operator in Haskell DSLs.+- Utilities for working with term accessors.+- More specific exception class for JSON decoding.+- Additional convenience methods on `JsonDecoding.java`.+- Used transitive dependencies in hydra-java and hydra-ext.+- Upgraded ANTLR to address a vulnerability.+- Moved TinkerPop utilities from `hydra/ext/org/apache/tinkerpop` into `hydra/pg`.++---++## [0.7.0] - 2024-08-21++Major refactoring of module organization and namespace management.+Establishes the DNS-style namespace convention in hydra-ext+and lifts property-graph models into a top-level `hydra/pg` namespace.++### Breaking changes++- Namespace reorganization: migrated to DNS-based module naming in hydra-ext ([#138](https://github.com/CategoricalData/hydra/issues/138)):+  `hydra/ext/avro` → `hydra/ext/org/apache/avro`,+  `hydra/ext/graphql` → `hydra/ext/org/graphql`,+  `hydra/ext/yaml` → `hydra/ext/org/yaml`,+  `hydra/ext/json/decoding` → `hydra/ext/org/json/decoding`,+  `hydra/ext/rdf` → `hydra/ext/org/w3/rdf`,+  `hydra/ext/shacl` → `hydra/ext/org/w3/shacl`,+  `hydra/ext/tinkerpop` → `hydra/ext/org/apache/tinkerpop`.+- Property graphs: promoted property graph modules from+  `hydra/ext/org/apache/tinkerpop` to `hydra/pg`.+- Project structure: renamed `hydra-extensions` to `hydra-ext`;+  renamed `hydra/langs` to `hydra/ext` ([#138](https://github.com/CategoricalData/hydra/issues/138));+  made hydra-ext into a Gradle subproject alongside hydra-java;+  added top-level Gradle build.++### Improvements++- Moved TinkerPop modules from hydra-haskell into hydra-ext for better separation.+- Moved miscellaneous models to `Hydra.Ext.Other` ([#138](https://github.com/CategoricalData/hydra/issues/138)).+- Moved XML Schema, SQL, ShEx, and OWL models to hydra-ext.+- Moved KQL, Parquet, and Python modules to hydra-ext.+- Separated JavaDocs for hydra-java and hydra-ext.+- Updated publishing configuration in `build.gradle`.++---++## [0.6.0] - 2024-08-19++Type-system improvements (System F type abstraction/application; eliminated polymorphic+types from Hydra Core), expanded language support (Graphviz DOT model, generated Java+field-name constants), and revamped annotation handling.++### Breaking changes++- Eliminated `InferenceContext` helper type ([#103](https://github.com/CategoricalData/hydra/issues/103)).+- Changed typing environment from `Map Name Type` to `Map Name TypeScheme` in graphs ([#76](https://github.com/CategoricalData/hydra/issues/76)).+- Updated annotations and flows to use `map<Name, Term>` instead of `map<string, Term>` ([#133](https://github.com/CategoricalData/hydra/issues/133)).+- Unified `Name` and `FieldName`; aliased to `string` ([#121](https://github.com/CategoricalData/hydra/issues/121)).+- Renamed `hydra/core.UnitType` to `hydra/core.Unit` ([#123](https://github.com/CategoricalData/hydra/issues/123)).+- Eliminated annotation classes; Hydra has a single built-in notion of annotations ([#113](https://github.com/CategoricalData/hydra/issues/113)).+- Unified the `Nominal` type with `RowType` ([#115](https://github.com/CategoricalData/hydra/issues/115)).+- Removed the `extends` parameter for row types ([#132](https://github.com/CategoricalData/hydra/issues/132)).+- Replaced `hydra/Kv` with `hydra/Annotations` (rename revisited).++### New features++- System F support: `typeAbstraction` and `typeApplication` term constructors.+- Python3 syntax model based on the official Python BNF ([#80](https://github.com/CategoricalData/hydra/issues/80)).+- Graphviz DOT model and initial support ([#136](https://github.com/CategoricalData/hydra/issues/136)).+- Field-name constants generated in Java code generation ([#137](https://github.com/CategoricalData/hydra/issues/137)).+- Provisional Algorithm W implementation in Haskell (originally from @wisnesky), kept for reference.++### Improvements++- Primitive organization: Hydra primitives organized into libraries for namespace management.+- Code generation:+  - Escaped field name constants and `with_` methods in Java coder.+  - Generated field name constants in Java ([#137](https://github.com/CategoricalData/hydra/issues/137)).+  - Avoided duplicated comments in wrapper classes in generated Java.+  - Removed superfluous newtype comments in Haskell coder.+- Updated Delta Parquet model to follow the Java API more closely.+- Enriched OpenCypher features module with the complete list of standard Cypher functions.+- Added convenience methods to `JsonEncoding.java`.+- Restored `Hydra.Inference` subdirectory.+- Allowed arbitrary case for element names ([#7](https://github.com/CategoricalData/hydra/issues/7)).+- Corrected `uint8` representation in Java to `Short` ([#120](https://github.com/CategoricalData/hydra/issues/120)).++### Bug fixes++- Fixed handling of type annotations in term adapters.+- Fixed decoding of encoded terms annotated with a type.+- Corrected encoding of universal types in `showTerm` ([#117](https://github.com/CategoricalData/hydra/issues/117)).++---++## [0.5.3] - 2024-08-06++Patch release.+Preserves order of map key/value pairs and set elements during JSON serialization.++### Bug fixes++- Preserved ordering of key/value pairs and set elements in JSON output.++### New features++- Polymorphic `equal` primitive in Haskell and Java.+- Generated Hydra type definitions together with native instantiations of Hydra types+  in Haskell (a stepping stone toward generated coders, [#47](https://github.com/CategoricalData/hydra/issues/47)).++---++## [0.5.1] - 2024-08-01++Patch release.+Dependency updates and minor improvements following the 0.5.0 Hydra Core overhaul.++### Improvements++- Updated dependencies.++---++## [0.5.0] - 2024-07-26++Untagged in-repository version.+Major Hydra Core overhaul: eliminates polymorphic types in favor of explicit+TypeScheme; consolidates the annotation system; revamps `Let` term encoding.++### Breaking changes++- Eliminated polymorphic types from Hydra Core in Haskell ([#125](https://github.com/CategoricalData/hydra/issues/125)):+  removed type parameters from `hydra/core` types in Hydra-Java; replaced type schemes+  with forall types ([#76](https://github.com/CategoricalData/hydra/issues/76)).+- Revamped core encoding and `Let`: bindings are now a list of+  `(name, term, optional type scheme)` triplets instead of a map.+- Unified typed-term types and moved `TypeScheme` into Hydra Core.+- Eliminated `AnnotationClass`; Hydra has a single built-in notion of annotations now ([#113](https://github.com/CategoricalData/hydra/issues/113)).+- Renamed and refactored phantom-type wrappers ([#128](https://github.com/CategoricalData/hydra/issues/128)); removed deprecated `Reference`+  type from `hydra/phantoms`.+- Removed incomplete support for stream types and stream terms ([#88](https://github.com/CategoricalData/hydra/issues/88)).++### New features++- `LiteralTypes` DSL module so literals can be built independently of terms.+- `Hydra.Minimal` module to facilitate collaboration on Hydra application prototypes.+- `TypeConstraint` type added to the kernel.+- `foldl` primitive in Haskell and Java; DSL uses `foldl` instead of the built-in+  list elimination term by default.++### Improvements++- Improvements to Java and JSON coders; improved untyped JSON coder.+- Pre-order and post-order term-traversal test cases added.+- Refactored type inference tests.+- Restored generated Java (Core through Tier 3) with only a few manual tweaks.+- Element names allow arbitrary case ([#7](https://github.com/CategoricalData/hydra/issues/7)).++---++## [0.4.0] - 2024-07-10++Untagged in-repository version.+Adds null checks to generated Java (breaking, but justified — Hydra-Java disallows nulls),+the Gremlin model, and Protobuf annotation refinements.++### Breaking changes++- Null checks added to constructors and `withXXX()` methods in generated Java;+  null values are no longer permitted in Hydra-Java.+- Removed Java 8 restriction (raised minimum Java version).++### New features++- Gremlin model ([#127](https://github.com/CategoricalData/hydra/issues/127)); generated Haskell for Gremlin.+- `hydra/lib/lists.safeHead` primitive in Haskell (necessary in Java due to eager evaluation).+- Support for Protobuf `deprecated=true` annotation; non-string Protobuf options.+- Java options in generated Protobuf.++### Improvements++- Used `java.util.Objects.requireNonNull` instead of a custom null check in generated Java.+- Added 'automatically generated file' disclaimer to generated Java files.+- Added autogen comments and null checks to (most) generated Java.+- Added necessary schema-level dependencies for built-in modules.+- Added null checks to the Flows DSL in Java.++---++## [0.3.0] - 2024-06-05++Untagged in-repository version.+Adds an OpenCypher parser based on an ANTLR grammar ([#124](https://github.com/CategoricalData/hydra/issues/124)),+a KQL (Kusto Query Language) model and serializer,+a Delta Parquet model,+and an early property graph queries model in the style of Cypher.++### New features++- OpenCypher parser based on the OpenCypher M23 ANTLR grammar ([#124](https://github.com/CategoricalData/hydra/issues/124));+  ANTLR added as a build dependency;+  large Cypher test suite drawn from the Cypher Manual.+- Cypher-to-PG-query transformer (Java; partially implemented).+- Property graph queries DSL and generated property graph query classes in Java.+- Property graph queries model (Cypher / future GQL style).+- KQL (Kusto Query Language) initial model and basic serializer.+- Delta Parquet model with generated sources.++### Improvements++- Java options and `deprecated=true` support in generated Protobuf.+- Convenience methods in Java.++---++## [0.2.0] - 2024-01-10++Hydra-Java 0.2.0 release.+Significant Java tooling and DSL build-out, Protobuf bidirectional coder,+Python3 syntax model ([#80](https://github.com/CategoricalData/hydra/issues/80)), property graph validation ([#100](https://github.com/CategoricalData/hydra/issues/100)),+JSON bidirectional support in Java ([#104](https://github.com/CategoricalData/hydra/issues/104)),+OpenCypher initial model ([#108](https://github.com/CategoricalData/hydra/issues/108)),+Cypher unification, and the start of the typed-DSL story in Haskell.++### New features++- Property graph validation: validator type, optionality on property types,+  customizable id/property handling in the merging adapter, fine-tuned validation,+  comprehensive unit tests in Java ([#100](https://github.com/CategoricalData/hydra/issues/100)).+- Bidirectional JSON serialization/deserialization in Java ([#104](https://github.com/CategoricalData/hydra/issues/104)).+- Checkstyle configuration based on Google style guide ([#111](https://github.com/CategoricalData/hydra/issues/111)).+- Python3 syntax model based on the official Python BNF ([#80](https://github.com/CategoricalData/hydra/issues/80)).+- Initial OpenCypher model and parser scaffold ([#108](https://github.com/CategoricalData/hydra/issues/108)).+- Protobuf coder ([#99](https://github.com/CategoricalData/hydra/issues/99)): type encoder, field numbering, formatting, deprecated annotation,+  Java options, non-string options.+- Adapter framework tolerance of recursive types ([#58](https://github.com/CategoricalData/hydra/issues/58)); default branch for case+  statements ([#60](https://github.com/CategoricalData/hydra/issues/60)).+- Topological sort in type inference ([#67](https://github.com/CategoricalData/hydra/issues/67)).+- `hydra/query` model ([#73](https://github.com/CategoricalData/hydra/issues/73)).+- Records-to-TinkerPop-elements coder ([#64](https://github.com/CategoricalData/hydra/issues/64)).+- Equality primitives for all literal types ([#92](https://github.com/CategoricalData/hydra/issues/92)); polymorphic logic primitives ([#95](https://github.com/CategoricalData/hydra/issues/95)).+- `mapKeys` primitive ([#93](https://github.com/CategoricalData/hydra/issues/93)).+- Tuple support in Java ([#94](https://github.com/CategoricalData/hydra/issues/94)).+- Java 8 as an optional target ([#96](https://github.com/CategoricalData/hydra/issues/96)); optionally generate Java classes as `Serializable` ([#97](https://github.com/CategoricalData/hydra/issues/97)).+- Bidirectional "merged vertex" and "merged edge" coders ([#106](https://github.com/CategoricalData/hydra/issues/106)).+- Nullability and parameterization in the tabular model ([#107](https://github.com/CategoricalData/hydra/issues/107)).+- Term-level / type-level dependency distinction for modules ([#109](https://github.com/CategoricalData/hydra/issues/109)).+- Flatten nested `let` terms for transformation into Java ([#110](https://github.com/CategoricalData/hydra/issues/110)).+- Various `Flow` utilities in Java: `bind3`; convenience methods for consuming results;+  `fromFlow` variants including one that throws.++### Improvements++- Hydra-Java module ports ([#10](https://github.com/CategoricalData/hydra/issues/10), [#12](https://github.com/CategoricalData/hydra/issues/12), [#13](https://github.com/CategoricalData/hydra/issues/13), [#14](https://github.com/CategoricalData/hydra/issues/14), [#17](https://github.com/CategoricalData/hydra/issues/17), [#30](https://github.com/CategoricalData/hydra/issues/30), [#31](https://github.com/CategoricalData/hydra/issues/31), [#32](https://github.com/CategoricalData/hydra/issues/32), [#33](https://github.com/CategoricalData/hydra/issues/33), [#34](https://github.com/CategoricalData/hydra/issues/34), [#35](https://github.com/CategoricalData/hydra/issues/35),+  [#38](https://github.com/CategoricalData/hydra/issues/38), [#39](https://github.com/CategoricalData/hydra/issues/39), [#41](https://github.com/CategoricalData/hydra/issues/41), [#43](https://github.com/CategoricalData/hydra/issues/43), [#48](https://github.com/CategoricalData/hydra/issues/48), [#71](https://github.com/CategoricalData/hydra/issues/71), [#72](https://github.com/CategoricalData/hydra/issues/72), [#75](https://github.com/CategoricalData/hydra/issues/75), [#83](https://github.com/CategoricalData/hydra/issues/83)):+  `Common`, `CoreEncoding`, `CoreLanguage`, `Kernel`, `Flows`, `Lists`, `Literals`,+  `Math`, `Sets`, `Strings`, `Optionals`, `Maps`, `Flows` primitives, `Sets` primitives.+- Common DSLs in Haskell: Flow support ([#68](https://github.com/CategoricalData/hydra/issues/68)), Let support ([#69](https://github.com/CategoricalData/hydra/issues/69)).+- Renamed annotation type parameter `m` to `a` ([#41](https://github.com/CategoricalData/hydra/issues/41)).+- Updated wrapper, element, and variable types ([#75](https://github.com/CategoricalData/hydra/issues/75)).+- Removed `schema` field from `Element` ([#83](https://github.com/CategoricalData/hydra/issues/83)).+- GraphQL coder ([#78](https://github.com/CategoricalData/hydra/issues/78)).+- Code quality:+  - Updated main and test sources to conform to Checkstyle configuration ([#111](https://github.com/CategoricalData/hydra/issues/111)).+  - Extended line-length limit from 100 to 120 characters.+  - Disabled overly restrictive indentation and import-order rules.+  - Disabled `RightCurlyAlone` for compact inline map definitions.+- Streamlined property-graph element merging to unify properties with identical+  keys and types ([#106](https://github.com/CategoricalData/hydra/issues/106)).+- Convenience functions for printing literals and literal types in the Java DSL.+- Minor addition to JSON decoding.+- DSL convenience: alphabetic-case flexibility for element names ([#7](https://github.com/CategoricalData/hydra/issues/7)).++### Bug fixes++- Fixed type annotations for the Sets Java port ([#48](https://github.com/CategoricalData/hydra/issues/48)).+- Various minor fixes during the Java module ports.++---++## [0.1.1] - 2022-12-04++Patch release the same day as 0.1.0.+README polish only.++---++## [0.1.0] - 2022-12-04++First packaged release of Hydra (Hackage).+This release contains the complete foundation of Hydra.++### Core language++- Hydra's core type and data languages (`hydra.core`).+- Core models for graphs and modules.+- Computation model with the `Flow` monad.+- BNF grammars support.+- Phantom types.+- Basic operations on types and terms.++### Type system++- Hindley–Milner-style type inference.+- Type schemes with polymorphism.+- Type/term validation.++### Transformations++- Adapter system: type-to-type rewriting and transformation.+- Coders:+  Haskell coder (types and terms),+  Java coder (types and terms),+  partial Scala coder (terms only),+  Avro coder,+  JSON coder,+  PDL (Pegasus Data Language) coder,+  RDF + SHACL coder,+  YAML coder.++### Language support++- Models for GraphQL, OWL (Web Ontology Language), ShEx (Shape Expressions),+  and TinkerPop-style property graphs.++### Developer tools++- Type-construction DSL and term-construction DSL.+- QuickCheck property-based tests.++### Implementations++- Hydra-Haskell: bootstrapping implementation with full kernel.+- Hydra-Java: Java implementation with mature tooling.++### Community++- Set up the LambdaGraph Discord server ([#2](https://github.com/CategoricalData/hydra/issues/2)).++---++## Contributing++We welcome contributions! Please see:++- [Developer recipes](https://github.com/CategoricalData/hydra/tree/main/docs/recipes)+- [LambdaGraph Discord](https://bit.ly/lg-discord)++## Release process++See the [Release policy](https://github.com/CategoricalData/hydra/wiki/Release-policy)+wiki page and [docs/release-workflow.md](docs/release-workflow.md)+for information on how Hydra releases are versioned, built, and published.
+ LICENSE view
@@ -0,0 +1,201 @@+                                 Apache License+                           Version 2.0, January 2004+                        http://www.apache.org/licenses/++   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++   1. Definitions.++      "License" shall mean the terms and conditions for use, reproduction,+      and distribution as defined by Sections 1 through 9 of this document.++      "Licensor" shall mean the copyright owner or entity authorized by+      the copyright owner that is granting the License.++      "Legal Entity" shall mean the union of the acting entity and all+      other entities that control, are controlled by, or are under common+      control with that entity. For the purposes of this definition,+      "control" means (i) the power, direct or indirect, to cause the+      direction or management of such entity, whether by contract or+      otherwise, or (ii) ownership of fifty percent (50%) or more of the+      outstanding shares, or (iii) beneficial ownership of such entity.++      "You" (or "Your") shall mean an individual or Legal Entity+      exercising permissions granted by this License.++      "Source" form shall mean the preferred form for making modifications,+      including but not limited to software source code, documentation+      source, and configuration files.++      "Object" form shall mean any form resulting from mechanical+      transformation or translation of a Source form, including but+      not limited to compiled object code, generated documentation,+      and conversions to other media types.++      "Work" shall mean the work of authorship, whether in Source or+      Object form, made available under the License, as indicated by a+      copyright notice that is included in or attached to the work+      (an example is provided in the Appendix below).++      "Derivative Works" shall mean any work, whether in Source or Object+      form, that is based on (or derived from) the Work and for which the+      editorial revisions, annotations, elaborations, or other modifications+      represent, as a whole, an original work of authorship. For the purposes+      of this License, Derivative Works shall not include works that remain+      separable from, or merely link (or bind by name) to the interfaces of,+      the Work and Derivative Works thereof.++      "Contribution" shall mean any work of authorship, including+      the original version of the Work and any modifications or additions+      to that Work or Derivative Works thereof, that is intentionally+      submitted to Licensor for inclusion in the Work by the copyright owner+      or by an individual or Legal Entity authorized to submit on behalf of+      the copyright owner. For the purposes of this definition, "submitted"+      means any form of electronic, verbal, or written communication sent+      to the Licensor or its representatives, including but not limited to+      communication on electronic mailing lists, source code control systems,+      and issue tracking systems that are managed by, or on behalf of, the+      Licensor for the purpose of discussing and improving the Work, but+      excluding communication that is conspicuously marked or otherwise+      designated in writing by the copyright owner as "Not a Contribution."++      "Contributor" shall mean Licensor and any individual or Legal Entity+      on behalf of whom a Contribution has been received by Licensor and+      subsequently incorporated within the Work.++   2. Grant of Copyright License. Subject to the terms and conditions of+      this License, each Contributor hereby grants to You a perpetual,+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable+      copyright license to reproduce, prepare Derivative Works of,+      publicly display, publicly perform, sublicense, and distribute the+      Work and such Derivative Works in Source or Object form.++   3. Grant of Patent License. Subject to the terms and conditions of+      this License, each Contributor hereby grants to You a perpetual,+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable+      (except as stated in this section) patent license to make, have made,+      use, offer to sell, sell, import, and otherwise transfer the Work,+      where such license applies only to those patent claims licensable+      by such Contributor that are necessarily infringed by their+      Contribution(s) alone or by combination of their Contribution(s)+      with the Work to which such Contribution(s) was submitted. If You+      institute patent litigation against any entity (including a+      cross-claim or counterclaim in a lawsuit) alleging that the Work+      or a Contribution incorporated within the Work constitutes direct+      or contributory patent infringement, then any patent licenses+      granted to You under this License for that Work shall terminate+      as of the date such litigation is filed.++   4. Redistribution. You may reproduce and distribute copies of the+      Work or Derivative Works thereof in any medium, with or without+      modifications, and in Source or Object form, provided that You+      meet the following conditions:++      (a) You must give any other recipients of the Work or+          Derivative Works a copy of this License; and++      (b) You must cause any modified files to carry prominent notices+          stating that You changed the files; and++      (c) You must retain, in the Source form of any Derivative Works+          that You distribute, all copyright, patent, trademark, and+          attribution notices from the Source form of the Work,+          excluding those notices that do not pertain to any part of+          the Derivative Works; and++      (d) If the Work includes a "NOTICE" text file as part of its+          distribution, then any Derivative Works that You distribute must+          include a readable copy of the attribution notices contained+          within such NOTICE file, excluding those notices that do not+          pertain to any part of the Derivative Works, in at least one+          of the following places: within a NOTICE text file distributed+          as part of the Derivative Works; within the Source form or+          documentation, if provided along with the Derivative Works; or,+          within a display generated by the Derivative Works, if and+          wherever such third-party notices normally appear. The contents+          of the NOTICE file are for informational purposes only and+          do not modify the License. You may add Your own attribution+          notices within Derivative Works that You distribute, alongside+          or as an addendum to the NOTICE text from the Work, provided+          that such additional attribution notices cannot be construed+          as modifying the License.++      You may add Your own copyright statement to Your modifications and+      may provide additional or different license terms and conditions+      for use, reproduction, or distribution of Your modifications, or+      for any such Derivative Works as a whole, provided Your use,+      reproduction, and distribution of the Work otherwise complies with+      the conditions stated in this License.++   5. Submission of Contributions. Unless You explicitly state otherwise,+      any Contribution intentionally submitted for inclusion in the Work+      by You to the Licensor shall be under the terms and conditions of+      this License, without any additional terms or conditions.+      Notwithstanding the above, nothing herein shall supersede or modify+      the terms of any separate license agreement you may have executed+      with Licensor regarding such Contributions.++   6. Trademarks. This License does not grant permission to use the trade+      names, trademarks, service marks, or product names of the Licensor,+      except as required for reasonable and customary use in describing the+      origin of the Work and reproducing the content of the NOTICE file.++   7. Disclaimer of Warranty. Unless required by applicable law or+      agreed to in writing, Licensor provides the Work (and each+      Contributor provides its Contributions) on an "AS IS" BASIS,+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+      implied, including, without limitation, any warranties or conditions+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+      PARTICULAR PURPOSE. You are solely responsible for determining the+      appropriateness of using or redistributing the Work and assume any+      risks associated with Your exercise of permissions under this License.++   8. Limitation of Liability. In no event and under no legal theory,+      whether in tort (including negligence), contract, or otherwise,+      unless required by applicable law (such as deliberate and grossly+      negligent acts) or agreed to in writing, shall any Contributor be+      liable to You for damages, including any direct, indirect, special,+      incidental, or consequential damages of any character arising as a+      result of this License or out of the use or inability to use the+      Work (including but not limited to damages for loss of goodwill,+      work stoppage, computer failure or malfunction, or any and all+      other commercial damages or losses), even if such Contributor+      has been advised of the possibility of such damages.++   9. Accepting Warranty or Additional Liability. While redistributing+      the Work or Derivative Works thereof, You may choose to offer,+      and charge a fee for, acceptance of support, warranty, indemnity,+      or other liability obligations and/or rights consistent with this+      License. However, in accepting such obligations, You may act only+      on Your own behalf and on Your sole responsibility, not on behalf+      of any other Contributor, and only if You agree to indemnify,+      defend, and hold each Contributor harmless for any liability+      incurred by, or claims asserted against, such Contributor by reason+      of your accepting any such warranty or additional liability.++   END OF TERMS AND CONDITIONS++   APPENDIX: How to apply the Apache License to your work.++      To apply the Apache License to your work, attach the following+      boilerplate notice, with the fields enclosed by brackets "[]"+      replaced with your own identifying information. (Don't include+      the brackets!)  The text should be enclosed in the appropriate+      comment syntax for the file format. We also recommend that a+      file or class name and description of purpose be included on the+      same "printed page" as the copyright notice for easier+      identification within third-party archives.++   Copyright [yyyy] [name of copyright owner]++   Licensed under the Apache License, Version 2.0 (the "License");+   you may not use this file except in compliance with the License.+   You may obtain a copy of the License at++       http://www.apache.org/licenses/LICENSE-2.0++   Unless required by applicable law or agreed to in writing, software+   distributed under the License is distributed on an "AS IS" BASIS,+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+   See the License for the specific language governing permissions and+   limitations under the License.
+ NOTICE view
@@ -0,0 +1,3 @@+Hydra+Copyright 2021-2026 The Hydra authors+https://github.com/CategoricalData/hydra
+ hydra-ext.cabal view
@@ -0,0 +1,96 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.39.1.+--+-- see: https://github.com/sol/hpack++name:           hydra-ext+version:        0.17.0+synopsis:       Hydra extensions: additional coders and schema integrations+description:    Hydra is an implementation of the LambdaGraph data model, which takes advantage of an isomorphism between labeled hypergraphs and typed lambda calculus: in Hydra, "graphs are programs, and programs are graphs". Various extensions to Hydra+category:       Data+homepage:       https://github.com/CategoricalData/hydra#readme+bug-reports:    https://github.com/CategoricalData/hydra/issues+author:         Joshua Shinavier <josh@fortytwo.net>+maintainer:     Joshua Shinavier <josh@fortytwo.net>+license:        Apache-2.0+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    LICENSE+    NOTICE+    CHANGELOG.md++source-repository head+  type: git+  location: https://github.com/CategoricalData/hydra++library+  exposed-modules:+      Hydra.Atlas+      Hydra.Avro.Coder+      Hydra.Avro.Encoder+      Hydra.Avro.Environment+      Hydra.Avro.Language+      Hydra.Avro.Schema+      Hydra.Avro.SchemaJson+      Hydra.Avro.Testing+      Hydra.Azure.Dtld+      Hydra.Cpp.Coder+      Hydra.Cpp.Environment+      Hydra.Cpp.Language+      Hydra.Cpp.Names+      Hydra.Cpp.Serde+      Hydra.Cpp.Syntax+      Hydra.Cpp.Utils+      Hydra.Csharp.Language+      Hydra.Csharp.Syntax+      Hydra.Datalog.Syntax+      Hydra.Delta.Parquet+      Hydra.Geojson.Model+      Hydra.Graphql.Coder+      Hydra.Graphql.Language+      Hydra.Graphql.Serde+      Hydra.Graphql.Syntax+      Hydra.Iana.Linkrelations+      Hydra.Json.Schema+      Hydra.Json.Schema.Coder+      Hydra.Json.Schema.Language+      Hydra.Json.Schema.Serde+      Hydra.Kusto.Kql+      Hydra.Osv.Schema+      Hydra.Parquet.Format+      Hydra.Pegasus.Coder+      Hydra.Pegasus.Language+      Hydra.Pegasus.Pdl+      Hydra.Pegasus.Serde+      Hydra.Protobuf.Any+      Hydra.Protobuf.Coder+      Hydra.Protobuf.Environment+      Hydra.Protobuf.Language+      Hydra.Protobuf.Proto3+      Hydra.Protobuf.Serde+      Hydra.Protobuf.SourceContext+      Hydra.Rust.Coder+      Hydra.Rust.Language+      Hydra.Rust.Operators+      Hydra.Rust.Serde+      Hydra.Rust.Syntax+      Hydra.Sql.Syntax+      Hydra.Stac.Items+      Hydra.Workflow+      Hydra.Yaml.Coder+      Hydra.Yaml.Language+      Hydra.Yaml.Serde+  other-modules:+      Paths_hydra_ext+  hs-source-dirs:+      src/main/haskell+  build-depends:+      base >=4.19.0 && <4.22+    , bytestring >=0.11.5 && <0.13+    , containers >=0.6.7 && <0.8+    , hydra-kernel ==0.17.0+    , hydra-rdf ==0.17.0+    , scientific >=0.3.7 && <0.4+  default-language: Haskell2010
+ src/main/haskell/Hydra/Atlas.hs view
@@ -0,0 +1,165 @@+-- Note: this is an automatically generated file. Do not edit.+-- | The Apache Atlas meta-model+-- | Based on the the org.apache.atlas.model package in the master branch as of 2022-06-01+-- |   https://github.com/apache/atlas/tree/master/intg/src/main/java/org/apache/atlas/model++module Hydra.Atlas where+import qualified Hydra.Core as Core+import qualified Hydra.Xml.Schema as Schema+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Int as I+import qualified Data.Map as M+import qualified Data.Set as S+-- | class that captures details of a struct-attribute.+data AtlasAttributeDef =+  AtlasAttributeDef {+    atlasAttributeDefName :: (Maybe String),+    atlasAttributeDefTypeName :: (Maybe String),+    atlasAttributeDefIsOptional :: Bool,+    atlasAttributeDefCardinality :: (Maybe AtlasAttributeDef_Cardinality),+    atlasAttributeDefValuesMinCount :: Int,+    atlasAttributeDefValuesMaxCount :: Int,+    atlasAttributeDefIsUnique :: Bool,+    atlasAttributeDefIsIndexable :: Bool,+    atlasAttributeDefIncludeInNotification :: Bool,+    atlasAttributeDefDefaultValue :: (Maybe String),+    atlasAttributeDefDescription :: (Maybe String),+    atlasAttributeDefSearchWeight :: Int,+    atlasAttributeDefIndexType :: (Maybe AtlasAttributeDef_IndexType),+    atlasAttributeDefConstraints :: [AtlasConstraintDef],+    atlasAttributeDefOptions :: (M.Map String String),+    atlasAttributeDefDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_AtlasAttributeDef = Core.Name "hydra.atlas.AtlasAttributeDef"+_AtlasAttributeDef_name = Core.Name "name"+_AtlasAttributeDef_typeName = Core.Name "typeName"+_AtlasAttributeDef_isOptional = Core.Name "isOptional"+_AtlasAttributeDef_cardinality = Core.Name "cardinality"+_AtlasAttributeDef_valuesMinCount = Core.Name "valuesMinCount"+_AtlasAttributeDef_valuesMaxCount = Core.Name "valuesMaxCount"+_AtlasAttributeDef_isUnique = Core.Name "isUnique"+_AtlasAttributeDef_isIndexable = Core.Name "isIndexable"+_AtlasAttributeDef_includeInNotification = Core.Name "includeInNotification"+_AtlasAttributeDef_defaultValue = Core.Name "defaultValue"+_AtlasAttributeDef_description = Core.Name "description"+_AtlasAttributeDef_searchWeight = Core.Name "searchWeight"+_AtlasAttributeDef_indexType = Core.Name "indexType"+_AtlasAttributeDef_constraints = Core.Name "constraints"+_AtlasAttributeDef_options = Core.Name "options"+_AtlasAttributeDef_displayName = Core.Name "displayName"+data AtlasAttributeDef_Cardinality =+  AtlasAttributeDef_CardinalitySingle |+  AtlasAttributeDef_CardinalityList |+  AtlasAttributeDef_CardinalitySet+  deriving (Eq, Ord, Read, Show)+_AtlasAttributeDef_Cardinality = Core.Name "hydra.atlas.AtlasAttributeDef_Cardinality"+_AtlasAttributeDef_Cardinality_single = Core.Name "single"+_AtlasAttributeDef_Cardinality_list = Core.Name "list"+_AtlasAttributeDef_Cardinality_set = Core.Name "set"+data AtlasAttributeDef_IndexType =+  AtlasAttributeDef_IndexTypeDefault |+  AtlasAttributeDef_IndexTypeString+  deriving (Eq, Ord, Read, Show)+_AtlasAttributeDef_IndexType = Core.Name "hydra.atlas.AtlasAttributeDef_IndexType"+_AtlasAttributeDef_IndexType_default = Core.Name "default"+_AtlasAttributeDef_IndexType_string = Core.Name "string"+-- | Base class that captures common-attributes for all Atlas types.+data AtlasBaseTypeDef =+  AtlasBaseTypeDef {+    atlasBaseTypeDefCategory :: (Maybe TypeCategory),+    atlasBaseTypeDefGuid :: (Maybe String),+    atlasBaseTypeDefCreatedBy :: (Maybe String),+    atlasBaseTypeDefUpdatedBy :: (Maybe String),+    atlasBaseTypeDefCreateTime :: (Maybe Schema.DateTime),+    atlasBaseTypeDefUpdateTime :: (Maybe Schema.DateTime),+    atlasBaseTypeDefVersion :: (Maybe I.Int64),+    atlasBaseTypeDefName :: (Maybe String),+    atlasBaseTypeDefDescription :: (Maybe String),+    atlasBaseTypeDefTypeVersion :: (Maybe String),+    atlasBaseTypeDefServiceType :: (Maybe String),+    atlasBaseTypeDefOptions :: (M.Map String String)}+  deriving (Eq, Ord, Read, Show)+_AtlasBaseTypeDef = Core.Name "hydra.atlas.AtlasBaseTypeDef"+_AtlasBaseTypeDef_category = Core.Name "category"+_AtlasBaseTypeDef_guid = Core.Name "guid"+_AtlasBaseTypeDef_createdBy = Core.Name "createdBy"+_AtlasBaseTypeDef_updatedBy = Core.Name "updatedBy"+_AtlasBaseTypeDef_createTime = Core.Name "createTime"+_AtlasBaseTypeDef_updateTime = Core.Name "updateTime"+_AtlasBaseTypeDef_version = Core.Name "version"+_AtlasBaseTypeDef_name = Core.Name "name"+_AtlasBaseTypeDef_description = Core.Name "description"+_AtlasBaseTypeDef_typeVersion = Core.Name "typeVersion"+_AtlasBaseTypeDef_serviceType = Core.Name "serviceType"+_AtlasBaseTypeDef_options = Core.Name "options"+-- | class that captures details of a constraint.+data AtlasConstraintDef =+  AtlasConstraintDef {+    atlasConstraintDefType :: (Maybe String),+    atlasConstraintDefParams :: (M.Map String String)}+  deriving (Eq, Ord, Read, Show)+_AtlasConstraintDef = Core.Name "hydra.atlas.AtlasConstraintDef"+_AtlasConstraintDef_type = Core.Name "type"+_AtlasConstraintDef_params = Core.Name "params"+-- | class that captures details of a entity-type.+data AtlasEntityDef =+  AtlasEntityDef {+    atlasEntityDefAsAtlasStruct :: AtlasStructDef,+    atlasEntityDefSuperTypes :: (S.Set String),+    -- | the value of this field is derived from 'superTypes' specified in all AtlasEntityDef+    atlasEntityDefSubTypes :: (S.Set String),+    -- | the value of this field is derived from all the relationshipDefs this entityType is referenced in+    atlasEntityDefRelationshipAttributeDefs :: [AtlasRelationshipAttributeDef],+    -- | the value of this field is derived from all the businessMetadataDefs this entityType is referenced in+    atlasEntityDefBusinessAttributeDefs :: (M.Map String [AtlasAttributeDef])}+  deriving (Eq, Ord, Read, Show)+_AtlasEntityDef = Core.Name "hydra.atlas.AtlasEntityDef"+_AtlasEntityDef_asAtlasStruct = Core.Name "asAtlasStruct"+_AtlasEntityDef_superTypes = Core.Name "superTypes"+_AtlasEntityDef_subTypes = Core.Name "subTypes"+_AtlasEntityDef_relationshipAttributeDefs = Core.Name "relationshipAttributeDefs"+_AtlasEntityDef_businessAttributeDefs = Core.Name "businessAttributeDefs"+-- | class that captures details of a struct-attribute.+data AtlasRelationshipAttributeDef =+  AtlasRelationshipAttributeDef {+    atlasRelationshipAttributeDefAsAtlasAttribute :: AtlasAttributeDef,+    atlasRelationshipAttributeDefRelationshipTypeName :: (Maybe String),+    atlasRelationshipAttributeDefIsLegacyAttribute :: Bool}+  deriving (Eq, Ord, Read, Show)+_AtlasRelationshipAttributeDef = Core.Name "hydra.atlas.AtlasRelationshipAttributeDef"+_AtlasRelationshipAttributeDef_asAtlasAttribute = Core.Name "asAtlasAttribute"+_AtlasRelationshipAttributeDef_relationshipTypeName = Core.Name "relationshipTypeName"+_AtlasRelationshipAttributeDef_isLegacyAttribute = Core.Name "isLegacyAttribute"+-- | class that captures details of a struct-type.+data AtlasStructDef =+  AtlasStructDef {+    atlasStructDefAsAtlasBaseType :: AtlasBaseTypeDef,+    atlasStructDefAttributeDefs :: [AtlasAttributeDef]}+  deriving (Eq, Ord, Read, Show)+_AtlasStructDef = Core.Name "hydra.atlas.AtlasStructDef"+_AtlasStructDef_asAtlasBaseType = Core.Name "asAtlasBaseType"+_AtlasStructDef_attributeDefs = Core.Name "attributeDefs"+data TypeCategory =+  TypeCategoryPrimitive |+  TypeCategoryObjectIdType |+  TypeCategoryEnum |+  TypeCategoryStruct |+  TypeCategoryClassification |+  TypeCategoryEntity |+  TypeCategoryArray |+  TypeCategoryMap |+  TypeCategoryRelationship |+  TypeCategoryBusinessMetadata+  deriving (Eq, Ord, Read, Show)+_TypeCategory = Core.Name "hydra.atlas.TypeCategory"+_TypeCategory_primitive = Core.Name "primitive"+_TypeCategory_objectIdType = Core.Name "objectIdType"+_TypeCategory_enum = Core.Name "enum"+_TypeCategory_struct = Core.Name "struct"+_TypeCategory_classification = Core.Name "classification"+_TypeCategory_entity = Core.Name "entity"+_TypeCategory_array = Core.Name "array"+_TypeCategory_map = Core.Name "map"+_TypeCategory_relationship = Core.Name "relationship"+_TypeCategory_businessMetadata = Core.Name "businessMetadata"
+ src/main/haskell/Hydra/Avro/Coder.hs view
@@ -0,0 +1,614 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Avro-to-Hydra adapter for converting Avro schemas and data to Hydra types and terms++module Hydra.Avro.Coder where+import qualified Hydra.Ast as Ast+import qualified Hydra.Avro.Environment as Environment+import qualified Hydra.Avro.Schema as Schema+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Extract.Core as ExtractCore+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Annotate an adapter's target type with optional annotations+annotateAdapter :: Maybe (M.Map Core.Name Core.Term) -> Coders.Adapter t0 Core.Type t1 t2 Errors.Error -> Coders.Adapter t0 Core.Type t1 t2 Errors.Error+annotateAdapter ann ad =+    Optionals.cases ann ad (\n -> Coders.Adapter {+      Coders.adapterIsLossy = (Coders.adapterIsLossy ad),+      Coders.adapterSource = (Coders.adapterSource ad),+      Coders.adapterTarget = (Core.TypeAnnotated (Core.AnnotatedType {+        Core.annotatedTypeBody = (Coders.adapterTarget ad),+        Core.annotatedTypeAnnotation = (Core.TermMap (Maps.mapKeys (\n2 -> Core.TermVariable n2) n))})),+      Coders.adapterCoder = (Coders.adapterCoder ad)})+-- | Create an adapter between Avro schemas and Hydra types/terms+avroHydraAdapter :: t0 -> Schema.Schema -> Environment.AvroEnvironment -> Either Errors.Error (Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error, Environment.AvroEnvironment)+avroHydraAdapter cx schema env0 =++      let simpleAdapter =+              \env -> \typ -> \encode -> \decode -> Right (+                Coders.Adapter {+                  Coders.adapterIsLossy = False,+                  Coders.adapterSource = schema,+                  Coders.adapterTarget = typ,+                  Coders.adapterCoder = Coders.Coder {+                    Coders.coderEncode = encode,+                    Coders.coderDecode = decode}},+                env)+          doubleToInt = \d -> Literals.bigintToInt32 (Literals.decimalToBigint d)+          doubleToLong = \d -> Literals.bigintToInt64 (Literals.decimalToBigint d)+      in case schema of+        Schema.SchemaArray v0 -> Eithers.bind (avroHydraAdapter cx (Schema.arrayItems v0) env0) (\adEnv ->+          let ad = Pairs.first adEnv+              env1 = Pairs.second adEnv+          in (Right (+            Coders.Adapter {+              Coders.adapterIsLossy = (Coders.adapterIsLossy ad),+              Coders.adapterSource = schema,+              Coders.adapterTarget = (Core.TypeList (Coders.adapterTarget ad)),+              Coders.adapterCoder = Coders.Coder {+                Coders.coderEncode = (\v -> case v of+                  Model.ValueArray v1 -> Eithers.map (\ts -> Core.TermList ts) (Eithers.mapList (\jv -> Coders.coderEncode (Coders.adapterCoder ad) jv) v1)),+                Coders.coderDecode = (\t -> case t of+                  Core.TermList v1 -> Eithers.map (\jvs -> Model.ValueArray jvs) (Eithers.mapList (\tv -> Coders.coderDecode (Coders.adapterCoder ad) tv) v1))}},+            env1)))+        Schema.SchemaMap v0 -> Eithers.bind (avroHydraAdapter cx (Schema.mapValues v0) env0) (\adEnv ->+          let ad = Pairs.first adEnv+              env1 = Pairs.second adEnv+              pairToHydra =+                      \entry ->+                        let k = Pairs.first entry+                            v = Pairs.second entry+                        in (Eithers.map (\v_ -> (Core.TermLiteral (Core.LiteralString k), v_)) (Coders.coderEncode (Coders.adapterCoder ad) v))+          in (Right (+            Coders.Adapter {+              Coders.adapterIsLossy = (Coders.adapterIsLossy ad),+              Coders.adapterSource = schema,+              Coders.adapterTarget = (Core.TypeMap (Core.MapType {+                Core.mapTypeKeys = (Core.TypeLiteral Core.LiteralTypeString),+                Core.mapTypeValues = (Coders.adapterTarget ad)})),+              Coders.adapterCoder = Coders.Coder {+                Coders.coderEncode = (\v -> case v of+                  Model.ValueObject v1 -> Eithers.map (\pairs -> Core.TermMap (Maps.fromList pairs)) (Eithers.mapList (\e -> pairToHydra e) v1)),+                Coders.coderDecode = (\m -> Eithers.map (\mp_ -> Model.ValueObject (Maps.toList mp_)) (ExtractCore.map (\t -> ExtractCore.string (Graph.Graph {+                  Graph.graphBoundTerms = Maps.empty,+                  Graph.graphBoundTypes = Maps.empty,+                  Graph.graphClassConstraints = Maps.empty,+                  Graph.graphLambdaVariables = Sets.empty,+                  Graph.graphMetadata = Maps.empty,+                  Graph.graphPrimitives = Maps.empty,+                  Graph.graphSchemaTypes = Maps.empty,+                  Graph.graphTypeVariables = Sets.empty}) t) (\t -> Coders.coderDecode (Coders.adapterCoder ad) t) (Graph.Graph {+                  Graph.graphBoundTerms = Maps.empty,+                  Graph.graphBoundTypes = Maps.empty,+                  Graph.graphClassConstraints = Maps.empty,+                  Graph.graphLambdaVariables = Sets.empty,+                  Graph.graphMetadata = Maps.empty,+                  Graph.graphPrimitives = Maps.empty,+                  Graph.graphSchemaTypes = Maps.empty,+                  Graph.graphTypeVariables = Sets.empty}) m))}},+            env1)))+        Schema.SchemaNamed v0 ->+          let ns = Schema.namedNamespace v0+              manns = namedAnnotationsToCore v0+              ann = Logic.ifElse (Maps.null manns) Nothing (Just manns)+              lastNs = Environment.avroEnvironmentNamespace env0+              nextNs = Optionals.cases ns lastNs (\s -> Just s)+              env1 =+                      Environment.AvroEnvironment {+                        Environment.avroEnvironmentNamedAdapters = (Environment.avroEnvironmentNamedAdapters env0),+                        Environment.avroEnvironmentNamespace = nextNs,+                        Environment.avroEnvironmentElements = (Environment.avroEnvironmentElements env0)}+              qname =+                      Environment.AvroQualifiedName {+                        Environment.avroQualifiedNameNamespace = nextNs,+                        Environment.avroQualifiedNameName = (Schema.namedName v0)}+              hydraName = avroNameToHydraName qname+          in (Optionals.cases (getAvroHydraAdapter qname env1) (Eithers.bind (case (Schema.namedType v0) of+            Schema.NamedTypeEnum v1 ->+              let syms = Schema.enumSymbols v1+                  typ =+                          Core.TypeUnion (Lists.map (\s -> Core.FieldType {+                            Core.fieldTypeName = (Core.Name s),+                            Core.fieldTypeType = Core.TypeUnit}) syms)+              in (simpleAdapter env1 typ (\jv -> case jv of+                Model.ValueString v2 -> Right (Core.TermInject (Core.Injection {+                  Core.injectionTypeName = hydraName,+                  Core.injectionField = Core.Field {+                    Core.fieldName = (Core.Name v2),+                    Core.fieldTerm = Core.TermUnit}}))) (\t -> case t of+                Core.TermInject v2 ->+                  let fld = Core.injectionField v2+                      fn = Core.fieldName fld+                  in (Right (Model.ValueString (Core.unName fn)))))+            Schema.NamedTypeFixed _ -> simpleAdapter env1 (Core.TypeLiteral Core.LiteralTypeBinary) (\jv -> case jv of+              Model.ValueString v2 -> Right (Core.TermLiteral (Core.LiteralBinary (Literals.stringToBinary v2)))) (\t -> Eithers.map (\b -> Model.ValueString (Literals.binaryToString b)) (ExtractCore.binary (Graph.Graph {+              Graph.graphBoundTerms = Maps.empty,+              Graph.graphBoundTypes = Maps.empty,+              Graph.graphClassConstraints = Maps.empty,+              Graph.graphLambdaVariables = Sets.empty,+              Graph.graphMetadata = Maps.empty,+              Graph.graphPrimitives = Maps.empty,+              Graph.graphSchemaTypes = Maps.empty,+              Graph.graphTypeVariables = Sets.empty}) t))+            Schema.NamedTypeRecord v1 ->+              let avroFields = Schema.recordFields v1+              in (Eithers.bind (prepareFields cx env1 avroFields) (\prepResult ->+                let adaptersByFieldName = Pairs.first prepResult+                    env2 = Pairs.second prepResult+                in (Eithers.bind (findAvroPrimaryKeyField cx qname avroFields) (\pk ->+                  let encodePair =+                          \cx1 -> \entry ->+                            let k = Pairs.first entry+                                v = Pairs.second entry+                            in (Optionals.cases (Maps.lookup k adaptersByFieldName) (err cx1 (Strings.cat [+                              "unrecognized field for ",+                              (showQname qname),+                              ": ",+                              k])) (\fad -> Eithers.map (\v_ -> Core.Field {+                              Core.fieldName = (Core.Name k),+                              Core.fieldTerm = v_}) (Coders.coderEncode (Coders.adapterCoder (Pairs.second fad)) v)))+                      decodeField =+                              \cx1 -> \fld ->+                                let k = Core.unName (Core.fieldName fld)+                                    v = Core.fieldTerm fld+                                in (Optionals.cases (Maps.lookup k adaptersByFieldName) (err cx1 (Strings.cat [+                                  "unrecognized field for ",+                                  (showQname qname),+                                  ": ",+                                  k])) (\fad -> Eithers.map (\v_ -> (k, v_)) (Coders.coderDecode (Coders.adapterCoder (Pairs.second fad)) v)))+                      lossy =+                              Lists.foldl (\b -> \fad -> Logic.or b (Coders.adapterIsLossy (Pairs.second fad))) False (Maps.elems adaptersByFieldName)+                      hfields =+                              Lists.map (\fad -> Core.FieldType {+                                Core.fieldTypeName = (Core.Name (Schema.fieldName (Pairs.first fad))),+                                Core.fieldTypeType = (Coders.adapterTarget (Pairs.second fad))}) (Maps.elems adaptersByFieldName)+                      target = Core.TypeRecord hfields+                  in (Right (+                    Coders.Adapter {+                      Coders.adapterIsLossy = lossy,+                      Coders.adapterSource = schema,+                      Coders.adapterTarget = target,+                      Coders.adapterCoder = Coders.Coder {+                        Coders.coderEncode = (\jv -> case jv of+                          Model.ValueObject v2 -> Eithers.map (\fields -> Core.TermRecord (Core.Record {+                            Core.recordTypeName = hydraName,+                            Core.recordFields = fields})) (Eithers.mapList (\e -> encodePair cx e) v2)),+                        Coders.coderDecode = (\t -> case t of+                          Core.TermRecord v2 -> Eithers.map (\kvs -> Model.ValueObject kvs) (Eithers.mapList (\fld -> decodeField cx fld) (Core.recordFields v2)))}},+                    env2))))))) (\adEnv2 ->+            let ad = Pairs.first adEnv2+                env2 = Pairs.second adEnv2+                env3 = putAvroHydraAdapter qname ad env2+                env4 =+                        Environment.AvroEnvironment {+                          Environment.avroEnvironmentNamedAdapters = (Environment.avroEnvironmentNamedAdapters env3),+                          Environment.avroEnvironmentNamespace = lastNs,+                          Environment.avroEnvironmentElements = (Environment.avroEnvironmentElements env3)}+            in (Right (annotateAdapter ann ad, env4)))) (\_ad -> err cx (Strings.cat2 "Avro named type defined more than once: " (showQname qname))))+        Schema.SchemaPrimitive v0 -> case v0 of+          Schema.PrimitiveNull -> simpleAdapter env0 Core.TypeUnit (\jv -> case jv of+            Model.ValueString v2 -> Right (Core.TermLiteral (Core.LiteralString v2))) (\t -> Eithers.map (\s -> Model.ValueString s) (ExtractCore.string (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveBoolean -> simpleAdapter env0 (Core.TypeLiteral Core.LiteralTypeBoolean) (\jv -> case jv of+            Model.ValueBoolean v2 -> Right (Core.TermLiteral (Core.LiteralBoolean v2))) (\t -> Eithers.map (\b -> Model.ValueBoolean b) (ExtractCore.boolean (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveInt -> simpleAdapter env0 (Core.TypeLiteral (Core.LiteralTypeInteger Core.IntegerTypeInt32)) (\jv -> case jv of+            Model.ValueNumber v2 -> Right (Core.TermLiteral (Core.LiteralInteger (Core.IntegerValueInt32 (doubleToInt v2))))) (\t -> Eithers.map (\i -> Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint i))) (ExtractCore.int32 (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveLong -> simpleAdapter env0 (Core.TypeLiteral (Core.LiteralTypeInteger Core.IntegerTypeInt64)) (\jv -> case jv of+            Model.ValueNumber v2 -> Right (Core.TermLiteral (Core.LiteralInteger (Core.IntegerValueInt64 (doubleToLong v2))))) (\t -> Eithers.map (\i -> Model.ValueNumber (Literals.bigintToDecimal (Literals.int64ToBigint i))) (ExtractCore.int64 (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveFloat -> simpleAdapter env0 (Core.TypeLiteral (Core.LiteralTypeFloat Core.FloatTypeFloat32)) (\jv -> case jv of+            Model.ValueNumber v2 -> Right (Core.TermLiteral (Core.LiteralFloat (Core.FloatValueFloat32 (Literals.decimalToFloat32 v2))))) (\t -> Eithers.map (\f -> Model.ValueNumber (Literals.float32ToDecimal f)) (ExtractCore.float32 (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveDouble -> simpleAdapter env0 (Core.TypeLiteral (Core.LiteralTypeFloat Core.FloatTypeFloat64)) (\jv -> case jv of+            Model.ValueNumber v2 -> Right (Core.TermLiteral (Core.LiteralFloat (Core.FloatValueFloat64 (Literals.decimalToFloat64 v2))))) (\t -> Eithers.map (\d -> Model.ValueNumber (Literals.float64ToDecimal d)) (ExtractCore.float64 (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveBytes -> simpleAdapter env0 (Core.TypeLiteral Core.LiteralTypeBinary) (\jv -> case jv of+            Model.ValueString v2 -> Right (Core.TermLiteral (Core.LiteralBinary (Literals.stringToBinary v2)))) (\t -> Eithers.map (\b -> Model.ValueString (Literals.binaryToString b)) (ExtractCore.binary (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+          Schema.PrimitiveString -> simpleAdapter env0 (Core.TypeLiteral Core.LiteralTypeString) (\jv -> case jv of+            Model.ValueString v2 -> Right (Core.TermLiteral (Core.LiteralString v2))) (\t -> Eithers.map (\s -> Model.ValueString s) (ExtractCore.string (Graph.Graph {+            Graph.graphBoundTerms = Maps.empty,+            Graph.graphBoundTypes = Maps.empty,+            Graph.graphClassConstraints = Maps.empty,+            Graph.graphLambdaVariables = Sets.empty,+            Graph.graphMetadata = Maps.empty,+            Graph.graphPrimitives = Maps.empty,+            Graph.graphSchemaTypes = Maps.empty,+            Graph.graphTypeVariables = Sets.empty}) t))+        Schema.SchemaReference v0 ->+          let qname = parseAvroName (Environment.avroEnvironmentNamespace env0) v0+          in (Optionals.cases (getAvroHydraAdapter qname env0) (err cx (Strings.cat2 "Referenced Avro type has not been defined: " (showQname qname))) (\ad -> Right (ad, env0)))+        Schema.SchemaUnion v0 ->+          let schemas = Schema.unUnion v0+              isNull =+                      \s -> case s of+                        Schema.SchemaPrimitive v1 -> case v1 of+                          Schema.PrimitiveNull -> True+                          _ -> False+                        _ -> False+              hasNull = Logic.not (Lists.null (Lists.filter isNull schemas))+              nonNulls = Lists.filter (\s -> Logic.not (isNull s)) schemas+              forOptional =+                      \s -> Eithers.bind (avroHydraAdapter cx s env0) (\adEnv ->+                        let ad = Pairs.first adEnv+                            env1 = Pairs.second adEnv+                        in (Right (+                          Coders.Adapter {+                            Coders.adapterIsLossy = (Coders.adapterIsLossy ad),+                            Coders.adapterSource = schema,+                            Coders.adapterTarget = (Core.TypeOptional (Coders.adapterTarget ad)),+                            Coders.adapterCoder = Coders.Coder {+                              Coders.coderEncode = (\v -> case v of+                                Model.ValueNull -> Right (Core.TermOptional Nothing)+                                _ -> Eithers.map (\t -> Core.TermOptional (Just t)) (Coders.coderEncode (Coders.adapterCoder ad) v)),+                              Coders.coderDecode = (\t -> case t of+                                Core.TermOptional v1 -> Optionals.cases v1 (Right Model.ValueNull) (\term_ -> Coders.coderDecode (Coders.adapterCoder ad) term_))}},+                          env1)))+          in (Logic.ifElse (Equality.gt (Lists.length nonNulls) 1) (err cx "general-purpose unions are not yet supported") (Optionals.cases (Lists.maybeHead nonNulls) (err cx "cannot generate the empty type") (\nonNullHead -> Logic.ifElse hasNull (forOptional nonNullHead) (Eithers.bind (avroHydraAdapter cx nonNullHead env0) (\adEnv ->+            let ad = Pairs.first adEnv+                env1 = Pairs.second adEnv+            in (Right (+              Coders.Adapter {+                Coders.adapterIsLossy = (Coders.adapterIsLossy ad),+                Coders.adapterSource = schema,+                Coders.adapterTarget = (Coders.adapterTarget ad),+                Coders.adapterCoder = (Coders.adapterCoder ad)},+              env1)))))))+-- | Convert an Avro qualified name to a Hydra name+avroNameToHydraName :: Environment.AvroQualifiedName -> Core.Name+avroNameToHydraName qname =++      let mns = Environment.avroQualifiedNameNamespace qname+          local = Environment.avroQualifiedNameName qname+      in (Names.unqualifyName (Util.QualifiedName {+        Util.qualifiedNameModuleName = (Optionals.map (\s -> Packaging.ModuleName s) mns),+        Util.qualifiedNameLocal = local}))+avro_foreignKey :: String+avro_foreignKey = "@foreignKey"+avro_primaryKey :: String+avro_primaryKey = "@primaryKey"+-- | An empty Avro environment with no named adapters, no namespace, and no elements+emptyAvroEnvironment :: Environment.AvroEnvironment+emptyAvroEnvironment =+    Environment.AvroEnvironment {+      Environment.avroEnvironmentNamedAdapters = Maps.empty,+      Environment.avroEnvironmentNamespace = Nothing,+      Environment.avroEnvironmentElements = Maps.empty}+-- | Encode a JSON value as a Hydra term for annotation purposes+encodeAnnotationValue :: Model.Value -> Core.Term+encodeAnnotationValue v =+    case v of+      Model.ValueArray v0 -> Core.TermList (Lists.map encodeAnnotationValue v0)+      Model.ValueBoolean v0 -> Core.TermLiteral (Core.LiteralBoolean v0)+      Model.ValueNull -> Core.TermUnit+      Model.ValueNumber v0 -> Core.TermLiteral (Core.LiteralDecimal v0)+      Model.ValueObject v0 -> Core.TermMap (Maps.fromList (Lists.map (\entry ->+        let k = Pairs.first entry+            v_ = Pairs.second entry+        in (Core.TermLiteral (Core.LiteralString k), (encodeAnnotationValue v_))) v0))+      Model.ValueString v0 -> Core.TermLiteral (Core.LiteralString v0)+-- | Construct an error result with a message in context+err :: t0 -> String -> Either Errors.Error t1+err cx msg = Left (Errors.ErrorOther (Errors.OtherError msg))+-- | Extract a JSON array or return an error+expectArrayE :: t0 -> Model.Value -> Either t1 [Model.Value]+expectArrayE cx value =+    case value of+      Model.ValueArray v0 -> Right v0+-- | Extract a JSON object or return an error+expectObjectE :: t0 -> Model.Value -> Either t1 (M.Map String Model.Value)+expectObjectE cx value =+    case value of+      Model.ValueObject v0 -> Right (Maps.fromList v0)+-- | Extract a JSON string or return an error+expectStringE :: t0 -> Model.Value -> Either t1 String+expectStringE cx value =+    case value of+      Model.ValueString v0 -> Right v0+-- | Extract field annotations and convert them to core Name/Term pairs+fieldAnnotationsToCore :: Schema.Field -> M.Map Core.Name Core.Term+fieldAnnotationsToCore f =+    Maps.fromList (Lists.map (\entry ->+      let k = Pairs.first entry+          v = Pairs.second entry+      in (Core.Name k, (encodeAnnotationValue v))) (Maps.toList (Schema.fieldAnnotations f)))+-- | Find the primary key field among a list of Avro fields+findAvroPrimaryKeyField :: t0 -> Environment.AvroQualifiedName -> [Schema.Field] -> Either Errors.Error (Maybe Environment.AvroPrimaryKey)+findAvroPrimaryKeyField cx qname avroFields =++      let keys = Optionals.cat (Lists.map (\f -> primaryKeyE cx f) avroFields)+      in (Logic.ifElse (Lists.null keys) (Right Nothing) (Logic.ifElse (Equality.equal (Lists.length keys) 1) (Right (Lists.maybeHead keys)) (err cx (Strings.cat2 "multiple primary key fields for " (showQname qname)))))+-- | Extract a foreign key annotation from a field, if present+foreignKeyE :: t0 -> Schema.Field -> Either Errors.Error (Maybe Environment.AvroForeignKey)+foreignKeyE cx f =+    Optionals.cases (Maps.lookup avro_foreignKey (Schema.fieldAnnotations f)) (Right Nothing) (\v -> Eithers.bind (expectObjectE cx v) (\m -> Eithers.bind (Eithers.map (\s -> Core.Name s) (requireStringE cx "type" m)) (\tname -> Eithers.bind (optStringE cx "pattern" m) (\pattern_ ->+      let constr = Optionals.cases pattern_ (\s -> Core.Name s) (\pat -> patternToNameConstructor pat)+      in (Right (Just (Environment.AvroForeignKey {+        Environment.avroForeignKeyTypeName = tname,+        Environment.avroForeignKeyConstructor = constr})))))))+-- | Look up an adapter by qualified name in the environment+getAvroHydraAdapter :: Environment.AvroQualifiedName -> Environment.AvroEnvironment -> Maybe (Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error)+getAvroHydraAdapter qname env = Maps.lookup qname (Environment.avroEnvironmentNamedAdapters env)+-- | Convert a JSON value to a string, supporting booleans, strings, and numbers+jsonToStringE :: t0 -> Model.Value -> Either Errors.Error String+jsonToStringE cx v =+    case v of+      Model.ValueBoolean v0 -> Right (Logic.ifElse v0 "true" "false")+      Model.ValueString v0 -> Right v0+      Model.ValueNumber v0 -> Right (Literals.showDecimal v0)+      _ -> unexpectedE cx "string, number, or boolean" "other"+-- | Extract named type annotations and convert them to core Name/Term pairs+namedAnnotationsToCore :: Schema.Named -> M.Map Core.Name Core.Term+namedAnnotationsToCore n =+    Maps.fromList (Lists.map (\entry ->+      let k = Pairs.first entry+          v = Pairs.second entry+      in (Core.Name k, (encodeAnnotationValue v))) (Maps.toList (Schema.namedAnnotations n)))+-- | Look up an optional string attribute in a JSON object map+optStringE :: Ord t1 => (t0 -> t1 -> M.Map t1 Model.Value -> Either t2 (Maybe String))+optStringE cx fname m =+    Optionals.cases (Maps.lookup fname m) (Right Nothing) (\v -> Eithers.map (\s -> Optionals.pure s) (expectStringE cx v))+-- | Parse a dotted Avro name into a qualified name+parseAvroName :: Maybe String -> String -> Environment.AvroQualifiedName+parseAvroName mns name_ =++      let parts = Strings.splitOn "." name_+          local = Optionals.fromOptional name_ (Lists.maybeLast parts)+      in (Logic.ifElse (Equality.equal (Lists.length parts) 1) (Environment.AvroQualifiedName {+        Environment.avroQualifiedNameNamespace = mns,+        Environment.avroQualifiedNameName = local}) (Environment.AvroQualifiedName {+        Environment.avroQualifiedNameNamespace = (Optionals.map (\ps -> Strings.intercalate "." ps) (Lists.maybeInit parts)),+        Environment.avroQualifiedNameName = local}))+-- | Create a name constructor from a pattern string+patternToNameConstructor :: String -> String -> Core.Name+patternToNameConstructor pat s = Core.Name (Strings.intercalate s (Strings.splitOn "${}" pat))+-- | Prepare a single field, producing an adapter and updated environment+prepareField :: t0 -> Environment.AvroEnvironment -> Schema.Field -> Either Errors.Error ((String, (Schema.Field, (Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error))), Environment.AvroEnvironment)+prepareField cx env f =++      let manns = fieldAnnotationsToCore f+          ann = Logic.ifElse (Maps.null manns) Nothing (Just manns)+      in (Eithers.bind (foreignKeyE cx f) (\fk -> Eithers.bind (Optionals.cases fk (avroHydraAdapter cx (Schema.fieldType f) env) (\fkVal ->+        let fkName = Environment.avroForeignKeyTypeName fkVal+            fkConstr = Environment.avroForeignKeyConstructor fkVal+        in (Eithers.bind (avroHydraAdapter cx (Schema.fieldType f) env) (\adEnvPair ->+          let ad0 = Pairs.first adEnvPair+              env1 = Pairs.second adEnvPair+              elTyp = Core.TypeVariable fkName+              encodeValue =+                      \v -> Eithers.bind (Coders.coderEncode (Coders.adapterCoder ad0) v) (\encoded -> Eithers.bind (termToStringE cx encoded) (\s -> Right (Core.TermVariable (fkConstr s))))+              decodeTerm =+                      \t -> case t of+                        Core.TermVariable v0 -> Eithers.bind (stringToTermE cx (Coders.adapterTarget ad0) (Core.unName v0)) (\term_ -> Coders.coderDecode (Coders.adapterCoder ad0) term_)+                        _ -> err cx "expected variable"+              forTypeAndCoder =+                      \env2 -> \ad1 -> \typ -> \cdr -> Right (+                        Coders.Adapter {+                          Coders.adapterIsLossy = (Coders.adapterIsLossy ad1),+                          Coders.adapterSource = (Schema.fieldType f),+                          Coders.adapterTarget = typ,+                          Coders.adapterCoder = cdr},+                        env2)+          in case (Strip.deannotateType (Coders.adapterTarget ad0)) of+            Core.TypeOptional v0 -> case v0 of+              Core.TypeLiteral _ -> forTypeAndCoder env1 ad0 (Core.TypeOptional elTyp) (Coders.Coder {+                Coders.coderEncode = (\json -> Eithers.map (\v_ -> Core.TermOptional (Just v_)) (encodeValue json)),+                Coders.coderDecode = decodeTerm})+              _ -> err cx "expected literal type inside optional foreign key"+            Core.TypeList v0 -> case v0 of+              Core.TypeLiteral _ -> forTypeAndCoder env1 ad0 (Core.TypeList elTyp) (Coders.Coder {+                Coders.coderEncode = (\json -> case json of+                  Model.ValueArray v2 -> Eithers.map (\terms -> Core.TermList terms) (Eithers.mapList (\jv -> encodeValue jv) v2)+                  _ -> err cx "Expected JSON array"),+                Coders.coderDecode = decodeTerm})+              _ -> err cx "expected literal type inside list foreign key"+            Core.TypeLiteral _ -> forTypeAndCoder env1 ad0 elTyp (Coders.Coder {+              Coders.coderEncode = encodeValue,+              Coders.coderDecode = decodeTerm})+            _ -> err cx (Strings.cat2 "unsupported type annotated as foreign key: " "unknown"))))) (\adEnv ->+        let ad = Pairs.first adEnv+            env1 = Pairs.second adEnv+        in (Right ((Schema.fieldName f, (f, (annotateAdapter ann ad))), env1)))))+-- | Thread AvroEnvironment through preparing multiple fields+prepareFields :: t0 -> Environment.AvroEnvironment -> [Schema.Field] -> Either Errors.Error (M.Map String (Schema.Field, (Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error)), Environment.AvroEnvironment)+prepareFields cx env fields =+    Lists.foldl (\acc -> \f -> Eithers.bind acc (\accPair ->+      let m = Pairs.first accPair+          env1 = Pairs.second accPair+      in (Eithers.bind (prepareField cx env1 f) (\result ->+        let kv = Pairs.first result+            env2 = Pairs.second result+            k = Pairs.first kv+            v = Pairs.second kv+        in (Right (Maps.insert k v m, env2)))))) (Right (Maps.empty, env)) fields+-- | Extract a primary key annotation from a field, if present+primaryKeyE :: t0 -> Schema.Field -> Maybe Environment.AvroPrimaryKey+primaryKeyE cx f =+    Optionals.cases (Maps.lookup avro_primaryKey (Schema.fieldAnnotations f)) Nothing (\v -> Eithers.either (\_ -> Nothing) (\s -> Just (Environment.AvroPrimaryKey {+      Environment.avroPrimaryKeyFieldName = (Core.Name (Schema.fieldName f)),+      Environment.avroPrimaryKeyConstructor = (patternToNameConstructor s)})) (expectStringE cx v))+-- | Store an adapter in the environment by qualified name+putAvroHydraAdapter :: Environment.AvroQualifiedName -> Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error -> Environment.AvroEnvironment -> Environment.AvroEnvironment+putAvroHydraAdapter qname ad env =+    Environment.AvroEnvironment {+      Environment.avroEnvironmentNamedAdapters = (Maps.insert qname ad (Environment.avroEnvironmentNamedAdapters env)),+      Environment.avroEnvironmentNamespace = (Environment.avroEnvironmentNamespace env),+      Environment.avroEnvironmentElements = (Environment.avroEnvironmentElements env)}+-- | Look up a required string attribute in a JSON object map+requireStringE :: t0 -> String -> M.Map String Model.Value -> Either Errors.Error String+requireStringE cx fname m =+    Optionals.cases (Maps.lookup fname m) (err cx (Strings.cat [+      "required attribute ",+      (Literals.showString fname),+      " not found"])) (\v -> expectStringE cx v)+-- | Recursively rewrite an Avro schema using a monadic transformation function+rewriteAvroSchemaM :: ((Schema.Schema -> Either t0 Schema.Schema) -> Schema.Schema -> Either t0 Schema.Schema) -> Schema.Schema -> Either t0 Schema.Schema+rewriteAvroSchemaM f schema =++      let recurse = rewriteAvroSchemaM f+          fsub =+                  \s -> case s of+                    Schema.SchemaArray v0 -> Eithers.map (\els_ -> Schema.SchemaArray (Schema.Array {+                      Schema.arrayItems = els_})) (recurse (Schema.arrayItems v0))+                    Schema.SchemaMap v0 -> Eithers.map (\vs_ -> Schema.SchemaMap (Schema.Map {+                      Schema.mapValues = vs_})) (recurse (Schema.mapValues v0))+                    Schema.SchemaNamed v0 -> Eithers.map (\nt_ -> Schema.SchemaNamed (Schema.Named {+                      Schema.namedName = (Schema.namedName v0),+                      Schema.namedNamespace = (Schema.namedNamespace v0),+                      Schema.namedAliases = (Schema.namedAliases v0),+                      Schema.namedDoc = (Schema.namedDoc v0),+                      Schema.namedType = nt_,+                      Schema.namedAnnotations = (Schema.namedAnnotations v0)})) (case (Schema.namedType v0) of+                      Schema.NamedTypeRecord v1 -> Eithers.map (\fields_ -> Schema.NamedTypeRecord (Schema.Record {+                        Schema.recordFields = fields_})) (Eithers.mapList (\fld -> Eithers.map (\t_ -> Schema.Field {+                        Schema.fieldName = (Schema.fieldName fld),+                        Schema.fieldDoc = (Schema.fieldDoc fld),+                        Schema.fieldType = t_,+                        Schema.fieldDefault = (Schema.fieldDefault fld),+                        Schema.fieldOrder = (Schema.fieldOrder fld),+                        Schema.fieldAliases = (Schema.fieldAliases fld),+                        Schema.fieldAnnotations = (Schema.fieldAnnotations fld)}) (recurse (Schema.fieldType fld))) (Schema.recordFields v1))+                      _ -> Right (Schema.namedType v0))+                    Schema.SchemaUnion v0 -> Eithers.map (\schemas_ -> Schema.SchemaUnion (Schema.Union schemas_)) (Eithers.mapList (\us -> recurse us) (Schema.unUnion v0))+                    _ -> Right s+      in (f fsub schema)+-- | Convert an Avro qualified name to a display string+showQname :: Environment.AvroQualifiedName -> String+showQname qname =++      let mns = Environment.avroQualifiedNameNamespace qname+          local = Environment.avroQualifiedNameName qname+      in (Strings.cat2 (Optionals.cases mns "" (\ns -> Strings.cat2 ns ".")) local)+-- | Parse a string into a term of the expected type+stringToTermE :: t0 -> Core.Type -> String -> Either Errors.Error Core.Term+stringToTermE cx typ s =++      let readErr = err cx "failed to read value"+          readAndWrap = \reader -> \wrapper -> Optionals.cases (reader s) readErr (\v -> Right (Core.TermLiteral (wrapper v)))+      in case (Strip.deannotateType typ) of+        Core.TypeLiteral v0 -> case v0 of+          Core.LiteralTypeBoolean -> readAndWrap (\x -> Literals.readBoolean x) (\b -> Core.LiteralBoolean b)+          Core.LiteralTypeInteger v1 -> case v1 of+            Core.IntegerTypeBigint -> readAndWrap (\x -> Literals.readBigint x) (\i -> Core.LiteralInteger (Core.IntegerValueBigint i))+            Core.IntegerTypeInt8 -> readAndWrap (\x -> Literals.readInt8 x) (\i -> Core.LiteralInteger (Core.IntegerValueInt8 i))+            Core.IntegerTypeInt16 -> readAndWrap (\x -> Literals.readInt16 x) (\i -> Core.LiteralInteger (Core.IntegerValueInt16 i))+            Core.IntegerTypeInt32 -> readAndWrap (\x -> Literals.readInt32 x) (\i -> Core.LiteralInteger (Core.IntegerValueInt32 i))+            Core.IntegerTypeInt64 -> readAndWrap (\x -> Literals.readInt64 x) (\i -> Core.LiteralInteger (Core.IntegerValueInt64 i))+            Core.IntegerTypeUint8 -> readAndWrap (\x -> Literals.readUint8 x) (\i -> Core.LiteralInteger (Core.IntegerValueUint8 i))+            Core.IntegerTypeUint16 -> readAndWrap (\x -> Literals.readUint16 x) (\i -> Core.LiteralInteger (Core.IntegerValueUint16 i))+            Core.IntegerTypeUint32 -> readAndWrap (\x -> Literals.readUint32 x) (\i -> Core.LiteralInteger (Core.IntegerValueUint32 i))+            Core.IntegerTypeUint64 -> readAndWrap (\x -> Literals.readUint64 x) (\i -> Core.LiteralInteger (Core.IntegerValueUint64 i))+          Core.LiteralTypeString -> Right (Core.TermLiteral (Core.LiteralString s))+          _ -> unexpectedE cx "literal type" "other literal type"+        _ -> unexpectedE cx "literal type" "other"+-- | Convert a literal term to its string representation+termToStringE :: t0 -> Core.Term -> Either Errors.Error String+termToStringE cx term =+    case (Strip.deannotateTerm term) of+      Core.TermLiteral v0 -> case v0 of+        Core.LiteralBoolean v1 -> Right (Literals.showBoolean v1)+        Core.LiteralInteger v1 -> Right (case v1 of+          Core.IntegerValueBigint v2 -> Literals.showBigint v2+          Core.IntegerValueInt8 v2 -> Literals.showInt8 v2+          Core.IntegerValueInt16 v2 -> Literals.showInt16 v2+          Core.IntegerValueInt32 v2 -> Literals.showInt32 v2+          Core.IntegerValueInt64 v2 -> Literals.showInt64 v2+          Core.IntegerValueUint8 v2 -> Literals.showUint8 v2+          Core.IntegerValueUint16 v2 -> Literals.showUint16 v2+          Core.IntegerValueUint32 v2 -> Literals.showUint32 v2+          Core.IntegerValueUint64 v2 -> Literals.showUint64 v2)+        Core.LiteralString v1 -> Right v1+        _ -> unexpectedE cx "boolean, integer, or string" "other literal"+      Core.TermOptional v0 -> Optionals.cases v0 (unexpectedE cx "literal value" "Nothing") (\term_ -> termToStringE cx term_)+      _ -> unexpectedE cx "literal value" "other"+-- | Construct an error for unexpected values+unexpectedE :: t0 -> String -> String -> Either Errors.Error t1+unexpectedE cx expected found =+    err cx (Strings.cat [+      "Expected ",+      expected,+      ", found: ",+      found])
+ src/main/haskell/Hydra/Avro/Encoder.hs view
@@ -0,0 +1,570 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Hydra-to-Avro encoder: converts Hydra types and terms to Avro schemas and JSON values++module Hydra.Avro.Encoder where+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Avro.Environment as Environment+import qualified Hydra.Avro.Schema as Schema+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Extract.Core as ExtractCore+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Build an Avro field from a name-adapter pair+buildAvroField :: (Core.Name, (Coders.Adapter t0 Schema.Schema t1 t2 t3)) -> Schema.Field+buildAvroField nameAd =++      let name_ = Pairs.first nameAd+          ad = Pairs.second nameAd+      in Schema.Field {+        Schema.fieldName = (localName name_),+        Schema.fieldDoc = Nothing,+        Schema.fieldType = (Coders.adapterTarget ad),+        Schema.fieldDefault = Nothing,+        Schema.fieldOrder = Nothing,+        Schema.fieldAliases = Nothing,+        Schema.fieldAnnotations = Maps.empty}+-- | Create an empty encode environment with the given type map+emptyEncodeEnvironment :: M.Map Core.Name Core.Type -> Environment.EncodeEnvironment+emptyEncodeEnvironment typeMap =+    Environment.EncodeEnvironment {+      Environment.encodeEnvironmentTypeMap = typeMap,+      Environment.encodeEnvironmentEmitted = Maps.empty}+-- | Encode a Hydra type to an Avro schema adapter, given the type map and a root name+encodeType :: t0 -> M.Map Core.Name Core.Type -> Core.Name -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error)+encodeType cx typeMap name_ =+    Eithers.map (\adEnv -> Pairs.first adEnv) (encodeTypeWithEnv cx name_ (emptyEncodeEnvironment typeMap))+-- | Core encoding logic: recursively encode a Hydra type to an Avro schema+encodeTypeInner :: t0 -> Maybe Core.Name -> Core.Type -> Environment.EncodeEnvironment -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error, Environment.EncodeEnvironment)+encodeTypeInner cx mName typ env =++      let annResult = extractAnnotations typ+          annotations = Pairs.first annResult+          bareType = Pairs.second annResult+          simpleAdapter =+                  \target -> \lossy -> \encode -> \decode -> Right (+                    Coders.Adapter {+                      Coders.adapterIsLossy = lossy,+                      Coders.adapterSource = typ,+                      Coders.adapterTarget = target,+                      Coders.adapterCoder = Coders.Coder {+                        Coders.coderEncode = encode,+                        Coders.coderDecode = decode}},+                    env)+      in case bareType of+        Core.TypeUnit -> simpleAdapter (Schema.SchemaPrimitive Schema.PrimitiveNull) False (\_t -> Right Model.ValueNull) (\_j -> Right Core.TermUnit)+        Core.TypeLiteral v0 -> Eithers.map (\ad -> (ad, env)) (literalAdapter cx typ v0)+        Core.TypeList v0 -> Eithers.bind (encodeTypeInner cx Nothing v0 env) (\adEnv ->+          let innerAd = Pairs.first adEnv+              env1 = Pairs.second adEnv+          in (Right (+            Coders.Adapter {+              Coders.adapterIsLossy = (Coders.adapterIsLossy innerAd),+              Coders.adapterSource = typ,+              Coders.adapterTarget = (Schema.SchemaArray (Schema.Array {+                Schema.arrayItems = (Coders.adapterTarget innerAd)})),+              Coders.adapterCoder = Coders.Coder {+                Coders.coderEncode = (\t -> case t of+                  Core.TermList v1 -> Eithers.map (\jvs -> Model.ValueArray jvs) (Eithers.mapList (\el -> Coders.coderEncode (Coders.adapterCoder innerAd) el) v1)),+                Coders.coderDecode = (\j -> case j of+                  Model.ValueArray v1 -> Eithers.map (\ts -> Core.TermList ts) (Eithers.mapList (\el -> Coders.coderDecode (Coders.adapterCoder innerAd) el) v1))}},+            env1)))+        Core.TypeMap v0 ->+          let keyType = Core.mapTypeKeys v0+              valType = Core.mapTypeValues v0+          in case (Strip.deannotateType keyType) of+            Core.TypeLiteral v1 -> case v1 of+              Core.LiteralTypeString -> Eithers.bind (encodeTypeInner cx Nothing valType env) (\adEnv ->+                let valAd = Pairs.first adEnv+                    env1 = Pairs.second adEnv+                in (Right (+                  Coders.Adapter {+                    Coders.adapterIsLossy = (Coders.adapterIsLossy valAd),+                    Coders.adapterSource = typ,+                    Coders.adapterTarget = (Schema.SchemaMap (Schema.Map {+                      Schema.mapValues = (Coders.adapterTarget valAd)})),+                    Coders.adapterCoder = Coders.Coder {+                      Coders.coderEncode = (\t -> case t of+                        Core.TermMap v3 ->+                          let encodeEntry =+                                  \entry ->+                                    let k = Pairs.first entry+                                        v = Pairs.second entry+                                    in (Eithers.bind (ExtractCore.string (Graph.Graph {+                                      Graph.graphBoundTerms = Maps.empty,+                                      Graph.graphBoundTypes = Maps.empty,+                                      Graph.graphClassConstraints = Maps.empty,+                                      Graph.graphLambdaVariables = Sets.empty,+                                      Graph.graphMetadata = Maps.empty,+                                      Graph.graphPrimitives = Maps.empty,+                                      Graph.graphSchemaTypes = Maps.empty,+                                      Graph.graphTypeVariables = Sets.empty}) k) (\kStr -> Eithers.map (\vJson -> (kStr, vJson)) (Coders.coderEncode (Coders.adapterCoder valAd) v)))+                          in (Eithers.map (\pairs -> Model.ValueObject (pairs)) (Eithers.mapList encodeEntry (Maps.toList v3)))),+                      Coders.coderDecode = (\j -> case j of+                        Model.ValueObject v3 ->+                          let decodeEntry =+                                  \entry ->+                                    let k = Pairs.first entry+                                        v = Pairs.second entry+                                    in (Eithers.map (\vTerm -> (Core.TermLiteral (Core.LiteralString k), vTerm)) (Coders.coderDecode (Coders.adapterCoder valAd) v))+                          in (Eithers.map (\pairs -> Core.TermMap (Maps.fromList pairs)) (Eithers.mapList decodeEntry v3)))}},+                  env1)))+              _ -> err cx "Avro maps require string keys"+            _ -> err cx "Avro maps require string keys"+        Core.TypeRecord v0 -> namedTypeAdapter cx typ mName annotations v0 env (\avroFields -> Schema.NamedTypeRecord (Schema.Record {+          Schema.recordFields = avroFields})) recordTermCoder+        Core.TypeUnion v0 ->+          let allUnit =+                  Lists.foldl (\b -> \ft -> Logic.and b (case (Core.fieldTypeType ft) of+                    Core.TypeUnit -> True+                    _ -> False)) True v0+          in (Logic.ifElse allUnit (enumAdapter cx typ mName annotations v0 env) (unionAsRecordAdapter cx typ mName annotations v0 env))+        Core.TypeOptional v0 -> Eithers.bind (encodeTypeInner cx Nothing v0 env) (\adEnv ->+          let innerAd = Pairs.first adEnv+              env1 = Pairs.second adEnv+          in (Right (+            Coders.Adapter {+              Coders.adapterIsLossy = (Coders.adapterIsLossy innerAd),+              Coders.adapterSource = typ,+              Coders.adapterTarget = (Schema.SchemaUnion (Schema.Union [+                Schema.SchemaPrimitive Schema.PrimitiveNull,+                (Coders.adapterTarget innerAd)])),+              Coders.adapterCoder = Coders.Coder {+                Coders.coderEncode = (\t -> case t of+                  Core.TermOptional v1 -> Optionals.cases v1 (Right Model.ValueNull) (\inner -> Coders.coderEncode (Coders.adapterCoder innerAd) inner)),+                Coders.coderDecode = (\j -> case j of+                  Model.ValueNull -> Right (Core.TermOptional Nothing)+                  _ -> Eithers.map (\t -> Core.TermOptional (Just t)) (Coders.coderDecode (Coders.adapterCoder innerAd) j))}},+            env1)))+        Core.TypeWrap v0 -> encodeTypeInner cx mName v0 env+        Core.TypeVariable v0 -> Optionals.cases (Maps.lookup v0 (Environment.encodeEnvironmentEmitted env)) (Optionals.cases (Maps.lookup v0 (Environment.encodeEnvironmentTypeMap env)) (err cx (Strings.cat2 "referenced type not found: " (Core.unName v0))) (\refType -> encodeTypeInner cx (Just v0) refType env)) (\existingAd -> Right (+          Coders.Adapter {+            Coders.adapterIsLossy = (Coders.adapterIsLossy existingAd),+            Coders.adapterSource = (Coders.adapterSource existingAd),+            Coders.adapterTarget = (Schema.SchemaReference (localName v0)),+            Coders.adapterCoder = (Coders.adapterCoder existingAd)},+          env))+        _ -> err cx "unsupported Hydra type for Avro encoding"+-- | Encode with full environment threading. Returns the adapter and updated environment+encodeTypeWithEnv :: t0 -> Core.Name -> Environment.EncodeEnvironment -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error, Environment.EncodeEnvironment)+encodeTypeWithEnv cx name_ env =+    Optionals.cases (Maps.lookup name_ (Environment.encodeEnvironmentTypeMap env)) (err cx (Strings.cat2 "type not found in type map: " (Literals.showString (Core.unName name_)))) (\typ -> encodeTypeInner cx (Just name_) typ env)+-- | Adapter for all-unit union types (enums)+enumAdapter :: t0 -> Core.Type -> Maybe Core.Name -> M.Map Core.Name Core.Term -> [Core.FieldType] -> Environment.EncodeEnvironment -> Either t1 (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error, Environment.EncodeEnvironment)+enumAdapter cx typ mName annotations fieldTypes env0 =++      let symbols = Lists.map (\ft -> localName (Core.fieldTypeName ft)) fieldTypes+          typeName = Optionals.fromOptional (typeToName typ) mName+          avroAnnotations = hydraAnnotationsToAvro annotations+          avroSchema =+                  Schema.SchemaNamed (Schema.Named {+                    Schema.namedName = (localName typeName),+                    Schema.namedNamespace = (nameNamespace typeName),+                    Schema.namedAliases = Nothing,+                    Schema.namedDoc = Nothing,+                    Schema.namedType = (Schema.NamedTypeEnum (Schema.Enum {+                      Schema.enumSymbols = symbols,+                      Schema.enumDefault = Nothing})),+                    Schema.namedAnnotations = avroAnnotations})+          adapter_ =+                  Coders.Adapter {+                    Coders.adapterIsLossy = False,+                    Coders.adapterSource = typ,+                    Coders.adapterTarget = avroSchema,+                    Coders.adapterCoder = Coders.Coder {+                      Coders.coderEncode = (\t -> case t of+                        Core.TermInject v0 ->+                          let fname = Core.injectionField v0+                          in (Right (Model.ValueString (localName (Core.fieldName fname))))+                        _ -> err cx "expected union term for enum"),+                      Coders.coderDecode = (\j -> case j of+                        Model.ValueString v0 -> Right (Core.TermInject (Core.Injection {+                          Core.injectionTypeName = typeName,+                          Core.injectionField = Core.Field {+                            Core.fieldName = (Core.Name v0),+                            Core.fieldTerm = Core.TermUnit}})))}}+          env1 =+                  Environment.EncodeEnvironment {+                    Environment.encodeEnvironmentTypeMap = (Environment.encodeEnvironmentTypeMap env0),+                    Environment.encodeEnvironmentEmitted = (Maps.insert typeName adapter_ (Environment.encodeEnvironmentEmitted env0))}+      in (Right (adapter_, env1))+-- | Construct an error result with a message in context+err :: t0 -> String -> Either Errors.Error t1+err cx msg = Left (Errors.ErrorOther (Errors.OtherError msg))+-- | Extract annotations from a potentially annotated type+extractAnnotations :: Core.Type -> (M.Map Core.Name Core.Term, Core.Type)+extractAnnotations typ =+    case typ of+      Core.TypeAnnotated v0 ->+        let inner = Core.annotatedTypeBody v0+            anns = Annotations.getAnnotationMap (Core.annotatedTypeAnnotation v0)+            innerResult = extractAnnotations inner+            innerAnns = Pairs.first innerResult+            bareType = Pairs.second innerResult+        in (Maps.union anns innerAnns, bareType)+      _ -> (Maps.empty, typ)+-- | Create an adapter for float types+floatAdapter :: t0 -> t1 -> Core.FloatType -> Either t2 (Coders.Adapter t1 Schema.Schema Core.Term Model.Value Errors.Error)+floatAdapter cx typ ft =++      let simple =+              \target -> \lossy -> \encode -> \decode -> Right (Coders.Adapter {+                Coders.adapterIsLossy = lossy,+                Coders.adapterSource = typ,+                Coders.adapterTarget = target,+                Coders.adapterCoder = Coders.Coder {+                  Coders.coderEncode = encode,+                  Coders.coderDecode = decode}})+      in case ft of+        Core.FloatTypeFloat32 -> simple (Schema.SchemaPrimitive Schema.PrimitiveFloat) False (\t -> Eithers.map (\f -> Model.ValueNumber (Literals.float32ToDecimal f)) (ExtractCore.float32 (Graph.Graph {+          Graph.graphBoundTerms = Maps.empty,+          Graph.graphBoundTypes = Maps.empty,+          Graph.graphClassConstraints = Maps.empty,+          Graph.graphLambdaVariables = Sets.empty,+          Graph.graphMetadata = Maps.empty,+          Graph.graphPrimitives = Maps.empty,+          Graph.graphSchemaTypes = Maps.empty,+          Graph.graphTypeVariables = Sets.empty}) t)) (\j -> case j of+          Model.ValueNumber v1 -> Right (Core.TermLiteral (Core.LiteralFloat (Core.FloatValueFloat32 (Literals.decimalToFloat32 v1)))))+        Core.FloatTypeFloat64 -> simple (Schema.SchemaPrimitive Schema.PrimitiveDouble) False (\t -> Eithers.map (\d -> Model.ValueNumber (Literals.float64ToDecimal d)) (ExtractCore.float64 (Graph.Graph {+          Graph.graphBoundTerms = Maps.empty,+          Graph.graphBoundTypes = Maps.empty,+          Graph.graphClassConstraints = Maps.empty,+          Graph.graphLambdaVariables = Sets.empty,+          Graph.graphMetadata = Maps.empty,+          Graph.graphPrimitives = Maps.empty,+          Graph.graphSchemaTypes = Maps.empty,+          Graph.graphTypeVariables = Sets.empty}) t)) (\j -> case j of+          Model.ValueNumber v1 -> Right (Core.TermLiteral (Core.LiteralFloat (Core.FloatValueFloat64 (Literals.decimalToFloat64 v1)))))+        _ -> simple (Schema.SchemaPrimitive Schema.PrimitiveDouble) True (\t -> case t of+          Core.TermLiteral v0 -> case v0 of+            Core.LiteralFloat v1 -> Right (Model.ValueNumber (floatValueToDouble v1))) (\j -> case j of+          Model.ValueNumber v0 -> Right (Core.TermLiteral (Core.LiteralFloat (Core.FloatValueFloat64 (Literals.decimalToFloat64 v0)))))+-- | Convert any float value to a JSON decimal number+floatValueToDouble :: Core.FloatValue -> Sci.Scientific+floatValueToDouble fv =+    case fv of+      Core.FloatValueFloat32 v0 -> Literals.float32ToDecimal v0+      Core.FloatValueFloat64 v0 -> Literals.float64ToDecimal v0+-- | Fold over field types, building adapters and threading the environment+foldFieldAdapters :: t0 -> [Core.FieldType] -> Environment.EncodeEnvironment -> Either Errors.Error ([(Core.Name, (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error))], Environment.EncodeEnvironment)+foldFieldAdapters cx fieldTypes env0 =+    Lists.foldl (\acc -> \ft -> Eithers.bind acc (\accPair ->+      let soFar = Pairs.first accPair+          env1 = Pairs.second accPair+          fname = Core.fieldTypeName ft+          ftype = Core.fieldTypeType ft+      in (Eithers.bind (encodeTypeInner cx Nothing ftype env1) (\adEnv ->+        let ad = Pairs.first adEnv+            env2 = Pairs.second adEnv+        in (Right (Lists.concat2 soFar [+          (fname, ad)], env2)))))) (Right ([], env0)) fieldTypes+-- | Convert Hydra annotations to Avro annotation map+hydraAnnotationsToAvro :: M.Map Core.Name Core.Term -> M.Map String Model.Value+hydraAnnotationsToAvro anns =+    Maps.fromList (Lists.map (\entry ->+      let k = Pairs.first entry+          v = Pairs.second entry+      in (Core.unName k, (termToJsonValue v))) (Maps.toList anns))+-- | Encode a single type without a type map (for simple/anonymous types)+hydraAvroAdapter :: t0 -> M.Map Core.Name Core.Type -> Core.Type -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error)+hydraAvroAdapter cx typeMap typ =+    Eithers.map (\adEnv -> Pairs.first adEnv) (encodeTypeInner cx Nothing typ (emptyEncodeEnvironment typeMap))+-- | Convert a Hydra Name to an Avro qualified name (local name, optional namespace)+hydraNameToAvroName :: Core.Name -> (String, (Maybe String))+hydraNameToAvroName name_ = (localName name_, (nameNamespace name_))+-- | Create an adapter for integer types+integerAdapter :: t0 -> t1 -> Core.IntegerType -> Either t2 (Coders.Adapter t1 Schema.Schema Core.Term Model.Value Errors.Error)+integerAdapter cx typ it =++      let simple =+              \target -> \lossy -> \encode -> \decode -> Right (Coders.Adapter {+                Coders.adapterIsLossy = lossy,+                Coders.adapterSource = typ,+                Coders.adapterTarget = target,+                Coders.adapterCoder = Coders.Coder {+                  Coders.coderEncode = encode,+                  Coders.coderDecode = decode}})+      in case it of+        Core.IntegerTypeInt32 -> simple (Schema.SchemaPrimitive Schema.PrimitiveInt) False (\t -> Eithers.map (\i -> Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint i))) (ExtractCore.int32 (Graph.Graph {+          Graph.graphBoundTerms = Maps.empty,+          Graph.graphBoundTypes = Maps.empty,+          Graph.graphClassConstraints = Maps.empty,+          Graph.graphLambdaVariables = Sets.empty,+          Graph.graphMetadata = Maps.empty,+          Graph.graphPrimitives = Maps.empty,+          Graph.graphSchemaTypes = Maps.empty,+          Graph.graphTypeVariables = Sets.empty}) t)) (\j -> case j of+          Model.ValueNumber v1 -> Right (Core.TermLiteral (Core.LiteralInteger (Core.IntegerValueInt32 (Literals.bigintToInt32 (Literals.decimalToBigint v1))))))+        Core.IntegerTypeInt64 -> simple (Schema.SchemaPrimitive Schema.PrimitiveLong) False (\t -> Eithers.map (\i -> Model.ValueNumber (Literals.bigintToDecimal (Literals.int64ToBigint i))) (ExtractCore.int64 (Graph.Graph {+          Graph.graphBoundTerms = Maps.empty,+          Graph.graphBoundTypes = Maps.empty,+          Graph.graphClassConstraints = Maps.empty,+          Graph.graphLambdaVariables = Sets.empty,+          Graph.graphMetadata = Maps.empty,+          Graph.graphPrimitives = Maps.empty,+          Graph.graphSchemaTypes = Maps.empty,+          Graph.graphTypeVariables = Sets.empty}) t)) (\j -> case j of+          Model.ValueNumber v1 -> Right (Core.TermLiteral (Core.LiteralInteger (Core.IntegerValueInt64 (Literals.bigintToInt64 (Literals.decimalToBigint v1))))))+        _ -> simple (Schema.SchemaPrimitive Schema.PrimitiveLong) True (\t -> case t of+          Core.TermLiteral v0 -> case v0 of+            Core.LiteralInteger v1 -> Right (Model.ValueNumber (integerValueToDouble v1))) (\j -> case j of+          Model.ValueNumber v0 -> Right (Core.TermLiteral (Core.LiteralInteger (Core.IntegerValueInt64 (Literals.bigintToInt64 (Literals.decimalToBigint v0))))))+-- | Convert any integer value to a JSON decimal number+integerValueToDouble :: Core.IntegerValue -> Sci.Scientific+integerValueToDouble iv =+    case iv of+      Core.IntegerValueBigint v0 -> Literals.bigintToDecimal v0+      Core.IntegerValueInt8 v0 -> Literals.bigintToDecimal (Literals.int8ToBigint v0)+      Core.IntegerValueInt16 v0 -> Literals.bigintToDecimal (Literals.int16ToBigint v0)+      Core.IntegerValueInt32 v0 -> Literals.bigintToDecimal (Literals.int32ToBigint v0)+      Core.IntegerValueInt64 v0 -> Literals.bigintToDecimal (Literals.int64ToBigint v0)+      Core.IntegerValueUint8 v0 -> Literals.bigintToDecimal (Literals.uint8ToBigint v0)+      Core.IntegerValueUint16 v0 -> Literals.bigintToDecimal (Literals.uint16ToBigint v0)+      Core.IntegerValueUint32 v0 -> Literals.bigintToDecimal (Literals.uint32ToBigint v0)+      Core.IntegerValueUint64 v0 -> Literals.bigintToDecimal (Literals.uint64ToBigint v0)+-- | Create an adapter for literal types+literalAdapter :: t0 -> t1 -> Core.LiteralType -> Either t2 (Coders.Adapter t1 Schema.Schema Core.Term Model.Value Errors.Error)+literalAdapter cx typ lt =++      let simple =+              \target -> \lossy -> \encode -> \decode -> Right (Coders.Adapter {+                Coders.adapterIsLossy = lossy,+                Coders.adapterSource = typ,+                Coders.adapterTarget = target,+                Coders.adapterCoder = Coders.Coder {+                  Coders.coderEncode = encode,+                  Coders.coderDecode = decode}})+      in case lt of+        Core.LiteralTypeBoolean -> simple (Schema.SchemaPrimitive Schema.PrimitiveBoolean) False (\t -> case t of+          Core.TermLiteral v1 -> case v1 of+            Core.LiteralBoolean v2 -> Right (Model.ValueBoolean v2)) (\j -> case j of+          Model.ValueBoolean v1 -> Right (Core.TermLiteral (Core.LiteralBoolean v1)))+        Core.LiteralTypeString -> simple (Schema.SchemaPrimitive Schema.PrimitiveString) False (\t -> case t of+          Core.TermLiteral v1 -> case v1 of+            Core.LiteralString v2 -> Right (Model.ValueString v2)) (\j -> case j of+          Model.ValueString v1 -> Right (Core.TermLiteral (Core.LiteralString v1)))+        Core.LiteralTypeBinary -> simple (Schema.SchemaPrimitive Schema.PrimitiveBytes) False (\t -> case t of+          Core.TermLiteral v1 -> case v1 of+            Core.LiteralBinary v2 -> Right (Model.ValueString (Literals.binaryToString v2))) (\j -> case j of+          Model.ValueString v1 -> Right (Core.TermLiteral (Core.LiteralBinary (Literals.stringToBinary v1))))+        Core.LiteralTypeInteger v0 -> integerAdapter cx typ v0+        Core.LiteralTypeFloat v0 -> floatAdapter cx typ v0+-- | Extract the local part of a qualified name+localName :: Core.Name -> String+localName name_ =++      let s = Core.unName name_+          parts = Strings.splitOn "." s+      in (Optionals.fromOptional s (Lists.maybeLast parts))+-- | Extract the namespace from a qualified name, if any+nameNamespace :: Core.Name -> Maybe String+nameNamespace name_ =++      let s = Core.unName name_+          parts = Strings.splitOn "." s+      in (Logic.ifElse (Equality.equal (Lists.length parts) 1) Nothing (Optionals.map (\ps -> Strings.intercalate "." ps) (Lists.maybeInit parts)))+-- | Build a named type adapter (shared between record and union-as-record)+namedTypeAdapter :: t0 -> Core.Type -> Maybe Core.Name -> M.Map Core.Name Core.Term -> [Core.FieldType] -> Environment.EncodeEnvironment -> ([Schema.Field] -> Schema.NamedType) -> (t0 -> Core.Name -> [(Core.Name, (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error))] -> (+  (Core.Term -> Either Errors.Error Model.Value),+  (Model.Value -> Either Errors.Error Core.Term))) -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error, Environment.EncodeEnvironment)+namedTypeAdapter cx typ mName annotations fieldTypes env0 mkNamedType mkCoder =++      let typeName = Optionals.fromOptional (typeToName typ) mName+      in (Optionals.cases (Maps.lookup typeName (Environment.encodeEnvironmentEmitted env0)) (Eithers.bind (foldFieldAdapters cx fieldTypes env0) (\faResult ->+        let fieldAdapters = Pairs.first faResult+            env1 = Pairs.second faResult+            avroFields = Lists.map buildAvroField fieldAdapters+            avroAnnotations = hydraAnnotationsToAvro annotations+            avroSchema =+                    Schema.SchemaNamed (Schema.Named {+                      Schema.namedName = (localName typeName),+                      Schema.namedNamespace = (nameNamespace typeName),+                      Schema.namedAliases = Nothing,+                      Schema.namedDoc = Nothing,+                      Schema.namedType = (mkNamedType avroFields),+                      Schema.namedAnnotations = avroAnnotations})+            lossy = Lists.foldl (\b -> \fa -> Logic.or b (Coders.adapterIsLossy (Pairs.second fa))) False fieldAdapters+            coderPair = mkCoder cx typeName fieldAdapters+            encodeFn = Pairs.first coderPair+            decodeFn = Pairs.second coderPair+            adapter_ =+                    Coders.Adapter {+                      Coders.adapterIsLossy = lossy,+                      Coders.adapterSource = typ,+                      Coders.adapterTarget = avroSchema,+                      Coders.adapterCoder = Coders.Coder {+                        Coders.coderEncode = encodeFn,+                        Coders.coderDecode = decodeFn}}+            env2 =+                    Environment.EncodeEnvironment {+                      Environment.encodeEnvironmentTypeMap = (Environment.encodeEnvironmentTypeMap env1),+                      Environment.encodeEnvironmentEmitted = (Maps.insert typeName adapter_ (Environment.encodeEnvironmentEmitted env1))}+        in (Right (adapter_, env2)))) (\existingAd -> Right (existingAd, env0)))+-- | Build a record term coder from field adapters+recordTermCoder :: t0 -> Core.Name -> [(Core.Name, (Coders.Adapter t1 t2 Core.Term Model.Value Errors.Error))] -> (+  (Core.Term -> Either Errors.Error Model.Value),+  (Model.Value -> Either Errors.Error Core.Term))+recordTermCoder cx typeName fieldAdapters =++      let encode =+              \term -> case term of+                Core.TermRecord v0 ->+                  let fields = Core.recordFields v0+                      fieldMap = Maps.fromList (Lists.map (\f -> (Core.fieldName f, (Core.fieldTerm f))) fields)+                      encodeField =+                              \nameAd ->+                                let fname = Pairs.first nameAd+                                    ad = Pairs.second nameAd+                                    fTerm = Optionals.fromOptional Core.TermUnit (Maps.lookup fname fieldMap)+                                in (Eithers.map (\jv -> (localName fname, jv)) (Coders.coderEncode (Coders.adapterCoder ad) fTerm))+                  in (Eithers.map (\pairs -> Model.ValueObject (pairs)) (Eithers.mapList encodeField fieldAdapters))+                _ -> err cx "expected record term"+          decode =+                  \json -> case json of+                    Model.ValueObject v0 ->+                      let decodeField =+                              \nameAd ->+                                let fname = Pairs.first nameAd+                                    ad = Pairs.second nameAd+                                    jv = Optionals.fromOptional Model.ValueNull (Maps.lookup (localName fname) (Maps.fromList v0))+                                in (Eithers.map (\t -> Core.Field {+                                  Core.fieldName = fname,+                                  Core.fieldTerm = t}) (Coders.coderDecode (Coders.adapterCoder ad) jv))+                      in (Eithers.map (\fields -> Core.TermRecord (Core.Record {+                        Core.recordTypeName = typeName,+                        Core.recordFields = fields})) (Eithers.mapList decodeField fieldAdapters))+                    _ -> err cx "expected JSON object"+      in (encode, decode)+-- | Convert a Hydra term to a JSON value (for annotation values)+termToJsonValue :: Core.Term -> Model.Value+termToJsonValue term =+    case term of+      Core.TermLiteral v0 -> case v0 of+        Core.LiteralString v1 -> Model.ValueString v1+        Core.LiteralBoolean v1 -> Model.ValueBoolean v1+        Core.LiteralInteger v1 -> Model.ValueNumber (integerValueToDouble v1)+        Core.LiteralFloat v1 -> Model.ValueNumber (floatValueToDouble v1)+        Core.LiteralBinary v1 -> Model.ValueString (Literals.binaryToString v1)+      Core.TermList v0 -> Model.ValueArray (Lists.map termToJsonValue v0)+      Core.TermMap v0 -> Model.ValueObject ((Lists.map (\entry ->+        let k = Pairs.first entry+            v = Pairs.second entry+        in (+          case k of+            Core.TermLiteral v1 -> case v1 of+              Core.LiteralString v2 -> v2+              _ -> "<key>"+            _ -> "<key>",+          (termToJsonValue v))) (Maps.toList v0)))+      Core.TermRecord v0 -> Logic.ifElse (Lists.null (Core.recordFields v0)) Model.ValueNull (Model.ValueString "<record>")+      _ -> Model.ValueString "<term>"+-- | Generate a default name for an anonymous type+typeToName :: Core.Type -> Core.Name+typeToName t =+    case (Strip.deannotateType t) of+      Core.TypeRecord _ -> Core.Name "Record"+      Core.TypeUnion _ -> Core.Name "Union"+      _ -> Core.Name "Unknown"+-- | Adapter for general unions (encoded as records with optional fields)+unionAsRecordAdapter :: t0 -> Core.Type -> Maybe Core.Name -> M.Map Core.Name Core.Term -> [Core.FieldType] -> Environment.EncodeEnvironment -> Either Errors.Error (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error, Environment.EncodeEnvironment)+unionAsRecordAdapter cx typ mName annotations fieldTypes env0 =+    Eithers.bind (foldFieldAdapters cx fieldTypes env0) (\faResult ->+      let fieldAdapters = Pairs.first faResult+          env1 = Pairs.second faResult+          avroFields =+                  Lists.map (\nameAd ->+                    let fname = Pairs.first nameAd+                        ad = Pairs.second nameAd+                    in Schema.Field {+                      Schema.fieldName = (localName fname),+                      Schema.fieldDoc = Nothing,+                      Schema.fieldType = (Schema.SchemaUnion (Schema.Union [+                        Schema.SchemaPrimitive Schema.PrimitiveNull,+                        (Coders.adapterTarget ad)])),+                      Schema.fieldDefault = (Just Model.ValueNull),+                      Schema.fieldOrder = Nothing,+                      Schema.fieldAliases = Nothing,+                      Schema.fieldAnnotations = Maps.empty}) fieldAdapters+          typeName = Optionals.fromOptional (typeToName typ) mName+          avroAnnotations = hydraAnnotationsToAvro annotations+          avroSchema =+                  Schema.SchemaNamed (Schema.Named {+                    Schema.namedName = (localName typeName),+                    Schema.namedNamespace = (nameNamespace typeName),+                    Schema.namedAliases = Nothing,+                    Schema.namedDoc = Nothing,+                    Schema.namedType = (Schema.NamedTypeRecord (Schema.Record {+                      Schema.recordFields = avroFields})),+                    Schema.namedAnnotations = avroAnnotations})+          adapter_ =+                  Coders.Adapter {+                    Coders.adapterIsLossy = True,+                    Coders.adapterSource = typ,+                    Coders.adapterTarget = avroSchema,+                    Coders.adapterCoder = Coders.Coder {+                      Coders.coderEncode = (\t -> case t of+                        Core.TermInject v0 ->+                          let activeName = Core.fieldName (Core.injectionField v0)+                              activeValue = Core.fieldTerm (Core.injectionField v0)+                              encodePair =+                                      \nameAd ->+                                        let fname = Pairs.first nameAd+                                            ad = Pairs.second nameAd+                                        in (Logic.ifElse (Equality.equal (Core.unName fname) (Core.unName activeName)) (Eithers.map (\jv -> (localName fname, jv)) (Coders.coderEncode (Coders.adapterCoder ad) activeValue)) (Right (localName fname, Model.ValueNull)))+                          in (Eithers.map (\pairs -> Model.ValueObject (pairs)) (Eithers.mapList encodePair fieldAdapters))+                        _ -> err cx "expected union term"),+                      Coders.coderDecode = (\j -> case j of+                        Model.ValueObject v0 ->+                          let findActive =+                                  \remaining -> Optionals.cases (Lists.uncons remaining) (err cx "no non-null field in union record") (\p ->+                                    let head_ = Pairs.first p+                                        rest_ = Pairs.second p+                                        fname = Pairs.first head_+                                        ad = Pairs.second head_+                                        mjv = Maps.lookup (localName fname) (Maps.fromList v0)+                                    in (Optionals.cases mjv (findActive rest_) (\jv -> case jv of+                                      Model.ValueNull -> findActive rest_+                                      _ -> Eithers.map (\t -> Core.TermInject (Core.Injection {+                                        Core.injectionTypeName = typeName,+                                        Core.injectionField = Core.Field {+                                          Core.fieldName = fname,+                                          Core.fieldTerm = t}})) (Coders.coderDecode (Coders.adapterCoder ad) jv))))+                          in (findActive fieldAdapters)+                        _ -> err cx "expected JSON object for union-as-record")}}+          env2 =+                  Environment.EncodeEnvironment {+                    Environment.encodeEnvironmentTypeMap = (Environment.encodeEnvironmentTypeMap env1),+                    Environment.encodeEnvironmentEmitted = (Maps.insert typeName adapter_ (Environment.encodeEnvironmentEmitted env1))}+      in (Right (adapter_, env2)))
+ src/main/haskell/Hydra/Avro/Environment.hs view
@@ -0,0 +1,66 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Type definitions for the Avro code generation environment++module Hydra.Avro.Environment where+import qualified Hydra.Avro.Schema as Schema+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Errors as Errors+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | An Avro qualified name with optional namespace+data AvroQualifiedName =+  AvroQualifiedName {+    -- | The optional namespace+    avroQualifiedNameNamespace :: (Maybe String),+    -- | The local name+    avroQualifiedNameName :: String}+  deriving (Eq, Ord, Read, Show)+_AvroQualifiedName = Core.Name "hydra.avro.environment.AvroQualifiedName"+_AvroQualifiedName_namespace = Core.Name "namespace"+_AvroQualifiedName_name = Core.Name "name"+-- | An Avro foreign key annotation linking a field to another type+data AvroForeignKey =+  AvroForeignKey {+    -- | The Hydra type name referenced by this foreign key+    avroForeignKeyTypeName :: Core.Name,+    -- | A function which constructs element names from string values+    avroForeignKeyConstructor :: (String -> Core.Name)}+_AvroForeignKey = Core.Name "hydra.avro.environment.AvroForeignKey"+_AvroForeignKey_typeName = Core.Name "typeName"+_AvroForeignKey_constructor = Core.Name "constructor"+-- | An Avro primary key annotation identifying the element name field+data AvroPrimaryKey =+  AvroPrimaryKey {+    -- | The name of the primary key field+    avroPrimaryKeyFieldName :: Core.Name,+    -- | A function which constructs element names from string values+    avroPrimaryKeyConstructor :: (String -> Core.Name)}+_AvroPrimaryKey = Core.Name "hydra.avro.environment.AvroPrimaryKey"+_AvroPrimaryKey_fieldName = Core.Name "fieldName"+_AvroPrimaryKey_constructor = Core.Name "constructor"+-- | Environment for Avro-to-Hydra code generation+data AvroEnvironment =+  AvroEnvironment {+    -- | Named adapters for previously processed schemas+    avroEnvironmentNamedAdapters :: (M.Map AvroQualifiedName (Coders.Adapter Schema.Schema Core.Type Model.Value Core.Term Errors.Error)),+    -- | The current Avro namespace+    avroEnvironmentNamespace :: (Maybe String),+    -- | Generated Hydra elements+    avroEnvironmentElements :: (M.Map Core.Name Core.Binding)}+_AvroEnvironment = Core.Name "hydra.avro.environment.AvroEnvironment"+_AvroEnvironment_namedAdapters = Core.Name "namedAdapters"+_AvroEnvironment_namespace = Core.Name "namespace"+_AvroEnvironment_elements = Core.Name "elements"+-- | Environment for Hydra-to-Avro encoding, tracking which named types have been emitted+data EncodeEnvironment =+  EncodeEnvironment {+    -- | All named types available for reference+    encodeEnvironmentTypeMap :: (M.Map Core.Name Core.Type),+    -- | Adapters for types that have already been fully emitted (emit references for these)+    encodeEnvironmentEmitted :: (M.Map Core.Name (Coders.Adapter Core.Type Schema.Schema Core.Term Model.Value Errors.Error))}+_EncodeEnvironment = Core.Name "hydra.avro.environment.EncodeEnvironment"+_EncodeEnvironment_typeMap = Core.Name "typeMap"+_EncodeEnvironment_emitted = Core.Name "emitted"
+ src/main/haskell/Hydra/Avro/Language.hs view
@@ -0,0 +1,81 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints for Apache Avro++module Hydra.Avro.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Language constraints for Apache Avro+avroLanguage :: Coders.Language+avroLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.avro"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64]+    termVariants =+        Sets.fromList [+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantRecord]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantWrap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantRecord]+    typePredicate =+        \typ -> case (Strip.deannotateType typ) of+          Core.TypeOptional v0 -> case (Strip.deannotateType v0) of+            Core.TypeOptional _ -> False+            _ -> True+          _ -> True
+ src/main/haskell/Hydra/Avro/Schema.hs view
@@ -0,0 +1,158 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for Avro schemas. Based on the Avro 1.11.1 specification:+-- |   https://avro.apache.org/docs/1.11.1/specification++module Hydra.Avro.Schema where+import qualified Hydra.Core as Core+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+data Array =+  Array {+    arrayItems :: Schema}+  deriving (Eq, Ord, Read, Show)+_Array = Core.Name "hydra.avro.schema.Array"+_Array_items = Core.Name "items"+data Enum =+  Enum {+    -- | a JSON array, listing symbols, as JSON strings. All symbols in an enum must be unique; duplicates are prohibited. Every symbol must match the regular expression [A-Za-z_][A-Za-z0-9_]* (the same requirement as for names)+    enumSymbols :: [String],+    -- | A default value for this enumeration, used during resolution when the reader encounters a symbol from the writer that isn't defined in the reader's schema. The value provided here must be a JSON string that's a member of the symbols array+    enumDefault :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Enum = Core.Name "hydra.avro.schema.Enum"+_Enum_symbols = Core.Name "symbols"+_Enum_default = Core.Name "default"+data Field =+  Field {+    -- | a JSON string providing the name of the field+    fieldName :: String,+    -- | a JSON string describing this field for users+    fieldDoc :: (Maybe String),+    -- | a schema+    fieldType :: Schema,+    -- | default value for this field, only used when reading instances that lack the field for schema evolution purposes+    fieldDefault :: (Maybe Model.Value),+    -- | specifies how this field impacts sort ordering of this record+    fieldOrder :: (Maybe Order),+    -- | a JSON array of strings, providing alternate names for this field+    fieldAliases :: (Maybe [String]),+    -- | Any additional key/value pairs attached to the field+    fieldAnnotations :: (M.Map String Model.Value)}+  deriving (Eq, Ord, Read, Show)+_Field = Core.Name "hydra.avro.schema.Field"+_Field_name = Core.Name "name"+_Field_doc = Core.Name "doc"+_Field_type = Core.Name "type"+_Field_default = Core.Name "default"+_Field_order = Core.Name "order"+_Field_aliases = Core.Name "aliases"+_Field_annotations = Core.Name "annotations"+data Fixed =+  Fixed {+    -- | an integer, specifying the number of bytes per value+    fixedSize :: Int}+  deriving (Eq, Ord, Read, Show)+_Fixed = Core.Name "hydra.avro.schema.Fixed"+_Fixed_size = Core.Name "size"+data Map =+  Map {+    mapValues :: Schema}+  deriving (Eq, Ord, Read, Show)+_Map = Core.Name "hydra.avro.schema.Map"+_Map_values = Core.Name "values"+data Named =+  Named {+    -- | a string naming this schema+    namedName :: String,+    -- | a string that qualifies the name+    namedNamespace :: (Maybe String),+    -- | a JSON array of strings, providing alternate names for this schema+    namedAliases :: (Maybe [String]),+    -- | a JSON string providing documentation to the user of this schema+    namedDoc :: (Maybe String),+    namedType :: NamedType,+    -- | Any additional key/value pairs attached to the type+    namedAnnotations :: (M.Map String Model.Value)}+  deriving (Eq, Ord, Read, Show)+_Named = Core.Name "hydra.avro.schema.Named"+_Named_name = Core.Name "name"+_Named_namespace = Core.Name "namespace"+_Named_aliases = Core.Name "aliases"+_Named_doc = Core.Name "doc"+_Named_type = Core.Name "type"+_Named_annotations = Core.Name "annotations"+data NamedType =+  NamedTypeEnum Enum |+  NamedTypeFixed Fixed |+  NamedTypeRecord Record+  deriving (Eq, Ord, Read, Show)+_NamedType = Core.Name "hydra.avro.schema.NamedType"+_NamedType_enum = Core.Name "enum"+_NamedType_fixed = Core.Name "fixed"+_NamedType_record = Core.Name "record"+data Order =+  OrderAscending |+  OrderDescending |+  OrderIgnore+  deriving (Eq, Ord, Read, Show)+_Order = Core.Name "hydra.avro.schema.Order"+_Order_ascending = Core.Name "ascending"+_Order_descending = Core.Name "descending"+_Order_ignore = Core.Name "ignore"+data Primitive =+  -- | no value+  PrimitiveNull |+  -- | A binary value+  PrimitiveBoolean |+  -- | 32-bit signed integer+  PrimitiveInt |+  -- | 64-bit signed integer+  PrimitiveLong |+  -- | single precision (32-bit) IEEE 754 floating-point number+  PrimitiveFloat |+  -- | double precision (64-bit) IEEE 754 floating-point number+  PrimitiveDouble |+  -- | sequence of 8-bit unsigned bytes+  PrimitiveBytes |+  -- | unicode character sequence+  PrimitiveString+  deriving (Eq, Ord, Read, Show)+_Primitive = Core.Name "hydra.avro.schema.Primitive"+_Primitive_null = Core.Name "null"+_Primitive_boolean = Core.Name "boolean"+_Primitive_int = Core.Name "int"+_Primitive_long = Core.Name "long"+_Primitive_float = Core.Name "float"+_Primitive_double = Core.Name "double"+_Primitive_bytes = Core.Name "bytes"+_Primitive_string = Core.Name "string"+data Record =+  Record {+    -- | a JSON array, listing fields+    recordFields :: [Field]}+  deriving (Eq, Ord, Read, Show)+_Record = Core.Name "hydra.avro.schema.Record"+_Record_fields = Core.Name "fields"+data Schema =+  SchemaArray Array |+  SchemaMap Map |+  SchemaNamed Named |+  SchemaPrimitive Primitive |+  -- | A reference by name to a previously defined type+  SchemaReference String |+  SchemaUnion Union+  deriving (Eq, Ord, Read, Show)+_Schema = Core.Name "hydra.avro.schema.Schema"+_Schema_array = Core.Name "array"+_Schema_map = Core.Name "map"+_Schema_named = Core.Name "named"+_Schema_primitive = Core.Name "primitive"+_Schema_reference = Core.Name "reference"+_Schema_union = Core.Name "union"+newtype Union =+  Union {+    unUnion :: [Schema]}+  deriving (Eq, Ord, Read, Show)+_Union = Core.Name "hydra.avro.schema.Union"
+ src/main/haskell/Hydra/Avro/SchemaJson.hs view
@@ -0,0 +1,371 @@+-- Note: this is an automatically generated file. Do not edit.+-- | JSON serialization and deserialization for Avro schemas++module Hydra.Avro.SchemaJson where+import qualified Hydra.Ast as Ast+import qualified Hydra.Avro.Schema as Schema+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Json.Parser as Parser+import qualified Hydra.Json.Writer as Writer+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Create a coder between Avro schemas and JSON values+avroSchemaJsonCoder :: t0 -> Coders.Coder Schema.Schema Model.Value Errors.Error+avroSchemaJsonCoder cx =+    Coders.Coder {+      Coders.coderEncode = (\schema -> Right (encodeSchema schema)),+      Coders.coderDecode = (\json -> decodeSchema cx json)}+-- | Create a coder between Avro schemas and JSON strings+avroSchemaStringCoder :: t0 -> Coders.Coder Schema.Schema String Errors.Error+avroSchemaStringCoder cx =+    Coders.Coder {+      Coders.coderEncode = (\schema -> Right (showJsonValue (encodeSchema schema))),+      Coders.coderDecode = (\s -> Eithers.bind (Eithers.either (\e -> err cx e) (\v -> Right v) (stringToJsonValue s)) (\json -> decodeSchema cx json))}+avro_aliases :: String+avro_aliases = "aliases"+avro_array :: String+avro_array = "array"+avro_ascending :: String+avro_ascending = "ascending"+avro_boolean :: String+avro_boolean = "boolean"+avro_bytes :: String+avro_bytes = "bytes"+avro_default :: String+avro_default = "default"+avro_descending :: String+avro_descending = "descending"+avro_doc :: String+avro_doc = "doc"+avro_double :: String+avro_double = "double"+avro_enum :: String+avro_enum = "enum"+avro_fields :: String+avro_fields = "fields"+avro_fixed :: String+avro_fixed = "fixed"+avro_float :: String+avro_float = "float"+avro_ignore :: String+avro_ignore = "ignore"+avro_int :: String+avro_int = "int"+avro_items :: String+avro_items = "items"+avro_long :: String+avro_long = "long"+avro_map :: String+avro_map = "map"+avro_name :: String+avro_name = "name"+avro_namespace :: String+avro_namespace = "namespace"+avro_null :: String+avro_null = "null"+avro_order :: String+avro_order = "order"+avro_record :: String+avro_record = "record"+avro_size :: String+avro_size = "size"+avro_string :: String+avro_string = "string"+avro_symbols :: String+avro_symbols = "symbols"+avro_type :: String+avro_type = "type"+avro_values :: String+avro_values = "values"+-- | Decode aliases from a JSON object map+decodeAliases :: t0 -> M.Map String Model.Value -> Either t1 (Maybe [String])+decodeAliases cx m =+    Eithers.bind (optArrayE cx avro_aliases m) (\mArr -> Optionals.cases mArr (Right Nothing) (\arr -> Eithers.map (\strs -> Optionals.pure strs) (Eithers.mapList (expectStringE cx) arr)))+-- | Decode an Avro array schema from a JSON object map+decodeArraySchema :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.Schema+decodeArraySchema cx m =+    Eithers.bind (requireE cx avro_items m) (\items -> Eithers.map (\s -> Schema.SchemaArray (Schema.Array {+      Schema.arrayItems = s})) (decodeSchema cx items))+-- | Decode an Avro enum type from a JSON object map+decodeEnum :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.NamedType+decodeEnum cx m =+    Eithers.bind (requireArrayE cx avro_symbols m) (\syms -> Eithers.bind (Eithers.mapList (expectStringE cx) syms) (\symbols -> Eithers.bind (optStringE cx avro_default m) (\defVal -> Right (Schema.NamedTypeEnum (Schema.Enum {+      Schema.enumSymbols = symbols,+      Schema.enumDefault = defVal})))))+-- | Decode an Avro field from a JSON object map+decodeField :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.Field+decodeField cx m =+    Eithers.bind (requireStringE cx avro_name m) (\name -> Eithers.bind (optStringE cx avro_doc m) (\fdoc -> Eithers.bind (requireE cx avro_type m) (\typeJson -> Eithers.bind (decodeSchema cx typeJson) (\fieldType -> Eithers.bind (Eithers.bind (optStringE cx avro_order m) (\mOrd -> Eithers.mapOptional (decodeOrder cx) mOrd)) (\order -> Eithers.bind (decodeAliases cx m) (\aliases -> Right (Schema.Field {+      Schema.fieldName = name,+      Schema.fieldDoc = fdoc,+      Schema.fieldType = fieldType,+      Schema.fieldDefault = (optE avro_default m),+      Schema.fieldOrder = order,+      Schema.fieldAliases = aliases,+      Schema.fieldAnnotations = (getAnnotations m)})))))))+-- | Decode an Avro fixed type from a JSON object map+decodeFixed :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.NamedType+decodeFixed cx m =+    Eithers.bind (requireNumberE cx avro_size m) (\n ->+      let size = Literals.bigintToInt32 (Literals.decimalToBigint n)+      in (Right (Schema.NamedTypeFixed (Schema.Fixed {+        Schema.fixedSize = size}))))+-- | Decode an Avro map schema from a JSON object map+decodeMapSchema :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.Schema+decodeMapSchema cx m =+    Eithers.bind (requireE cx avro_values m) (\values -> Eithers.map (\s -> Schema.SchemaMap (Schema.Map {+      Schema.mapValues = s})) (decodeSchema cx values))+-- | Decode a named Avro schema from a JSON object map and a decoded named type result+decodeNamedSchema :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.NamedType -> Either Errors.Error Schema.Schema+decodeNamedSchema cx m namedTypeResult =+    Eithers.bind (requireStringE cx avro_name m) (\name -> Eithers.bind (optStringE cx avro_namespace m) (\ns -> Eithers.bind (optStringE cx avro_doc m) (\sdoc -> Eithers.bind (decodeAliases cx m) (\aliases -> Eithers.bind namedTypeResult (\namedType -> Right (Schema.SchemaNamed (Schema.Named {+      Schema.namedName = name,+      Schema.namedNamespace = ns,+      Schema.namedAliases = aliases,+      Schema.namedDoc = sdoc,+      Schema.namedType = namedType,+      Schema.namedAnnotations = (getAnnotations m)})))))))+-- | Decode an Avro schema from a JSON object given the type name+decodeObjectSchema :: t0 -> M.Map String Model.Value -> String -> Either Errors.Error Schema.Schema+decodeObjectSchema cx m typeName =+    Logic.ifElse (Equality.equal typeName "array") (decodeArraySchema cx m) (Logic.ifElse (Equality.equal typeName "map") (decodeMapSchema cx m) (Logic.ifElse (Equality.equal typeName "record") (decodeNamedSchema cx m (decodeRecord cx m)) (Logic.ifElse (Equality.equal typeName "enum") (decodeNamedSchema cx m (decodeEnum cx m)) (Logic.ifElse (Equality.equal typeName "fixed") (decodeNamedSchema cx m (decodeFixed cx m)) (Optionals.cases (decodePrimitiveName typeName) (err cx (Strings.cat [+      "unknown type: ",+      typeName])) (\p -> Right (Schema.SchemaPrimitive p)))))))+-- | Decode an Avro field ordering from a string+decodeOrder :: t0 -> String -> Either Errors.Error Schema.Order+decodeOrder cx o =+    Logic.ifElse (Equality.equal o "ascending") (Right Schema.OrderAscending) (Logic.ifElse (Equality.equal o "descending") (Right Schema.OrderDescending) (Logic.ifElse (Equality.equal o "ignore") (Right Schema.OrderIgnore) (err cx (Strings.cat [+      "unknown order: ",+      o]))))+-- | Decode a primitive type name string to a Primitive, or Nothing if not a primitive+decodePrimitiveName :: String -> Maybe Schema.Primitive+decodePrimitiveName s =+    Logic.ifElse (Equality.equal s "null") (Just Schema.PrimitiveNull) (Logic.ifElse (Equality.equal s "boolean") (Just Schema.PrimitiveBoolean) (Logic.ifElse (Equality.equal s "int") (Just Schema.PrimitiveInt) (Logic.ifElse (Equality.equal s "long") (Just Schema.PrimitiveLong) (Logic.ifElse (Equality.equal s "float") (Just Schema.PrimitiveFloat) (Logic.ifElse (Equality.equal s "double") (Just Schema.PrimitiveDouble) (Logic.ifElse (Equality.equal s "bytes") (Just Schema.PrimitiveBytes) (Logic.ifElse (Equality.equal s "string") (Just Schema.PrimitiveString) Nothing)))))))+-- | Decode an Avro record type from a JSON object map+decodeRecord :: t0 -> M.Map String Model.Value -> Either Errors.Error Schema.NamedType+decodeRecord cx m =+    Eithers.bind (requireArrayE cx avro_fields m) (\fieldJsons -> Eithers.bind (Eithers.mapList (\fj -> Eithers.bind (expectObjectE cx fj) (\fm -> decodeField cx fm)) fieldJsons) (\fields -> Right (Schema.NamedTypeRecord (Schema.Record {+      Schema.recordFields = fields}))))+-- | Decode an Avro schema from a JSON value+decodeSchema :: t0 -> Model.Value -> Either Errors.Error Schema.Schema+decodeSchema cx v =+    case v of+      Model.ValueString v0 -> Optionals.cases (decodePrimitiveName v0) (Right (Schema.SchemaReference v0)) (\p -> Right (Schema.SchemaPrimitive p))+      Model.ValueArray v0 -> Eithers.map (\decoded -> Schema.SchemaUnion (Schema.Union decoded)) (Eithers.mapList (decodeSchema cx) v0)+      Model.ValueObject v0 -> Eithers.bind (requireStringE cx avro_type (Maps.fromList v0)) (\typeName -> decodeObjectSchema cx (Maps.fromList v0) typeName)+      _ -> err cx (Strings.cat [+        "unexpected JSON value for schema: ",+        (showJsonValue v)])+-- | Encode annotations as key-value pairs with @ prefix on keys+encodeAnnotations :: M.Map String t0 -> [(String, t0)]+encodeAnnotations m = Lists.map (\entry -> (Strings.cat2 "@" (Pairs.first entry), (Pairs.second entry))) (Maps.toList m)+-- | Encode an Avro array schema to a JSON object+encodeArray :: Schema.Array -> Model.Value+encodeArray arr =+    Model.ValueObject ([+      ("type", (Model.ValueString "array")),+      ("items", (encodeSchema (Schema.arrayItems arr)))])+-- | Encode an Avro enum type as key-value pairs+encodeEnum :: Schema.Enum -> [(String, Model.Value)]+encodeEnum e =+    Lists.concat [+      [+        ("type", (Model.ValueString "enum"))],+      [+        ("symbols", (Model.ValueArray (Lists.map (\s -> Model.ValueString s) (Schema.enumSymbols e))))],+      (Optionals.cases (Schema.enumDefault e) [] (\d -> [+        ("default", (Model.ValueString d))]))]+-- | Encode an Avro field to a JSON object+encodeField :: Schema.Field -> Model.Value+encodeField f =+    Model.ValueObject ((Lists.concat [+      [+        ("name", (Model.ValueString (Schema.fieldName f)))],+      [+        ("type", (encodeSchema (Schema.fieldType f)))],+      (Optionals.cases (Schema.fieldDoc f) [] (\d -> [+        ("doc", (Model.ValueString d))])),+      (Optionals.cases (Schema.fieldDefault f) [] (\d -> [+        ("default", d)])),+      (Optionals.cases (Schema.fieldOrder f) [] (\o -> [+        encodeOrder o])),+      (Optionals.cases (Schema.fieldAliases f) [] (\als -> [+        ("aliases", (Model.ValueArray (Lists.map (\a -> Model.ValueString a) als)))])),+      (encodeAnnotations (Schema.fieldAnnotations f))]))+-- | Encode an Avro fixed type as key-value pairs+encodeFixed :: Schema.Fixed -> [(String, Model.Value)]+encodeFixed f =+    [+      ("type", (Model.ValueString "fixed")),+      ("size", (Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint (Schema.fixedSize f)))))]+-- | Encode an Avro map schema to a JSON object+encodeMap :: Schema.Map -> Model.Value+encodeMap mp =+    Model.ValueObject ([+      ("type", (Model.ValueString "map")),+      ("values", (encodeSchema (Schema.mapValues mp)))])+-- | Encode an Avro named type to a JSON object+encodeNamed :: Schema.Named -> Model.Value+encodeNamed n =+    Model.ValueObject ((Lists.concat [+      [+        ("name", (Model.ValueString (Schema.namedName n)))],+      (Optionals.cases (Schema.namedNamespace n) [] (\ns -> [+        ("namespace", (Model.ValueString ns))])),+      (Optionals.cases (Schema.namedDoc n) [] (\d -> [+        ("doc", (Model.ValueString d))])),+      (Optionals.cases (Schema.namedAliases n) [] (\als -> [+        ("aliases", (Model.ValueArray (Lists.map (\a -> Model.ValueString a) als)))])),+      (encodeNamedType (Schema.namedType n)),+      (encodeAnnotations (Schema.namedAnnotations n))]))+-- | Encode the specific variant of a named Avro type+encodeNamedType :: Schema.NamedType -> [(String, Model.Value)]+encodeNamedType nt =+    case nt of+      Schema.NamedTypeEnum v0 -> encodeEnum v0+      Schema.NamedTypeFixed v0 -> encodeFixed v0+      Schema.NamedTypeRecord v0 -> encodeRecord v0+-- | Encode an Avro field ordering as a key-value pair+encodeOrder :: Schema.Order -> (String, Model.Value)+encodeOrder o =+    (+      "order",+      (Model.ValueString (case o of+        Schema.OrderAscending -> "ascending"+        Schema.OrderDescending -> "descending"+        Schema.OrderIgnore -> "ignore")))+-- | Encode an Avro primitive type as a JSON string+encodePrimitive :: Schema.Primitive -> Model.Value+encodePrimitive p =+    Model.ValueString (case p of+      Schema.PrimitiveNull -> "null"+      Schema.PrimitiveBoolean -> "boolean"+      Schema.PrimitiveInt -> "int"+      Schema.PrimitiveLong -> "long"+      Schema.PrimitiveFloat -> "float"+      Schema.PrimitiveDouble -> "double"+      Schema.PrimitiveBytes -> "bytes"+      Schema.PrimitiveString -> "string")+-- | Encode an Avro record type as key-value pairs+encodeRecord :: Schema.Record -> [(String, Model.Value)]+encodeRecord r =+    [+      ("type", (Model.ValueString "record")),+      ("fields", (Model.ValueArray (Lists.map encodeField (Schema.recordFields r))))]+-- | Encode an Avro schema to a JSON value+encodeSchema :: Schema.Schema -> Model.Value+encodeSchema schema =+    case schema of+      Schema.SchemaPrimitive v0 -> encodePrimitive v0+      Schema.SchemaArray v0 -> encodeArray v0+      Schema.SchemaMap v0 -> encodeMap v0+      Schema.SchemaNamed v0 -> encodeNamed v0+      Schema.SchemaReference v0 -> Model.ValueString v0+      Schema.SchemaUnion v0 -> encodeUnion v0+-- | Encode an Avro union as a JSON array of schemas+encodeUnion :: Schema.Union -> Model.Value+encodeUnion u = Model.ValueArray (Lists.map encodeSchema (Schema.unUnion u))+-- | Construct an error result with a message in context+err :: t0 -> String -> Either Errors.Error t1+err cx msg = Left (Errors.ErrorOther (Errors.OtherError msg))+-- | Extract a JSON array or return an error+expectArrayE :: t0 -> Model.Value -> Either t1 [Model.Value]+expectArrayE cx value =+    case value of+      Model.ValueArray v0 -> Right v0+-- | Extract a JSON number or return an error+expectNumberE :: t0 -> Model.Value -> Either t1 Sci.Scientific+expectNumberE cx value =+    case value of+      Model.ValueNumber v0 -> Right v0+-- | Extract a JSON object or return an error+expectObjectE :: t0 -> Model.Value -> Either t1 (M.Map String Model.Value)+expectObjectE cx value =+    case value of+      Model.ValueObject v0 -> Right (Maps.fromList v0)+-- | Extract a JSON string or return an error+expectStringE :: t0 -> Model.Value -> Either t1 String+expectStringE cx value =+    case value of+      Model.ValueString v0 -> Right v0+-- | Extract annotation entries (keys starting with @) from a JSON object map+getAnnotations :: M.Map String t0 -> M.Map String t0+getAnnotations m =+    Maps.fromList (Optionals.cat (Lists.map (\entry ->+      let k = Pairs.first entry+          v = Pairs.second entry+      in (Logic.ifElse (Equality.equal (Optionals.fromOptional 0 (Strings.maybeCharAt 0 k)) 64) (Optionals.pure (Strings.fromList (Lists.drop 1 (Strings.toList k)), v)) Nothing)) (Maps.toList m)))+-- | Look up an optional array attribute in a JSON object map+optArrayE :: Ord t1 => (t0 -> t1 -> M.Map t1 Model.Value -> Either t2 (Maybe [Model.Value]))+optArrayE cx fname m =+    Optionals.cases (Maps.lookup fname m) (Right Nothing) (\v -> Eithers.map (\a -> Optionals.pure a) (expectArrayE cx v))+-- | Look up an optional attribute in a JSON object map+optE :: Ord t0 => (t0 -> M.Map t0 t1 -> Maybe t1)+optE k m = Maps.lookup k m+-- | Look up an optional string attribute in a JSON object map+optStringE :: Ord t1 => (t0 -> t1 -> M.Map t1 Model.Value -> Either t2 (Maybe String))+optStringE cx fname m =+    Optionals.cases (Maps.lookup fname m) (Right Nothing) (\v -> Eithers.map (\s -> Optionals.pure s) (expectStringE cx v))+-- | Look up a required array attribute in a JSON object map+requireArrayE :: t0 -> String -> M.Map String Model.Value -> Either Errors.Error [Model.Value]+requireArrayE cx fname m = Eithers.bind (requireE cx fname m) (\v -> expectArrayE cx v)+-- | Look up a required attribute in a JSON object map+requireE :: t0 -> String -> M.Map String t1 -> Either Errors.Error t1+requireE cx fname m =+    Optionals.cases (Maps.lookup fname m) (err cx (Strings.cat [+      "required attribute ",+      (Literals.showString fname),+      " not found"])) (\v -> Right v)+-- | Look up a required number attribute in a JSON object map+requireNumberE :: t0 -> String -> M.Map String Model.Value -> Either Errors.Error Sci.Scientific+requireNumberE cx fname m = Eithers.bind (requireE cx fname m) (\v -> expectNumberE cx v)+-- | Look up a required string attribute in a JSON object map+requireStringE :: t0 -> String -> M.Map String Model.Value -> Either Errors.Error String+requireStringE cx fname m = Eithers.bind (requireE cx fname m) (\v -> expectStringE cx v)+-- | Convert a JSON value to its string representation+showJsonValue :: Model.Value -> String+showJsonValue v = Writer.printJson v+-- | Parse a JSON string, returning Either for compatibility+stringToJsonValue :: String -> Either String Model.Value+stringToJsonValue s =+    (\x -> case x of+      Parsing.ParseResultSuccess v0 -> Right (Parsing.parseSuccessValue v0)+      Parsing.ParseResultFailure v0 -> Left (Parsing.parseErrorMessage v0)) (Parser.parseJson s)+-- | Construct an error for unexpected values+unexpectedE :: t0 -> String -> String -> Either Errors.Error t1+unexpectedE cx expected found =+    err cx (Strings.cat [+      "Expected ",+      expected,+      ", found: ",+      found])
+ src/main/haskell/Hydra/Avro/Testing.hs view
@@ -0,0 +1,241 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Test case types for the bidirectional Avro coder++module Hydra.Avro.Testing where+import qualified Hydra.Avro.Schema as Schema+import qualified Hydra.Core as Core+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | A test case which maps an Avro schema to a Hydra type and compares the result+data TypeLevelForwardTestCase =+  TypeLevelForwardTestCase {+    -- | A human-readable description of what this test case covers+    typeLevelForwardTestCaseDescription :: String,+    -- | The input Avro schema+    typeLevelForwardTestCaseSchema :: Schema.Schema,+    -- | The expected Hydra type+    typeLevelForwardTestCaseType :: Core.Type}+  deriving (Eq, Ord, Read, Show)+_TypeLevelForwardTestCase = Core.Name "hydra.avro.testing.TypeLevelForwardTestCase"+_TypeLevelForwardTestCase_description = Core.Name "description"+_TypeLevelForwardTestCase_schema = Core.Name "schema"+_TypeLevelForwardTestCase_type = Core.Name "type"+-- | A test case which maps a Hydra type to an Avro schema and compares the result+data TypeLevelReverseTestCase =+  TypeLevelReverseTestCase {+    -- | A human-readable description of what this test case covers+    typeLevelReverseTestCaseDescription :: String,+    -- | The input Hydra type+    typeLevelReverseTestCaseType :: Core.Type,+    -- | The expected Avro schema+    typeLevelReverseTestCaseSchema :: Schema.Schema}+  deriving (Eq, Ord, Read, Show)+_TypeLevelReverseTestCase = Core.Name "hydra.avro.testing.TypeLevelReverseTestCase"+_TypeLevelReverseTestCase_description = Core.Name "description"+_TypeLevelReverseTestCase_type = Core.Name "type"+_TypeLevelReverseTestCase_schema = Core.Name "schema"+-- | A test case which maps an Avro schema to a Hydra type and back, verifying the result+data TypeLevelRoundTripAvroTestCase =+  TypeLevelRoundTripAvroTestCase {+    -- | A human-readable description of what this test case covers+    typeLevelRoundTripAvroTestCaseDescription :: String,+    -- | The original Avro schema+    typeLevelRoundTripAvroTestCaseSchema :: Schema.Schema,+    -- | The expected Avro schema after the round-trip, which may differ from the original due to normalization or information loss+    typeLevelRoundTripAvroTestCaseExpectedSchema :: Schema.Schema}+  deriving (Eq, Ord, Read, Show)+_TypeLevelRoundTripAvroTestCase = Core.Name "hydra.avro.testing.TypeLevelRoundTripAvroTestCase"+_TypeLevelRoundTripAvroTestCase_description = Core.Name "description"+_TypeLevelRoundTripAvroTestCase_schema = Core.Name "schema"+_TypeLevelRoundTripAvroTestCase_expectedSchema = Core.Name "expectedSchema"+-- | A test case which maps a Hydra type to an Avro schema and back, verifying the result+data TypeLevelRoundTripHydraTestCase =+  TypeLevelRoundTripHydraTestCase {+    -- | A human-readable description of what this test case covers+    typeLevelRoundTripHydraTestCaseDescription :: String,+    -- | The original Hydra type+    typeLevelRoundTripHydraTestCaseType :: Core.Type,+    -- | The expected Hydra type after the round-trip, which may differ from the original due to normalization or information loss+    typeLevelRoundTripHydraTestCaseExpectedType :: Core.Type}+  deriving (Eq, Ord, Read, Show)+_TypeLevelRoundTripHydraTestCase = Core.Name "hydra.avro.testing.TypeLevelRoundTripHydraTestCase"+_TypeLevelRoundTripHydraTestCase_description = Core.Name "description"+_TypeLevelRoundTripHydraTestCase_type = Core.Name "type"+_TypeLevelRoundTripHydraTestCase_expectedType = Core.Name "expectedType"+-- | A test case which encodes a JSON value as a Hydra term using an Avro schema+data TermLevelForwardTestCase =+  TermLevelForwardTestCase {+    -- | A human-readable description of what this test case covers+    termLevelForwardTestCaseDescription :: String,+    -- | The Avro schema describing the JSON value+    termLevelForwardTestCaseSchema :: Schema.Schema,+    -- | The input JSON value+    termLevelForwardTestCaseJson :: Model.Value,+    -- | The expected Hydra term+    termLevelForwardTestCaseTerm :: Core.Term}+  deriving (Eq, Ord, Read, Show)+_TermLevelForwardTestCase = Core.Name "hydra.avro.testing.TermLevelForwardTestCase"+_TermLevelForwardTestCase_description = Core.Name "description"+_TermLevelForwardTestCase_schema = Core.Name "schema"+_TermLevelForwardTestCase_json = Core.Name "json"+_TermLevelForwardTestCase_term = Core.Name "term"+-- | A test case which decodes a Hydra term to a JSON value using an Avro schema+data TermLevelReverseTestCase =+  TermLevelReverseTestCase {+    -- | A human-readable description of what this test case covers+    termLevelReverseTestCaseDescription :: String,+    -- | The Avro schema describing the expected JSON value+    termLevelReverseTestCaseSchema :: Schema.Schema,+    -- | The input Hydra term+    termLevelReverseTestCaseTerm :: Core.Term,+    -- | The expected JSON value+    termLevelReverseTestCaseJson :: Model.Value}+  deriving (Eq, Ord, Read, Show)+_TermLevelReverseTestCase = Core.Name "hydra.avro.testing.TermLevelReverseTestCase"+_TermLevelReverseTestCase_description = Core.Name "description"+_TermLevelReverseTestCase_schema = Core.Name "schema"+_TermLevelReverseTestCase_term = Core.Name "term"+_TermLevelReverseTestCase_json = Core.Name "json"+-- | A test case which encodes a JSON value as a Hydra term and decodes it back, verifying the result+data TermLevelRoundTripJsonTestCase =+  TermLevelRoundTripJsonTestCase {+    -- | A human-readable description of what this test case covers+    termLevelRoundTripJsonTestCaseDescription :: String,+    -- | The Avro schema describing the JSON value+    termLevelRoundTripJsonTestCaseSchema :: Schema.Schema,+    -- | The original JSON value+    termLevelRoundTripJsonTestCaseJson :: Model.Value,+    -- | The expected JSON value after the round-trip, which may differ from the original due to normalization+    termLevelRoundTripJsonTestCaseExpectedJson :: Model.Value}+  deriving (Eq, Ord, Read, Show)+_TermLevelRoundTripJsonTestCase = Core.Name "hydra.avro.testing.TermLevelRoundTripJsonTestCase"+_TermLevelRoundTripJsonTestCase_description = Core.Name "description"+_TermLevelRoundTripJsonTestCase_schema = Core.Name "schema"+_TermLevelRoundTripJsonTestCase_json = Core.Name "json"+_TermLevelRoundTripJsonTestCase_expectedJson = Core.Name "expectedJson"+-- | A test case which decodes a Hydra term to JSON and encodes it back, verifying the result+data TermLevelRoundTripTermTestCase =+  TermLevelRoundTripTermTestCase {+    -- | A human-readable description of what this test case covers+    termLevelRoundTripTermTestCaseDescription :: String,+    -- | The Hydra type of the term+    termLevelRoundTripTermTestCaseType :: Core.Type,+    -- | The original Hydra term+    termLevelRoundTripTermTestCaseTerm :: Core.Term,+    -- | The expected Hydra term after the round-trip, which may differ from the original due to normalization+    termLevelRoundTripTermTestCaseExpectedTerm :: Core.Term}+  deriving (Eq, Ord, Read, Show)+_TermLevelRoundTripTermTestCase = Core.Name "hydra.avro.testing.TermLevelRoundTripTermTestCase"+_TermLevelRoundTripTermTestCase_description = Core.Name "description"+_TermLevelRoundTripTermTestCase_type = Core.Name "type"+_TermLevelRoundTripTermTestCase_term = Core.Name "term"+_TermLevelRoundTripTermTestCase_expectedTerm = Core.Name "expectedTerm"+-- | A test case for union type encoding and decoding, covering the various strategies for representing unions in Avro+data UnionTestCase =+  UnionTestCase {+    -- | A human-readable description of what this test case covers+    unionTestCaseDescription :: String,+    -- | The Hydra union type+    unionTestCaseHydraType :: Core.Type,+    -- | The expected Avro schema (enum for all-unit unions, record with optional fields for general unions)+    unionTestCaseAvroSchema :: Schema.Schema,+    -- | Pairs of corresponding Hydra terms and JSON values for this union+    unionTestCaseTermPairs :: [(Core.Term, Model.Value)]}+  deriving (Eq, Ord, Read, Show)+_UnionTestCase = Core.Name "hydra.avro.testing.UnionTestCase"+_UnionTestCase_description = Core.Name "description"+_UnionTestCase_hydraType = Core.Name "hydraType"+_UnionTestCase_avroSchema = Core.Name "avroSchema"+_UnionTestCase_termPairs = Core.Name "termPairs"+-- | A test case for bidirectional name mapping between Hydra and Avro+data NameMappingTestCase =+  NameMappingTestCase {+    -- | A human-readable description of what this test case covers+    nameMappingTestCaseDescription :: String,+    -- | The Hydra name+    nameMappingTestCaseHydraName :: Core.Name,+    -- | The expected Avro qualified name (dotted string)+    nameMappingTestCaseAvroName :: String,+    -- | The expected Avro namespace, if any+    nameMappingTestCaseAvroNamespace :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_NameMappingTestCase = Core.Name "hydra.avro.testing.NameMappingTestCase"+_NameMappingTestCase_description = Core.Name "description"+_NameMappingTestCase_hydraName = Core.Name "hydraName"+_NameMappingTestCase_avroName = Core.Name "avroName"+_NameMappingTestCase_avroNamespace = Core.Name "avroNamespace"+-- | A test case which verifies that lossy conversions stash original information in annotations+data LossinessTestCase =+  LossinessTestCase {+    -- | A human-readable description of what this test case covers+    lossinessTestCaseDescription :: String,+    -- | The original Avro schema containing information that may be lost+    lossinessTestCaseOriginalSchema :: Schema.Schema,+    -- | The resulting Hydra type, which should carry annotations for any lost information+    lossinessTestCaseHydraType :: Core.Type,+    -- | The Avro schema recovered from the annotated Hydra type+    lossinessTestCaseRecoveredSchema :: Schema.Schema,+    -- | Whether the adapter reports this conversion as lossy+    lossinessTestCaseIsLossy :: Bool}+  deriving (Eq, Ord, Read, Show)+_LossinessTestCase = Core.Name "hydra.avro.testing.LossinessTestCase"+_LossinessTestCase_description = Core.Name "description"+_LossinessTestCase_originalSchema = Core.Name "originalSchema"+_LossinessTestCase_hydraType = Core.Name "hydraType"+_LossinessTestCase_recoveredSchema = Core.Name "recoveredSchema"+_LossinessTestCase_isLossy = Core.Name "isLossy"+-- | A test case for Avro schema serialization to and from JSON+data SchemaSerializationTestCase =+  SchemaSerializationTestCase {+    -- | A human-readable description of what this test case covers+    schemaSerializationTestCaseDescription :: String,+    -- | The Avro schema+    schemaSerializationTestCaseSchema :: Schema.Schema,+    -- | The expected JSON representation of the schema+    schemaSerializationTestCaseJson :: Model.Value}+  deriving (Eq, Ord, Read, Show)+_SchemaSerializationTestCase = Core.Name "hydra.avro.testing.SchemaSerializationTestCase"+_SchemaSerializationTestCase_description = Core.Name "description"+_SchemaSerializationTestCase_schema = Core.Name "schema"+_SchemaSerializationTestCase_json = Core.Name "json"+-- | A test case for the bidirectional Avro coder+data AvroTestCase =+  -- | Type-level forward mapping (Avro Schema -> Hydra Type)+  AvroTestCaseTypeLevelForward TypeLevelForwardTestCase |+  -- | Type-level reverse mapping (Hydra Type -> Avro Schema)+  AvroTestCaseTypeLevelReverse TypeLevelReverseTestCase |+  -- | Type-level round-trip starting from Avro (Avro -> Hydra -> Avro)+  AvroTestCaseTypeLevelRoundTripAvro TypeLevelRoundTripAvroTestCase |+  -- | Type-level round-trip starting from Hydra (Hydra -> Avro -> Hydra)+  AvroTestCaseTypeLevelRoundTripHydra TypeLevelRoundTripHydraTestCase |+  -- | Term-level forward mapping (JSON -> Hydra Term)+  AvroTestCaseTermLevelForward TermLevelForwardTestCase |+  -- | Term-level reverse mapping (Hydra Term -> JSON)+  AvroTestCaseTermLevelReverse TermLevelReverseTestCase |+  -- | Term-level round-trip starting from JSON (JSON -> Term -> JSON)+  AvroTestCaseTermLevelRoundTripJson TermLevelRoundTripJsonTestCase |+  -- | Term-level round-trip starting from a term (Term -> JSON -> Term)+  AvroTestCaseTermLevelRoundTripTerm TermLevelRoundTripTermTestCase |+  -- | Union-specific encoding and decoding+  AvroTestCaseUnion UnionTestCase |+  -- | Name mapping between Hydra and Avro+  AvroTestCaseNameMapping NameMappingTestCase |+  -- | Lossy conversion with annotation stashing+  AvroTestCaseLossiness LossinessTestCase |+  -- | Schema serialization to and from JSON+  AvroTestCaseSchemaSerialization SchemaSerializationTestCase+  deriving (Eq, Ord, Read, Show)+_AvroTestCase = Core.Name "hydra.avro.testing.AvroTestCase"+_AvroTestCase_typeLevelForward = Core.Name "typeLevelForward"+_AvroTestCase_typeLevelReverse = Core.Name "typeLevelReverse"+_AvroTestCase_typeLevelRoundTripAvro = Core.Name "typeLevelRoundTripAvro"+_AvroTestCase_typeLevelRoundTripHydra = Core.Name "typeLevelRoundTripHydra"+_AvroTestCase_termLevelForward = Core.Name "termLevelForward"+_AvroTestCase_termLevelReverse = Core.Name "termLevelReverse"+_AvroTestCase_termLevelRoundTripJson = Core.Name "termLevelRoundTripJson"+_AvroTestCase_termLevelRoundTripTerm = Core.Name "termLevelRoundTripTerm"+_AvroTestCase_union = Core.Name "union"+_AvroTestCase_nameMapping = Core.Name "nameMapping"+_AvroTestCase_lossiness = Core.Name "lossiness"+_AvroTestCase_schemaSerialization = Core.Name "schemaSerialization"
+ src/main/haskell/Hydra/Azure/Dtld.hs view
@@ -0,0 +1,543 @@+-- Note: this is an automatically generated file. Do not edit.+-- | An Azure Digital Twin Definition Language (DTLD) model. Based on:+-- |   https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#digital-twins-definition-language+-- | DTLD features which are not currently included in this model:+-- |   * geospatial schemas (https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#geospatial-schemas)+-- |   * semantic types and units (https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#semantic-types)+-- |   * model versioning (https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#model-versioning)++module Hydra.Azure.Dtld where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | A Command describes a function or operation that can be performed on any digital twin.+data Command =+  Command {+    -- | This must be 'Command'+    commandType :: Iri,+    -- | The 'programming' name of the command. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    commandName :: String,+    -- | The ID of the command. If no @id is provided, the digital twin interface processor will assign one.+    commandId :: (Maybe Dtmi),+    -- | A comment for model authors+    commandComment :: (Maybe String),+    -- | A localizable description for display+    commandDescription :: (Maybe String),+    -- | A localizable name for display+    commandDisplayName :: (Maybe String),+    -- | This property is deprecated. Either value, synchronous or asynchronous, has the same meaning: a command that starts execution within a configurable time and that completes execution within a configurable time.+    commandCommandType :: (Maybe CommandType),+    -- | A description of the input to the Command+    commandRequest :: (Maybe CommandPayload),+    -- | A description of the output of the Command+    commandResponse :: (Maybe CommandPayload)}+  deriving (Eq, Ord, Read, Show)+_Command = Core.Name "hydra.azure.dtld.Command"+_Command_type = Core.Name "type"+_Command_name = Core.Name "name"+_Command_id = Core.Name "id"+_Command_comment = Core.Name "comment"+_Command_description = Core.Name "description"+_Command_displayName = Core.Name "displayName"+_Command_commandType = Core.Name "commandType"+_Command_request = Core.Name "request"+_Command_response = Core.Name "response"+-- | A CommandPayload describes the inputs to or the outputs from a Command.+data CommandPayload =+  CommandPayload {+    -- | The 'programming' name of the payload. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    commandPayloadName :: String,+    -- | The data type of the payload+    commandPayloadSchema :: Schema,+    -- | The ID of the payload. If no @id is provided, the digital twin interface processor will assign one.+    commandPayloadId :: (Maybe Dtmi),+    -- | A comment for model authors+    commandPayloadComment :: (Maybe String),+    -- | A localizable description for display+    commandPayloadDescription :: (Maybe String),+    -- | A localizable name for display+    commandPayloadDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_CommandPayload = Core.Name "hydra.azure.dtld.CommandPayload"+_CommandPayload_name = Core.Name "name"+_CommandPayload_schema = Core.Name "schema"+_CommandPayload_id = Core.Name "id"+_CommandPayload_comment = Core.Name "comment"+_CommandPayload_description = Core.Name "description"+_CommandPayload_displayName = Core.Name "displayName"+-- | CommandType is deprecated. Either value, synchronous or asynchronous, has the same meaning: a command that starts execution within a configurable time and that completes execution within a configurable time.+data CommandType =+  CommandTypeSynchronous |+  CommandTypeAsynchronous+  deriving (Eq, Ord, Read, Show)+_CommandType = Core.Name "hydra.azure.dtld.CommandType"+_CommandType_synchronous = Core.Name "synchronous"+_CommandType_asynchronous = Core.Name "asynchronous"+-- | Components enable interfaces to be composed of other interfaces. Components are different from relationships because they describe contents that are directly part of the interface. (A relationship describes a link between two interfaces.)+data Component =+  Component {+    -- | This must be 'Component'+    componentType :: Iri,+    -- | The 'programming' name of the component. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    componentName :: String,+    -- | The data type of the component+    componentSchema :: Interface,+    -- | The ID of the component. If no @id is provided, the digital twin interface processor will assign one.+    componentId :: (Maybe Dtmi),+    -- | A comment for model authors+    componentComment :: (Maybe String),+    -- | A localizable description for display+    componentDescription :: (Maybe String),+    -- | A localizable name for display+    componentDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Component = Core.Name "hydra.azure.dtld.Component"+_Component_type = Core.Name "type"+_Component_name = Core.Name "name"+_Component_schema = Core.Name "schema"+_Component_id = Core.Name "id"+_Component_comment = Core.Name "comment"+_Component_description = Core.Name "description"+_Component_displayName = Core.Name "displayName"+-- | A digital twin model identifier+newtype Dtmi =+  Dtmi {+    unDtmi :: String}+  deriving (Eq, Ord, Read, Show)+_Dtmi = Core.Name "hydra.azure.dtld.Dtmi"+-- | An EnumValue describes an element of an Enum.+data EnumValue =+  EnumValue {+    -- | The 'programming' name of the enum value. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    enumValueName :: String,+    -- | The on-the-wire value that maps to the EnumValue. EnumValue may be either an integer or a string and must be unique for all enum values in this enum.+    enumValueEnumValue :: IntegerOrString,+    -- | The ID of the enum value. If no @id is provided, the digital twin interface processor will assign one.+    enumValueId :: (Maybe Dtmi),+    -- | A comment for model authors+    enumValueComment :: (Maybe String),+    -- | A localizable description for display+    enumValueDescription :: (Maybe String),+    -- | A localizable name for display+    enumValueDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_EnumValue = Core.Name "hydra.azure.dtld.EnumValue"+_EnumValue_name = Core.Name "name"+_EnumValue_enumValue = Core.Name "enumValue"+_EnumValue_id = Core.Name "id"+_EnumValue_comment = Core.Name "comment"+_EnumValue_description = Core.Name "description"+_EnumValue_displayName = Core.Name "displayName"+-- | A Field describes a field in an Object.+data Field =+  Field {+    -- | The 'programming' name of the field. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    fieldName :: String,+    -- | The data type of the field+    fieldSchema :: Schema,+    -- | The ID of the field. If no @id is provided, the digital twin interface processor will assign one.+    fieldId :: (Maybe Dtmi),+    -- | A comment for model authors+    fieldComment :: (Maybe String),+    -- | A localizable description for display+    fieldDescription :: (Maybe String),+    -- | A localizable name for display+    fieldDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Field = Core.Name "hydra.azure.dtld.Field"+_Field_name = Core.Name "name"+_Field_schema = Core.Name "schema"+_Field_id = Core.Name "id"+_Field_comment = Core.Name "comment"+_Field_description = Core.Name "description"+_Field_displayName = Core.Name "displayName"+data IntegerOrString =+  IntegerOrStringInteger Int |+  IntegerOrStringString String+  deriving (Eq, Ord, Read, Show)+_IntegerOrString = Core.Name "hydra.azure.dtld.IntegerOrString"+_IntegerOrString_integer = Core.Name "integer"+_IntegerOrString_string = Core.Name "string"+data Interface =+  Interface {+    -- | A digital twin model identifier for the interface+    interfaceId :: Dtmi,+    -- | This must be 'Interface'+    interfaceType :: Iri,+    -- | The context to use when processing this interface. For this version, it must be set to 'dtmi:dtdl:context;2'+    interfaceContext :: Iri,+    -- | A comment for model authors+    interfaceComment :: (Maybe String),+    -- | A set of objects that define the contents (Telemetry, Properties, Commands, Relationships, and/or Components) of this interface+    interfaceContents :: (Maybe (S.Set Interface_Contents)),+    -- | A localizable description for display+    interfaceDescription :: (Maybe String),+    -- | A localizable name for display+    interfaceDisplayName :: (Maybe String),+    -- | A set of DTMIs that refer to interfaces this interface inherits from. Interfaces can inherit from multiple interfaces.+    interfaceExtends :: (Maybe (S.Set Interface)),+    -- | A set of IRIs or objects that refer to the reusable schemas within this interface.+    interfaceSchemas :: (Maybe (S.Set Schema_Interface))}+  deriving (Eq, Ord, Read, Show)+_Interface = Core.Name "hydra.azure.dtld.Interface"+_Interface_id = Core.Name "id"+_Interface_type = Core.Name "type"+_Interface_context = Core.Name "context"+_Interface_comment = Core.Name "comment"+_Interface_contents = Core.Name "contents"+_Interface_description = Core.Name "description"+_Interface_displayName = Core.Name "displayName"+_Interface_extends = Core.Name "extends"+_Interface_schemas = Core.Name "schemas"+data Interface_Contents =+  Interface_ContentsCommand Command |+  Interface_ContentsComponent Component |+  Interface_ContentsProperty Property |+  Interface_ContentsRelationship Relationship |+  Interface_ContentsTelemetry Telemetry+  deriving (Eq, Ord, Read, Show)+_Interface_Contents = Core.Name "hydra.azure.dtld.Interface_Contents"+_Interface_Contents_command = Core.Name "command"+_Interface_Contents_component = Core.Name "component"+_Interface_Contents_property = Core.Name "property"+_Interface_Contents_relationship = Core.Name "relationship"+_Interface_Contents_telemetry = Core.Name "telemetry"+newtype Iri =+  Iri {+    unIri :: String}+  deriving (Eq, Ord, Read, Show)+_Iri = Core.Name "hydra.azure.dtld.Iri"+-- | A MapKey describes the key in a Map. The schema of a MapKey must be string.+data MapKey =+  MapKey {+    -- | The 'programming' name of the map's key. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    mapKeyName :: String,+    -- | The data type of the map's key+    mapKeySchema :: Schema,+    -- | The ID of the map key. If no @id is provided, the digital twin interface processor will assign one.+    mapKeyId :: (Maybe Dtmi),+    -- | A comment for model authors+    mapKeyComment :: (Maybe String),+    -- | A localizable description for display+    mapKeyDescription :: (Maybe String),+    -- | A localizable name for display+    mapKeyDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_MapKey = Core.Name "hydra.azure.dtld.MapKey"+_MapKey_name = Core.Name "name"+_MapKey_schema = Core.Name "schema"+_MapKey_id = Core.Name "id"+_MapKey_comment = Core.Name "comment"+_MapKey_description = Core.Name "description"+_MapKey_displayName = Core.Name "displayName"+-- | A MapValue describes the values in a Map.+data MapValue =+  MapValue {+    -- | The 'programming' name of the map's value. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    mapValueName :: String,+    -- | The data type of the map's values+    mapValueSchema :: Schema,+    -- | The ID of the map value. If no @id is provided, the digital twin interface processor will assign one.+    mapValueId :: (Maybe Dtmi),+    -- | A comment for model authors+    mapValueComment :: (Maybe String),+    -- | A localizable description for display+    mapValueDescription :: (Maybe String),+    -- | A localizable name for display+    mapValueDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_MapValue = Core.Name "hydra.azure.dtld.MapValue"+_MapValue_name = Core.Name "name"+_MapValue_schema = Core.Name "schema"+_MapValue_id = Core.Name "id"+_MapValue_comment = Core.Name "comment"+_MapValue_description = Core.Name "description"+_MapValue_displayName = Core.Name "displayName"+-- | A Property describes the read-only and read/write state of any digital twin. For example, a device serial number may be a read-only property, the desired temperature on a thermostat may be a read-write property; and the name of a room may be a read-write property.+data Property =+  Property {+    -- | This must at least be 'Property'. It can also include a semantic type.+    propertyType :: Iri,+    -- | The 'programming' name of the property. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$..+    propertyName :: String,+    -- | The data type of the Property+    propertySchema :: Schema,+    -- | The ID of the property. If no @id is provided, the digital twin interface processor will assign one.+    propertyId :: (Maybe Dtmi),+    -- | A comment for model authors+    propertyComment :: (Maybe String),+    -- | A localizable description for display+    propertyDescription :: (Maybe String),+    -- | A localizable name for display+    propertyDisplayName :: (Maybe String),+    -- | The unit type of the property. A semantic type is required for the unit property to be available.+    propertyUnit :: (Maybe Unit),+    -- | A boolean value that indicates whether the property is writable by an external source, such as an application, or not. The default value is false (read-only).+    propertyWritable :: (Maybe Bool)}+  deriving (Eq, Ord, Read, Show)+_Property = Core.Name "hydra.azure.dtld.Property"+_Property_type = Core.Name "type"+_Property_name = Core.Name "name"+_Property_schema = Core.Name "schema"+_Property_id = Core.Name "id"+_Property_comment = Core.Name "comment"+_Property_description = Core.Name "description"+_Property_displayName = Core.Name "displayName"+_Property_unit = Core.Name "unit"+_Property_writable = Core.Name "writable"+-- | A Relationship describes a link to another digital twin and enables graphs of digital twins to be created. Relationships are different from Components because they describe a link to a separate digital twin.+data Relationship =+  Relationship {+    -- | This must be 'Relationship'+    relationshipType :: Iri,+    -- | The 'programming' name of the relationship. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$.+    relationshipName :: String,+    -- | The ID of the relationship description. If no @id is provided, the digital twin interface processor will assign one.+    relationshipId :: (Maybe Dtmi),+    -- | A comment for model authors+    relationshipComment :: (Maybe String),+    -- | A localizable description for display+    relationshipDescription :: (Maybe String),+    -- | A localizable name for display+    relationshipDisplayName :: (Maybe String),+    -- | The maximum multiplicity for the target of the relationship. The default value is infinite (there may be an unlimited number of relationship instances for this relationship).+    relationshipMaxMultiplicity :: (Maybe Int),+    -- | The minimum multiplicity for the target of the relationship. The default value is 0 (this relationship is permitted to have no instances). In DTDL v2, minMultiplicity must always be 0.+    relationshipMinMultiplicity :: (Maybe Int),+    -- | A set of Properties that define relationship-specific state+    relationshipProperties :: (Maybe (S.Set Property)),+    -- | An interface ID. The default value (when target is not specified) is that the target may be any interface.+    relationshipTarget :: (Maybe Interface),+    -- | A boolean value that indicates whether the relationship is writable by an external source, such as an application, or not. The default value is false (read-only).+    relationshipWritable :: (Maybe Bool)}+  deriving (Eq, Ord, Read, Show)+_Relationship = Core.Name "hydra.azure.dtld.Relationship"+_Relationship_type = Core.Name "type"+_Relationship_name = Core.Name "name"+_Relationship_id = Core.Name "id"+_Relationship_comment = Core.Name "comment"+_Relationship_description = Core.Name "description"+_Relationship_displayName = Core.Name "displayName"+_Relationship_maxMultiplicity = Core.Name "maxMultiplicity"+_Relationship_minMultiplicity = Core.Name "minMultiplicity"+_Relationship_properties = Core.Name "properties"+_Relationship_target = Core.Name "target"+_Relationship_writable = Core.Name "writable"+-- | Schemas are used to describe the on-the-wire or serialized format of the data in a digital twin interface. A full set of primitive data types are provided, along with support for a variety of complex schemas in the forms of Arrays, Enums, Maps, and Objects. Schemas described through digital twin's schema definition language are compatible with popular serialization formats, including JSON, Avro, and Protobuf.+data Schema =+  SchemaPrimitive Schema_Primitive |+  SchemaComplex Schema_Complex+  deriving (Eq, Ord, Read, Show)+_Schema = Core.Name "hydra.azure.dtld.Schema"+_Schema_primitive = Core.Name "primitive"+_Schema_complex = Core.Name "complex"+-- | An Array describes an indexable data type where each element is of the same schema. An Array elements' schema can itself be a primitive or complex schema.+data Schema_Array =+  Schema_Array {+    -- | This must be 'Array'+    schema_ArrayType :: Iri,+    -- | The data type of the array elements+    schema_ArrayElementSchema :: Schema,+    -- | The ID of the array. If no @id is provided, the digital twin interface processor will assign one.+    schema_ArrayId :: (Maybe Dtmi),+    -- | A comment for model authors+    schema_ArrayComment :: (Maybe String),+    -- | A localizable description for display+    schema_ArrayDescription :: (Maybe String),+    -- | A localizable name for display+    schema_ArrayDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Schema_Array = Core.Name "hydra.azure.dtld.Schema_Array"+_Schema_Array_type = Core.Name "type"+_Schema_Array_elementSchema = Core.Name "elementSchema"+_Schema_Array_id = Core.Name "id"+_Schema_Array_comment = Core.Name "comment"+_Schema_Array_description = Core.Name "description"+_Schema_Array_displayName = Core.Name "displayName"+-- | Complex schemas are designed for supporting complex data types made up of primitive data types. Currently the following complex schemas are provided: Array, Enum, Map, and Object. A complex schema can be specified directly as the value in a schema statement or described in the interface schemas set and referenced in the schema statement.+data Schema_Complex =+  Schema_ComplexArray Schema_Array |+  Schema_ComplexEnum Schema_Enum |+  Schema_ComplexMap Schema_Map |+  Schema_ComplexObject Schema_Object+  deriving (Eq, Ord, Read, Show)+_Schema_Complex = Core.Name "hydra.azure.dtld.Schema_Complex"+_Schema_Complex_array = Core.Name "array"+_Schema_Complex_enum = Core.Name "enum"+_Schema_Complex_map = Core.Name "map"+_Schema_Complex_object = Core.Name "object"+-- | An Enum describes a data type with a set of named labels that map to values. The values in an Enum can be either integers or strings, but the labels are always strings.+data Schema_Enum =+  Schema_Enum {+    -- | Enum+    schema_EnumType :: Iri,+    -- | A set of enum value and label mappings+    schema_EnumEnumValues :: [EnumValue],+    -- | The data type for the enum values. All enum values must be of the same type.+    schema_EnumValueSchema :: IntegerOrString,+    -- | The ID of the enum. If no @id is provided, the digital twin interface processor will assign one.+    schema_EnumId :: (Maybe Dtmi),+    -- | A comment for model authors+    schema_EnumComment :: (Maybe String),+    -- | A localizable description for display+    schema_EnumDescription :: (Maybe String),+    -- | A localizable name for display+    schema_EnumDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Schema_Enum = Core.Name "hydra.azure.dtld.Schema_Enum"+_Schema_Enum_type = Core.Name "type"+_Schema_Enum_enumValues = Core.Name "enumValues"+_Schema_Enum_valueSchema = Core.Name "valueSchema"+_Schema_Enum_id = Core.Name "id"+_Schema_Enum_comment = Core.Name "comment"+_Schema_Enum_description = Core.Name "description"+_Schema_Enum_displayName = Core.Name "displayName"+-- | Within an interface definition, complex schemas may be defined for reusability across Telemetry, Properties, and Commands. This is designed to promote readability and improved maintenance because schemas that are reused can be defined once (per interface). Interface schemas are defined in the schemas property of an interface.+data Schema_Interface =+  Schema_Interface {+    -- | The globally unique identifier for the schema+    schema_InterfaceId :: Dtmi,+    -- | The type of complex schema. This must refer to one of the complex schema classes (Array, Enum, Map, or Object).+    schema_InterfaceType :: Schema_Interface_Type,+    -- | A comment for model authors+    schema_InterfaceComment :: (Maybe String),+    -- | A localizable description for display+    schema_InterfaceDescription :: (Maybe String),+    -- | A localizable name for display+    schema_InterfaceDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Schema_Interface = Core.Name "hydra.azure.dtld.Schema_Interface"+_Schema_Interface_id = Core.Name "id"+_Schema_Interface_type = Core.Name "type"+_Schema_Interface_comment = Core.Name "comment"+_Schema_Interface_description = Core.Name "description"+_Schema_Interface_displayName = Core.Name "displayName"+data Schema_Interface_Type =+  Schema_Interface_TypeArray Schema_Array |+  Schema_Interface_TypeEnum Schema_Enum |+  Schema_Interface_TypeMap Schema_Map |+  Schema_Interface_TypeObject Schema_Object+  deriving (Eq, Ord, Read, Show)+_Schema_Interface_Type = Core.Name "hydra.azure.dtld.Schema_Interface_Type"+_Schema_Interface_Type_array = Core.Name "array"+_Schema_Interface_Type_enum = Core.Name "enum"+_Schema_Interface_Type_map = Core.Name "map"+_Schema_Interface_Type_object = Core.Name "object"+-- | A Map describes a data type of key-value pairs where the values share the same schema. The key in a Map must be a string. The values in a Map can be any schema.+data Schema_Map =+  Schema_Map {+    -- | Map+    schema_MapType :: Iri,+    -- | A description of the keys in the map+    schema_MapMapKey :: MapKey,+    -- | A description of the values in the map+    schema_MapMapValue :: MapValue,+    -- | The ID of the map. If no @id is provided, the digital twin interface processor will assign one.+    schema_MapId :: (Maybe Dtmi),+    -- | A comment for model authors+    schema_MapComment :: (Maybe String),+    -- | A localizable description for display+    schema_MapDescription :: (Maybe String),+    -- | A localizable name for display+    schema_MapDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Schema_Map = Core.Name "hydra.azure.dtld.Schema_Map"+_Schema_Map_type = Core.Name "type"+_Schema_Map_mapKey = Core.Name "mapKey"+_Schema_Map_mapValue = Core.Name "mapValue"+_Schema_Map_id = Core.Name "id"+_Schema_Map_comment = Core.Name "comment"+_Schema_Map_description = Core.Name "description"+_Schema_Map_displayName = Core.Name "displayName"+-- | An Object describes a data type made up of named fields (like a struct in C). The fields in an Object map can be primitive or complex schemas.+data Schema_Object =+  Schema_Object {+    -- | Object+    schema_ObjectType :: Iri,+    -- | A set of field descriptions, one for each field in the Object+    schema_ObjectFields :: (S.Set Field),+    -- | The ID of the object. If no @id is provided, the digital twin interface processor will assign one.+    schema_ObjectId :: (Maybe Dtmi),+    -- | A comment for model authors+    schema_ObjectComment :: (Maybe String),+    -- | A localizable description for display+    schema_ObjectDescription :: (Maybe String),+    -- | A localizable name for display+    schema_ObjectDisplayName :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Schema_Object = Core.Name "hydra.azure.dtld.Schema_Object"+_Schema_Object_type = Core.Name "type"+_Schema_Object_fields = Core.Name "fields"+_Schema_Object_id = Core.Name "id"+_Schema_Object_comment = Core.Name "comment"+_Schema_Object_description = Core.Name "description"+_Schema_Object_displayName = Core.Name "displayName"+-- | A full set of primitive data types are provided and can be specified directly as the value in a schema statement in a digital twin interface.+data Schema_Primitive =+  -- | A boolean value+  Schema_PrimitiveBoolean |+  -- | A full-date as defined in section 5.6 of RFC 3339+  Schema_PrimitiveDate |+  -- | A date-time as defined in RFC 3339+  Schema_PrimitiveDateTime |+  -- | An IEEE 8-byte floating point+  Schema_PrimitiveDouble |+  -- | A duration in ISO 8601 format+  Schema_PrimitiveDuration |+  -- | An IEEE 4-byte floating point+  Schema_PrimitiveFloat |+  -- | A signed 4-byte integer+  Schema_PrimitiveInteger |+  -- | A signed 8-byte integer+  Schema_PrimitiveLong |+  -- | A UTF8 string+  Schema_PrimitiveString |+  -- | A full-time as defined in section 5.6 of RFC 3339+  Schema_PrimitiveTime+  deriving (Eq, Ord, Read, Show)+_Schema_Primitive = Core.Name "hydra.azure.dtld.Schema_Primitive"+_Schema_Primitive_boolean = Core.Name "boolean"+_Schema_Primitive_date = Core.Name "date"+_Schema_Primitive_dateTime = Core.Name "dateTime"+_Schema_Primitive_double = Core.Name "double"+_Schema_Primitive_duration = Core.Name "duration"+_Schema_Primitive_float = Core.Name "float"+_Schema_Primitive_integer = Core.Name "integer"+_Schema_Primitive_long = Core.Name "long"+_Schema_Primitive_string = Core.Name "string"+_Schema_Primitive_time = Core.Name "time"+-- | Telemetry describes the data emitted by any digital twin, whether the data is a regular stream of sensor readings or a computed stream of data, such as occupancy, or an occasional error or information message.+data Telemetry =+  Telemetry {+    -- | This must be at least 'Telemetry'. It can also include a semantic type+    telemetryType :: Iri,+    -- | The 'programming' name of the telemetry. The name may only contain the characters a-z, A-Z, 0-9, and underscore, and must match this regular expression ^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$..+    telemetryName :: String,+    -- | The data type of the Telemetry+    telemetrySchema :: Schema,+    -- | The ID of the telemetry. If no @id is provided, the digital twin interface processor will assign one.+    telemetryId :: (Maybe Dtmi),+    -- | A comment for model authors+    telemetryComment :: (Maybe String),+    -- | A localizable description for display+    telemetryDescription :: (Maybe String),+    -- | A localizable name for display+    telemetryDisplayName :: (Maybe String),+    -- | The unit type of the Telemetry. A semantic type is required for the unit property to be available.+    telemetryUnit :: (Maybe Unit)}+  deriving (Eq, Ord, Read, Show)+_Telemetry = Core.Name "hydra.azure.dtld.Telemetry"+_Telemetry_type = Core.Name "type"+_Telemetry_name = Core.Name "name"+_Telemetry_schema = Core.Name "schema"+_Telemetry_id = Core.Name "id"+_Telemetry_comment = Core.Name "comment"+_Telemetry_description = Core.Name "description"+_Telemetry_displayName = Core.Name "displayName"+_Telemetry_unit = Core.Name "unit"+newtype Unit =+  Unit {+    unUnit :: ()}+  deriving (Eq, Ord, Read, Show)+_Unit = Core.Name "hydra.azure.dtld.Unit"
+ src/main/haskell/Hydra/Cpp/Coder.hs view
@@ -0,0 +1,609 @@+-- Note: this is an automatically generated file. Do not edit.+-- | C++ code generator: converts Hydra modules to C++ header files++module Hydra.Cpp.Coder where+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.File as File+import qualified Hydra.Cpp.Language as Language+import qualified Hydra.Cpp.Serde as Serde+import qualified Hydra.Cpp.Syntax as Syntax+import qualified Hydra.Decode.Core as DecodeCore+import qualified Hydra.Dependencies as Dependencies+import qualified Hydra.Encode.Core as EncodeCore+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Predicates as Predicates+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Resolution as Resolution+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Show.Core as ShowCore+import qualified Hydra.Sorting as Sorting+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+bindingNameToFilePath :: Core.Name -> String+bindingNameToFilePath name =+    Names.nameToFilePath Util.CaseConventionLowerSnake Util.CaseConventionLowerSnake (File.FileExtension "h") name+className :: Core.Name -> String+className name = sanitizeCppName (Names.localNameOf name)+constParameter :: String -> Syntax.TypeExpression -> Syntax.Parameter+constParameter name typ =+    Syntax.Parameter {+      Syntax.parameterType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+        Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+          Syntax.qualifiedTypeBaseType = typ,+          Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierConst})),+        Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierLvalueRef})),+      Syntax.parameterName = name,+      Syntax.parameterUnnamed = False,+      Syntax.parameterDefaultValue = Nothing}+cppClassDeclaration :: String -> [Syntax.BaseSpecifier] -> Maybe Syntax.ClassBody -> Syntax.Declaration+cppClassDeclaration name baseSpecs mbody =+    Syntax.DeclarationClass (Syntax.ClassDeclaration {+      Syntax.classDeclarationSpecifier = Syntax.ClassSpecifier {+        Syntax.classSpecifierKey = Syntax.ClassKeyClass,+        Syntax.classSpecifierName = name,+        Syntax.classSpecifierInheritance = baseSpecs},+      Syntax.classDeclarationBody = mbody})+cppEnumDeclaration :: String -> Maybe Syntax.ClassBody -> Syntax.Declaration+cppEnumDeclaration name mbody =+    Syntax.DeclarationClass (Syntax.ClassDeclaration {+      Syntax.classDeclarationSpecifier = Syntax.ClassSpecifier {+        Syntax.classSpecifierKey = Syntax.ClassKeyEnumClass,+        Syntax.classSpecifierName = name,+        Syntax.classSpecifierInheritance = []},+      Syntax.classDeclarationBody = mbody})+cppEnumForwardDeclaration :: String -> Syntax.Declaration+cppEnumForwardDeclaration name = cppEnumDeclaration name Nothing+cppPostfixExpressionToCppExpression :: Syntax.PostfixExpression -> Syntax.Expression+cppPostfixExpressionToCppExpression pe = cppUnaryExpressionToCppExpression (Syntax.UnaryExpressionPostfix pe)+cppPrimaryExpressionToCppExpression :: Syntax.PrimaryExpression -> Syntax.Expression+cppPrimaryExpressionToCppExpression prim = cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary prim)+cppUnaryExpressionToCppExpression :: Syntax.UnaryExpression -> Syntax.Expression+cppUnaryExpressionToCppExpression ue =+    Syntax.ExpressionAssignment (Syntax.AssignmentExpressionConditional (Syntax.ConditionalExpressionLogicalOr (cppUnaryExpressionToCppLogicalOrExpression ue)))+cppUnaryExpressionToCppLogicalOrExpression :: Syntax.UnaryExpression -> Syntax.LogicalOrExpression+cppUnaryExpressionToCppLogicalOrExpression ue =+    Syntax.LogicalOrExpressionLogicalAnd (Syntax.LogicalAndExpressionInclusiveOr (Syntax.InclusiveOrExpressionExclusiveOr (Syntax.ExclusiveOrExpressionAnd (Syntax.AndExpressionEquality (Syntax.EqualityExpressionRelational (Syntax.RelationalExpressionShift (Syntax.ShiftExpressionAdditive (Syntax.AdditiveExpressionMultiplicative (Syntax.MultiplicativeExpressionUnary ue)))))))))+createAcceptImplementation :: Core.Name -> [Core.FieldType] -> Syntax.Declaration+createAcceptImplementation tname variants =+    Syntax.DeclarationTemplate (Syntax.TemplateDeclaration {+      Syntax.templateDeclarationInline = False,+      Syntax.templateDeclarationParameters = [+        "typename R"],+      Syntax.templateDeclarationDeclaration = (Syntax.DeclarationFunction (Syntax.FunctionDeclaration {+        Syntax.functionDeclarationPrefixSpecifiers = [],+        Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed "R")),+        Syntax.functionDeclarationName = (Strings.cat2 (className tname) "::accept"),+        Syntax.functionDeclarationParameters = [+          Syntax.Parameter {+            Syntax.parameterType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+              Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (Strings.cat2 (visitorName tname) "<R>"))),+              Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierLvalueRef})),+            Syntax.parameterName = "visitor",+            Syntax.parameterUnnamed = False,+            Syntax.parameterDefaultValue = Nothing}],+        Syntax.functionDeclarationSuffixSpecifiers = [+          Syntax.FunctionSpecifierSuffixConst],+        Syntax.functionDeclarationBody = (Syntax.FunctionBodyCompound (Syntax.CompoundStatement (Lists.map (\ft ->+          let fname = Core.fieldTypeName ft+          in (Syntax.StatementSelection (Syntax.SelectionStatement {+            Syntax.selectionStatementCondition = (Syntax.ExpressionAssignment (Syntax.AssignmentExpressionAssignment (Syntax.ExplicitAssignment {+              Syntax.explicitAssignmentLeft = (cppUnaryExpressionToCppLogicalOrExpression (Syntax.UnaryExpressionPostfix (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "auto ptr")))),+              Syntax.explicitAssignmentOp = Syntax.AssignmentOperatorAssign,+              Syntax.explicitAssignmentRight = (Syntax.AssignmentExpressionConditional (Syntax.ConditionalExpressionLogicalOr (cppUnaryExpressionToCppLogicalOrExpression (Syntax.UnaryExpressionPostfix (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+                Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier (Strings.cat2 (Strings.cat2 "dynamic_cast<const " (variantName tname fname)) "*>"))),+                Syntax.functionCallOperationArguments = [+                  cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionIdentifier "this")]}))))))}))),+            Syntax.selectionStatementThenBranch = (Syntax.StatementCompound (Syntax.CompoundStatement [+              Syntax.StatementJump (Syntax.JumpStatementReturnValue (cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+                Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionMemberAccess (Syntax.MemberAccessOperation {+                  Syntax.memberAccessOperationObject = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "visitor")),+                  Syntax.memberAccessOperationMember = "visit"})),+                Syntax.functionCallOperationArguments = [+                  cppUnaryExpressionToCppExpression (Syntax.UnaryExpressionUnaryOp (Syntax.UnaryOperation {+                    Syntax.unaryOperationOperator = Syntax.UnaryOperatorDereference,+                    Syntax.unaryOperationOperand = (Syntax.UnaryExpressionPostfix (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "ptr")))}))]}))))])),+            Syntax.selectionStatementElseBranch = (Just (createThrowStmt "std::runtime_error" createTypeIdNameCall))}))) variants)))}))})+createConstructorBody :: [t0] -> Syntax.FunctionBody+createConstructorBody params =+    Logic.ifElse (Lists.null params) Syntax.FunctionBodyDefault (Syntax.FunctionBodyCompound (Syntax.CompoundStatement []))+createFunctionCallExpr :: String -> [Syntax.Expression] -> Syntax.Expression+createFunctionCallExpr funcName args =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+      Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier funcName)),+      Syntax.functionCallOperationArguments = args}))+createHeaderFile :: [Syntax.IncludeDirective] -> [Syntax.Declaration] -> Syntax.Program+createHeaderFile includes decls =+    Syntax.Program {+      Syntax.programPreprocessorDirectives = [+        Syntax.PreprocessorDirectivePragma (Syntax.PragmaDirective {+          Syntax.pragmaDirectiveContent = "once"})],+      Syntax.programIncludes = includes,+      Syntax.programDeclarations = decls}+createIdentifierExpr :: String -> Syntax.Expression+createIdentifierExpr name = cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionIdentifier name)+createLessThanOperator :: Core.Name -> t0 -> Syntax.Declaration+createLessThanOperator typeName fields =+    Syntax.DeclarationFunction (Syntax.FunctionDeclaration {+      Syntax.functionDeclarationPrefixSpecifiers = [+        Syntax.FunctionSpecifierPrefixInline],+      Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic Syntax.BasicTypeBool),+      Syntax.functionDeclarationName = "operator<",+      Syntax.functionDeclarationParameters = [+        unnamedParameter "lhs" (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (className typeName))),+        (unnamedParameter "rhs" (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (className typeName))))],+      Syntax.functionDeclarationSuffixSpecifiers = [],+      Syntax.functionDeclarationBody = (Syntax.FunctionBodyCompound (Syntax.CompoundStatement [+        Syntax.StatementJump (Syntax.JumpStatementReturnValue (createLiteralBoolExpr False))]))})+createLiteralBoolExpr :: Bool -> Syntax.Expression+createLiteralBoolExpr val =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralBoolean (Syntax.BooleanLiteral val)))+createLiteralIntExpr :: Integer -> Syntax.Expression+createLiteralIntExpr val =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteralDecimal val)))+createPartialVisitorInterface :: Core.Name -> [Core.FieldType] -> Syntax.Declaration+createPartialVisitorInterface tname variants =+    Syntax.DeclarationTemplate (Syntax.TemplateDeclaration {+      Syntax.templateDeclarationInline = False,+      Syntax.templateDeclarationParameters = [+        "typename R"],+      Syntax.templateDeclarationDeclaration = (cppClassDeclaration (partialVisitorName tname) [+        Syntax.BaseSpecifier {+          Syntax.baseSpecifierAccess = Syntax.AccessSpecifierPublic,+          Syntax.baseSpecifierName = (Strings.cat2 (visitorName tname) "<R>")}] (Just (Syntax.ClassBody (Lists.concat [+        [+          memberSpecificationPublic],+        [+          Syntax.MemberSpecificationMember (Syntax.MemberDeclarationFunction (Syntax.FunctionDeclaration {+            Syntax.functionDeclarationPrefixSpecifiers = [+              Syntax.FunctionSpecifierPrefixVirtual],+            Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed "R")),+            Syntax.functionDeclarationName = "otherwise",+            Syntax.functionDeclarationParameters = [+              constParameter "value" (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (className tname)))],+            Syntax.functionDeclarationSuffixSpecifiers = [+              Syntax.FunctionSpecifierSuffixConst],+            Syntax.functionDeclarationBody = Syntax.FunctionBodyPure}))],+        (Lists.map (\ft ->+          let fname = Core.fieldTypeName ft+          in (Syntax.MemberSpecificationMember (Syntax.MemberDeclarationFunction (Syntax.FunctionDeclaration {+            Syntax.functionDeclarationPrefixSpecifiers = [],+            Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed "R")),+            Syntax.functionDeclarationName = "visit",+            Syntax.functionDeclarationParameters = [+              constParameter "value" (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (variantName tname fname)))],+            Syntax.functionDeclarationSuffixSpecifiers = [+              Syntax.FunctionSpecifierSuffixOverride],+            Syntax.functionDeclarationBody = (Syntax.FunctionBodyCompound (Syntax.CompoundStatement [+              Syntax.StatementJump (Syntax.JumpStatementReturnValue (createFunctionCallExpr "otherwise" [+                createIdentifierExpr "value"]))]))})))) variants)]))))})+createTemplateType :: String -> [Syntax.TypeExpression] -> Syntax.TypeExpression+createTemplateType name args =+    Syntax.TypeExpressionTemplate (Syntax.TemplateType {+      Syntax.templateTypeName = name,+      Syntax.templateTypeArguments = (Lists.map (\a -> Syntax.TemplateArgumentType a) args)})+createThrowStmt :: String -> Syntax.Expression -> Syntax.Statement+createThrowStmt exceptionType arg =+    Syntax.StatementJump (Syntax.JumpStatementThrow (createFunctionCallExpr exceptionType [+      arg]))+createTypeIdNameCall :: Syntax.Expression+createTypeIdNameCall =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+      Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionMemberAccess (Syntax.MemberAccessOperation {+        Syntax.memberAccessOperationObject = (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+          Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "typeid")),+          Syntax.functionCallOperationArguments = [+            cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionParenthesized (cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "*this"))))]})),+        Syntax.memberAccessOperationMember = "name"})),+      Syntax.functionCallOperationArguments = []}))+createTypeReference :: Bool -> Core.Name -> Syntax.TypeExpression+createTypeReference isPointer name =+    Logic.ifElse isPointer (createTemplateType "std::shared_ptr" [+      toConstType (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (sanitizeCppName (Names.localNameOf name))))]) (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (sanitizeCppName (Names.localNameOf name))))+createUnionBaseClass :: Core.Name -> t0 -> Syntax.Declaration+createUnionBaseClass name variants =+    cppClassDeclaration (className name) [] (Just (Syntax.ClassBody [+      memberSpecificationProtected,+      (Syntax.MemberSpecificationMember (Syntax.MemberDeclarationConstructor (Syntax.ConstructorDeclaration {+        Syntax.constructorDeclarationName = (className name),+        Syntax.constructorDeclarationParameters = [],+        Syntax.constructorDeclarationInitializers = [],+        Syntax.constructorDeclarationBody = Syntax.FunctionBodyDefault}))),+      memberSpecificationPublic,+      (Syntax.MemberSpecificationMember (Syntax.MemberDeclarationDestructor (Syntax.DestructorDeclaration {+        Syntax.destructorDeclarationPrefixSpecifiers = [+          Syntax.FunctionSpecifierPrefixVirtual],+        Syntax.destructorDeclarationName = (className name),+        Syntax.destructorDeclarationSuffixSpecifiers = [],+        Syntax.destructorDeclarationBody = Syntax.FunctionBodyDefault}))),+      (Syntax.MemberSpecificationMember (Syntax.MemberDeclarationTemplate (Syntax.TemplateDeclaration {+        Syntax.templateDeclarationInline = False,+        Syntax.templateDeclarationParameters = [+          "typename R"],+        Syntax.templateDeclarationDeclaration = (Syntax.DeclarationFunction (Syntax.FunctionDeclaration {+          Syntax.functionDeclarationPrefixSpecifiers = [],+          Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed "R")),+          Syntax.functionDeclarationName = "accept",+          Syntax.functionDeclarationParameters = [+            Syntax.Parameter {+              Syntax.parameterType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+                Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (Strings.cat2 (visitorName name) "<R>"))),+                Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierLvalueRef})),+              Syntax.parameterName = "visitor",+              Syntax.parameterUnnamed = False,+              Syntax.parameterDefaultValue = Nothing}],+          Syntax.functionDeclarationSuffixSpecifiers = [+            Syntax.FunctionSpecifierSuffixConst],+          Syntax.functionDeclarationBody = Syntax.FunctionBodyDeclaration}))})))]))+createVariantClass :: t0 -> t1 -> Core.Name -> Core.Name -> Core.FieldType -> Either Errors.Error Syntax.Declaration+createVariantClass cx g tname parentClass ft =++      let fname = Core.fieldTypeName ft+          variantType = Core.fieldTypeType ft+          hasValue = Logic.not (Predicates.isUnitType variantType)+          valueField =+                  Logic.ifElse hasValue (Eithers.map (\cppType -> [+                    Syntax.MemberSpecificationMember (Syntax.MemberDeclarationVariable (Syntax.VariableDeclaration {+                      Syntax.variableDeclarationType = (Just cppType),+                      Syntax.variableDeclarationName = "value",+                      Syntax.variableDeclarationInitializer = Nothing,+                      Syntax.variableDeclarationIsAuto = False}))]) (encodeType cx g (Strip.deannotateType variantType))) (Right [])+          constructorParams =+                  Logic.ifElse hasValue (Eithers.map (\paramType -> [+                    Syntax.Parameter {+                      Syntax.parameterType = paramType,+                      Syntax.parameterName = "value",+                      Syntax.parameterUnnamed = False,+                      Syntax.parameterDefaultValue = Nothing}]) (encodeType cx g (Strip.deannotateType variantType))) (Right [])+      in (Eithers.bind valueField (\vFields -> Eithers.bind constructorParams (\vParams ->+        let initList =+                Logic.ifElse hasValue [+                  Syntax.MemInitializer {+                    Syntax.memInitializerName = "value",+                    Syntax.memInitializerArguments = [+                      createIdentifierExpr "value"]}] []+        in (Right (cppClassDeclaration (variantName tname fname) [+          Syntax.BaseSpecifier {+            Syntax.baseSpecifierAccess = Syntax.AccessSpecifierPublic,+            Syntax.baseSpecifierName = (className parentClass)}] (Just (Syntax.ClassBody (Lists.concat [+          [+            memberSpecificationPublic],+          vFields,+          [+            Syntax.MemberSpecificationMember (Syntax.MemberDeclarationConstructor (Syntax.ConstructorDeclaration {+              Syntax.constructorDeclarationName = (variantName tname fname),+              Syntax.constructorDeclarationParameters = vParams,+              Syntax.constructorDeclarationInitializers = initList,+              Syntax.constructorDeclarationBody = (createConstructorBody vParams)}))]]))))))))+createVisitorInterface :: Core.Name -> [Core.FieldType] -> Syntax.Declaration+createVisitorInterface tname variants =+    Syntax.DeclarationTemplate (Syntax.TemplateDeclaration {+      Syntax.templateDeclarationInline = False,+      Syntax.templateDeclarationParameters = [+        "typename R"],+      Syntax.templateDeclarationDeclaration = (cppClassDeclaration (visitorName tname) [] (Just (Syntax.ClassBody (Lists.concat [+        [+          memberSpecificationPublic],+        (Lists.map (\ft ->+          let fname = Core.fieldTypeName ft+          in (Syntax.MemberSpecificationMember (Syntax.MemberDeclarationFunction (Syntax.FunctionDeclaration {+            Syntax.functionDeclarationPrefixSpecifiers = [+              Syntax.FunctionSpecifierPrefixVirtual],+            Syntax.functionDeclarationReturnType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed "R")),+            Syntax.functionDeclarationName = "visit",+            Syntax.functionDeclarationParameters = [+              Syntax.Parameter {+                Syntax.parameterType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+                  Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+                    Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (variantName tname fname))),+                    Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierConst})),+                  Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierLvalueRef})),+                Syntax.parameterName = "value",+                Syntax.parameterUnnamed = False,+                Syntax.parameterDefaultValue = Nothing}],+            Syntax.functionDeclarationSuffixSpecifiers = [],+            Syntax.functionDeclarationBody = Syntax.FunctionBodyPure})))) variants),+        [+          Syntax.MemberSpecificationMember (Syntax.MemberDeclarationDestructor (Syntax.DestructorDeclaration {+            Syntax.destructorDeclarationPrefixSpecifiers = [+              Syntax.FunctionSpecifierPrefixVirtual],+            Syntax.destructorDeclarationName = (visitorName tname),+            Syntax.destructorDeclarationSuffixSpecifiers = [],+            Syntax.destructorDeclarationBody = Syntax.FunctionBodyDefault}))]]))))})+encodeApplicationType :: t0 -> t1 -> Core.ApplicationType -> Either Errors.Error Syntax.TypeExpression+encodeApplicationType cx g at =+    Eithers.bind (encodeType cx g (Core.applicationTypeFunction at)) (\body -> Eithers.bind (encodeType cx g (Core.applicationTypeArgument at)) (\arg -> Right (createTemplateType "TODO_template" [+      body,+      arg])))+encodeEnumType :: t0 -> t1 -> Core.Name -> [Core.FieldType] -> t2 -> Either t3 [Syntax.Declaration]+encodeEnumType cx g name tfields comment =+    Right [+      cppEnumDeclaration (className name) (Just (Syntax.ClassBody (Lists.map (\ft -> Syntax.MemberSpecificationMember (Syntax.MemberDeclarationVariable (Syntax.VariableDeclaration {+        Syntax.variableDeclarationType = Nothing,+        Syntax.variableDeclarationName = (encodeEnumValue (Core.fieldTypeName ft)),+        Syntax.variableDeclarationInitializer = Nothing,+        Syntax.variableDeclarationIsAuto = False}))) tfields)))]+encodeEnumValue :: Core.Name -> String+encodeEnumValue fname = sanitizeCppName (Formatting.convertCaseCamelToUpperSnake (Core.unName fname))+encodeFieldName :: Core.Name -> String+encodeFieldName fname = sanitizeCppName (Formatting.convertCaseCamelToLowerSnake (Core.unName fname))+encodeFieldType :: t0 -> Core.FieldType -> t1 -> t2 -> Either Errors.Error Syntax.VariableDeclaration+encodeFieldType isParameter ft cx g =++      let fname = Core.fieldTypeName ft+          ftype = Core.fieldTypeType ft+      in (Eithers.bind (encodeType cx g ftype) (\cppType -> Right (Syntax.VariableDeclaration {+        Syntax.variableDeclarationType = (Just cppType),+        Syntax.variableDeclarationName = (encodeFieldName fname),+        Syntax.variableDeclarationInitializer = Nothing,+        Syntax.variableDeclarationIsAuto = False})))+encodeForallType :: t0 -> t1 -> Core.ForallType -> Either Errors.Error Syntax.TypeExpression+encodeForallType cx g lt = encodeType cx g (Core.forallTypeBody lt)+encodeFunctionType :: t0 -> t1 -> Core.FunctionType -> Either Errors.Error Syntax.TypeExpression+encodeFunctionType cx g ft =+    Eithers.bind (encodeType cx g (Core.functionTypeDomain ft)) (\dom -> Eithers.bind (encodeType cx g (Core.functionTypeCodomain ft)) (\cod -> Right (Syntax.TypeExpressionFunction (Syntax.FunctionType {+      Syntax.functionTypeReturnType = cod,+      Syntax.functionTypeParameters = [+        Syntax.Parameter {+          Syntax.parameterType = dom,+          Syntax.parameterName = "",+          Syntax.parameterUnnamed = False,+          Syntax.parameterDefaultValue = Nothing}]}))))+encodeLiteralType :: Core.LiteralType -> Syntax.TypeExpression+encodeLiteralType lt =+    Syntax.TypeExpressionBasic (case lt of+      Core.LiteralTypeBinary -> Syntax.BasicTypeChar+      Core.LiteralTypeBoolean -> Syntax.BasicTypeBool+      Core.LiteralTypeFloat v0 -> case v0 of+        Core.FloatTypeFloat32 -> Syntax.BasicTypeFloat+        Core.FloatTypeFloat64 -> Syntax.BasicTypeDouble+        _ -> Syntax.BasicTypeDouble+      Core.LiteralTypeInteger v0 -> case v0 of+        Core.IntegerTypeBigint -> Syntax.BasicTypeInt+        Core.IntegerTypeInt8 -> Syntax.BasicTypeChar+        Core.IntegerTypeInt16 -> Syntax.BasicTypeNamed "int16_t"+        Core.IntegerTypeInt32 -> Syntax.BasicTypeInt+        Core.IntegerTypeInt64 -> Syntax.BasicTypeNamed "int64_t"+        _ -> Syntax.BasicTypeInt+      Core.LiteralTypeString -> Syntax.BasicTypeString)+-- | Encode a name with a specified case convention, optionally qualified+encodeName :: t0 -> t1 -> t2 -> Core.Name -> String+encodeName isQualified conv env name = sanitizeCppName (Names.localNameOf name)+encodeNamespace :: Packaging.ModuleName -> String+encodeNamespace ns =+    Strings.intercalate "::" (Lists.map (\seg -> Formatting.convertCaseCamelToLowerSnake seg) (Strings.splitOn "." (Packaging.unModuleName ns)))+encodeRecordType :: t0 -> t1 -> Core.Name -> [Core.FieldType] -> t2 -> Either Errors.Error [Syntax.Declaration]+encodeRecordType cx g name rt comment =+    Eithers.bind (Eithers.mapList (\f -> encodeFieldType False f cx g) rt) (\cppFields -> Eithers.bind (Eithers.mapList (\f -> encodeFieldType True f cx g) rt) (\constructorParams -> Right [+      cppClassDeclaration (className name) [] (Just (Syntax.ClassBody (Lists.concat [+        [+          memberSpecificationPublic],+        (Lists.map (\field -> Syntax.MemberSpecificationMember (Syntax.MemberDeclarationVariable field)) cppFields),+        [+          Syntax.MemberSpecificationMember (Syntax.MemberDeclarationConstructor (Syntax.ConstructorDeclaration {+            Syntax.constructorDeclarationName = (className name),+            Syntax.constructorDeclarationParameters = (Lists.map (\p -> Syntax.Parameter {+              Syntax.parameterType = (Optionals.fromOptional (Syntax.TypeExpressionBasic Syntax.BasicTypeInt) (Syntax.variableDeclarationType p)),+              Syntax.parameterName = (Syntax.variableDeclarationName p),+              Syntax.parameterUnnamed = False,+              Syntax.parameterDefaultValue = Nothing}) constructorParams),+            Syntax.constructorDeclarationInitializers = (Lists.map (\field -> Syntax.MemInitializer {+              Syntax.memInitializerName = (Syntax.variableDeclarationName field),+              Syntax.memInitializerArguments = [+                createIdentifierExpr (Syntax.variableDeclarationName field)]}) cppFields),+            Syntax.constructorDeclarationBody = (createConstructorBody constructorParams)}))]]))),+      (createLessThanOperator name rt)]))+encodeType :: t0 -> t1 -> Core.Type -> Either Errors.Error Syntax.TypeExpression+encodeType cx g typ =++      let t = Strip.deannotateType typ+      in case t of+        Core.TypeApplication v0 -> encodeApplicationType cx g v0+        Core.TypeEither v0 -> Eithers.bind (encodeType cx g (Core.eitherTypeLeft v0)) (\lt -> Eithers.bind (encodeType cx g (Core.eitherTypeRight v0)) (\rt -> Right (toConstType (createTemplateType "std::variant" [+          lt,+          rt]))))+        Core.TypeFunction v0 -> encodeFunctionType cx g v0+        Core.TypeForall v0 -> encodeForallType cx g v0+        Core.TypeList v0 -> Eithers.map (\enc -> toConstType (createTemplateType "std::vector" [+          enc])) (encodeType cx g v0)+        Core.TypeMap v0 -> Eithers.bind (encodeType cx g (Core.mapTypeKeys v0)) (\kt -> Eithers.bind (encodeType cx g (Core.mapTypeValues v0)) (\vt -> Right (toConstType (createTemplateType "std::map" [+          kt,+          vt]))))+        Core.TypeLiteral v0 -> Right (encodeLiteralType v0)+        Core.TypeOptional v0 -> Eithers.map (\enc -> toConstType (createTemplateType "std::optional" [+          enc])) (encodeType cx g v0)+        Core.TypePair v0 -> Eithers.bind (encodeType cx g (Core.pairTypeFirst v0)) (\ft -> Eithers.bind (encodeType cx g (Core.pairTypeSecond v0)) (\st -> Right (toConstType (createTemplateType "std::pair" [+          ft,+          st]))))+        Core.TypeRecord _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous record type"))+        Core.TypeSet v0 -> Eithers.map (\enc -> toConstType (createTemplateType "std::set" [+          enc])) (encodeType cx g v0)+        Core.TypeUnion _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous union type"))+        Core.TypeVariable v0 -> Right (Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (sanitizeCppName (Core.unName v0))))+        Core.TypeWrap _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous wrapped type"))+        Core.TypeUnit -> Right (createTemplateType "std::tuple" [])+        _ -> Left (Errors.ErrorOther (Errors.OtherError "Unsupported type"))+encodeTypeAlias :: t0 -> t1 -> Core.Name -> Core.Type -> t2 -> Either Errors.Error Syntax.Declaration+encodeTypeAlias cx g name typ comment =+    Eithers.bind (encodeType cx g typ) (\cppType -> Right (Syntax.DeclarationTypedef (Syntax.TypedefDeclaration {+      Syntax.typedefDeclarationName = (className name),+      Syntax.typedefDeclarationType = cppType,+      Syntax.typedefDeclarationIsUsing = True})))+encodeTypeDefinition :: t0 -> t1 -> Core.Name -> Core.Type -> Either Errors.Error [Syntax.Declaration]+encodeTypeDefinition cx g name typ =++      let t = Strip.deannotateType typ+      in case t of+        Core.TypeForall v0 -> encodeTypeDefinition cx g name (Core.forallTypeBody v0)+        Core.TypeRecord v0 -> encodeRecordType cx g name v0 Nothing+        Core.TypeUnion v0 -> encodeUnionType cx g name v0 Nothing+        Core.TypeWrap v0 -> encodeWrappedType cx g name v0 Nothing+        _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "unexpected type in definition: " (ShowCore.type_ typ))))+encodeUnionType :: t0 -> t1 -> Core.Name -> [Core.FieldType] -> t2 -> Either Errors.Error [Syntax.Declaration]+encodeUnionType cx g name rt comment =+    Logic.ifElse (Predicates.isEnumRowType rt) (encodeEnumType cx g name rt comment) (encodeVariantType cx g name rt comment)+encodeVariantType :: t0 -> t1 -> Core.Name -> [Core.FieldType] -> t2 -> Either Errors.Error [Syntax.Declaration]+encodeVariantType cx g name variants comment =+    Eithers.bind (Eithers.mapList (\v -> createVariantClass cx g name name v) variants) (\variantClasses -> Right (Lists.concat [+      generateForwardDeclarations name variants,+      [+        createVisitorInterface name variants],+      [+        createUnionBaseClass name variants],+      variantClasses,+      [+        createPartialVisitorInterface name variants],+      [+        createAcceptImplementation name variants]]))+encodeWrappedType :: t0 -> t1 -> Core.Name -> Core.Type -> t2 -> Either Errors.Error [Syntax.Declaration]+encodeWrappedType cx g name typ comment =+    encodeRecordType cx g name [+      Core.FieldType {+        Core.fieldTypeName = (Core.Name "value"),+        Core.fieldTypeType = typ}] comment+findIncludes :: Bool -> Packaging.ModuleName -> [Packaging.TypeDefinition] -> [Syntax.IncludeDirective]+findIncludes withFwd ns defs =+    Lists.concat [+      [+        Syntax.IncludeDirective {+          Syntax.includeDirectiveName = "memory",+          Syntax.includeDirectiveIsSystem = True},+        Syntax.IncludeDirective {+          Syntax.includeDirectiveName = "stdexcept",+          Syntax.includeDirectiveIsSystem = True}],+      (Lists.map (\depName -> Syntax.IncludeDirective {+        Syntax.includeDirectiveName = (bindingNameToFilePath depName),+        Syntax.includeDirectiveIsSystem = False}) (findTypeDependencies ns defs)),+      (Logic.ifElse withFwd [+        Syntax.IncludeDirective {+          Syntax.includeDirectiveName = (bindingNameToFilePath (fwdHeaderName ns)),+          Syntax.includeDirectiveIsSystem = False}] [])]+findTypeDependencies :: Packaging.ModuleName -> [Packaging.TypeDefinition] -> [Core.Name]+findTypeDependencies ns defs =+    Lists.filter (\n -> Logic.not (Equality.equal (Optionals.map Packaging.unModuleName (Names.moduleNameOf n)) (Just (Packaging.unModuleName ns)))) (Sets.toList (Lists.foldl (\acc -> \d -> Sets.union acc (Dependencies.typeDependencyNames True (Core.typeSchemeBody (Packaging.typeDefinitionBody d)))) Sets.empty defs))+fwdHeaderName :: Packaging.ModuleName -> Core.Name+fwdHeaderName ns =+    Names.unqualifyName (Util.QualifiedName {+      Util.qualifiedNameModuleName = (Just ns),+      Util.qualifiedNameLocal = "Fwd"})+gatherMetadata :: t0 -> Bool+gatherMetadata defs = True+generateForwardDeclarations :: Core.Name -> [Core.FieldType] -> [Syntax.Declaration]+generateForwardDeclarations tname fields =+    Lists.map (\ft -> cppClassDeclaration (variantName tname (Core.fieldTypeName ft)) [] Nothing) fields+generateTypeFile :: Packaging.ModuleName -> Packaging.TypeDefinition -> t0 -> t1 -> Either Errors.Error (String, String)+generateTypeFile ns def_ cx g =++      let name = Packaging.typeDefinitionName def_+          typ = Core.typeSchemeBody (Packaging.typeDefinitionBody def_)+      in (Eithers.bind (encodeTypeDefinition cx g name typ) (\decls ->+        let includes = findIncludes True ns [+              def_]+        in (Right (serializeHeaderFile name includes [+          namespaceDecl ns decls]))))+generateTypeFiles :: Packaging.ModuleName -> [Packaging.TypeDefinition] -> t0 -> t1 -> Either Errors.Error [(String, String)]+generateTypeFiles ns defs cx g =+    Eithers.bind (Eithers.mapList (\d -> generateTypeFile ns d cx g) defs) (\classFiles -> Right classFiles)+isStdContainerType :: Core.Type -> Bool+isStdContainerType typ =++      let t = Strip.deannotateType typ+      in case t of+        Core.TypeApplication v0 -> isStdContainerType (Core.applicationTypeFunction v0)+        Core.TypeList _ -> True+        Core.TypeMap _ -> True+        Core.TypeOptional _ -> True+        Core.TypeSet _ -> True+        _ -> False+isStructType :: Core.Type -> Bool+isStructType rawType =++      let t = Resolution.fullyStripType rawType+          isLiteral =+                  case t of+                    Core.TypeLiteral _ -> True+                    _ -> False+      in (Logic.and (Logic.not isLiteral) (Logic.not (Predicates.isEnumType rawType)))+isTemplateType :: Core.Type -> Bool+isTemplateType typ =++      let t = Strip.deannotateType typ+      in (Logic.or (case t of+        Core.TypeLiteral v0 -> case v0 of+          Core.LiteralTypeString -> True+          _ -> False+        _ -> False) (isStdContainerType typ))+memberSpecificationProtected :: Syntax.MemberSpecification+memberSpecificationProtected = Syntax.MemberSpecificationAccessLabel Syntax.AccessSpecifierProtected+memberSpecificationPublic :: Syntax.MemberSpecification+memberSpecificationPublic = Syntax.MemberSpecificationAccessLabel Syntax.AccessSpecifierPublic+moduleToCpp :: Packaging.Module -> [Packaging.Definition] -> t0 -> t1 -> Either Errors.Error (M.Map String String)+moduleToCpp mod defs cx g =++      let ns = Packaging.moduleName mod+          typeDefs = Pairs.first (Environment.partitionDefinitions defs)+      in (Eithers.bind (generateTypeFiles ns typeDefs cx g) (\typeFiles -> Right (Maps.fromList typeFiles)))+namespaceDecl :: Packaging.ModuleName -> [Syntax.Declaration] -> Syntax.Declaration+namespaceDecl ns decls =+    Syntax.DeclarationNamespace (Syntax.NamespaceDeclaration {+      Syntax.namespaceDeclarationName = (encodeNamespace ns),+      Syntax.namespaceDeclarationDeclarations = decls})+partialVisitorName :: Core.Name -> String+partialVisitorName name = sanitizeCppName (Strings.cat2 (Names.localNameOf name) "PartialVisitor")+sanitizeCppName :: String -> String+sanitizeCppName name = Formatting.sanitizeWithUnderscores Language.cppReservedWords name+serializeHeaderFile :: Core.Name -> [Syntax.IncludeDirective] -> [Syntax.Declaration] -> (String, String)+serializeHeaderFile name includes decls =+    (+      bindingNameToFilePath name,+      (Serialization.printExpr (Serialization.parenthesize (Serde.programToExpr (createHeaderFile includes decls)))))+toConstType :: Syntax.TypeExpression -> Syntax.TypeExpression+toConstType baseType =+    Syntax.TypeExpressionQualified (Syntax.QualifiedType {+      Syntax.qualifiedTypeBaseType = baseType,+      Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierConst})+unnamedParameter :: String -> Syntax.TypeExpression -> Syntax.Parameter+unnamedParameter name typ =+    Syntax.Parameter {+      Syntax.parameterType = typ,+      Syntax.parameterName = name,+      Syntax.parameterUnnamed = True,+      Syntax.parameterDefaultValue = Nothing}+variantName :: Core.Name -> Core.Name -> String+variantName tname fname = sanitizeCppName (Strings.cat2 (Names.localNameOf tname) (Formatting.capitalize (Core.unName fname)))+visitorName :: Core.Name -> String+visitorName name = sanitizeCppName (Strings.cat2 (Names.localNameOf name) "Visitor")
+ src/main/haskell/Hydra/Cpp/Environment.hs view
@@ -0,0 +1,21 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Type definitions for C++ code generation environment++module Hydra.Cpp.Environment where+import qualified Hydra.Core as Core+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Util as Util+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Environment for C++ code generation+data CppEnvironment =+  CppEnvironment {+    -- | ModuleName mapping for code generation+    cppEnvironmentNamespaces :: (Util.ModuleNames String),+    -- | Type variables in scope, with their C++ names+    cppEnvironmentBoundTypeVariables :: ([Core.Name], (M.Map Core.Name String))}+  deriving (Eq, Ord, Read, Show)+_CppEnvironment = Core.Name "hydra.cpp.environment.CppEnvironment"+_CppEnvironment_namespaces = Core.Name "namespaces"+_CppEnvironment_boundTypeVariables = Core.Name "boundTypeVariables"
+ src/main/haskell/Hydra/Cpp/Language.hs view
@@ -0,0 +1,247 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints and reserved words for C++++module Hydra.Cpp.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | Language constraints for C+++cppLanguage :: Coders.Language+cppLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.cpp"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt8,+          Core.IntegerTypeInt16,+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64,+          Core.IntegerTypeBigint]+    termVariants =+        Sets.fromList [+          Variants.TermVariantApplication,+          Variants.TermVariantEither,+          Variants.TermVariantCases,+          Variants.TermVariantLambda,+          Variants.TermVariantProject,+          Variants.TermVariantUnwrap,+          Variants.TermVariantTypeApplication,+          Variants.TermVariantTypeLambda,+          Variants.TermVariantLet,+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantPair,+          Variants.TermVariantRecord,+          Variants.TermVariantSet,+          Variants.TermVariantInject,+          Variants.TermVariantVariable,+          Variants.TermVariantWrap]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantApplication,+          Variants.TypeVariantEither,+          Variants.TypeVariantFunction,+          Variants.TypeVariantForall,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantPair,+          Variants.TypeVariantRecord,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnion,+          Variants.TypeVariantVariable,+          Variants.TypeVariantWrap]+    typePredicate = \_ -> True+-- | A set of reserved words in C+++cppReservedWords :: S.Set String+cppReservedWords =+    Sets.fromList (Lists.concat [+      cppKeywords,+      cppPreprocessor,+      cppStlTypes,+      hydraCppKeywords])+  where+    cppKeywords =+        [+          "alignas",+          "alignof",+          "and",+          "and_eq",+          "asm",+          "auto",+          "bitand",+          "bitor",+          "bool",+          "break",+          "case",+          "catch",+          "char",+          "char8_t",+          "char16_t",+          "char32_t",+          "class",+          "compl",+          "concept",+          "const",+          "consteval",+          "constexpr",+          "constinit",+          "const_cast",+          "continue",+          "co_await",+          "co_return",+          "co_yield",+          "decltype",+          "default",+          "delete",+          "do",+          "double",+          "dynamic_cast",+          "else",+          "enum",+          "explicit",+          "export",+          "extern",+          "false",+          "float",+          "for",+          "friend",+          "goto",+          "if",+          "inline",+          "int",+          "long",+          "mutable",+          "namespace",+          "new",+          "noexcept",+          "not",+          "not_eq",+          "nullptr",+          "operator",+          "or",+          "or_eq",+          "private",+          "protected",+          "public",+          "register",+          "reinterpret_cast",+          "requires",+          "return",+          "short",+          "signed",+          "sizeof",+          "static",+          "static_assert",+          "static_cast",+          "struct",+          "switch",+          "template",+          "this",+          "thread_local",+          "throw",+          "true",+          "try",+          "typedef",+          "typeid",+          "typename",+          "union",+          "unsigned",+          "using",+          "virtual",+          "void",+          "volatile",+          "wchar_t",+          "while",+          "xor",+          "xor_eq"]+    cppPreprocessor =+        [+          "#define",+          "#elif",+          "#else",+          "#endif",+          "#error",+          "#if",+          "#ifdef",+          "#ifndef",+          "#include",+          "#line",+          "#pragma",+          "#undef"]+    cppStlTypes =+        [+          "std",+          "string",+          "vector",+          "map",+          "set",+          "optional",+          "variant",+          "pair",+          "tuple",+          "function",+          "array",+          "deque",+          "forward_list",+          "list",+          "multimap",+          "multiset",+          "unordered_map",+          "unordered_set",+          "unordered_multimap",+          "unordered_multiset",+          "stack",+          "queue",+          "priority_queue",+          "shared_ptr",+          "unique_ptr",+          "weak_ptr"]+    hydraCppKeywords = []
+ src/main/haskell/Hydra/Cpp/Names.hs view
@@ -0,0 +1,120 @@+-- Note: this is an automatically generated file. Do not edit.+-- | C++ naming utilities: encoding Hydra names as C++ names++module Hydra.Cpp.Names where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Cpp.Environment as Environment+import qualified Hydra.Cpp.Language as Language+import qualified Hydra.Cpp.Syntax as Syntax+import qualified Hydra.Cpp.Utils as Utils+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Get the C++ class name from a Hydra Name+className :: Core.Name -> String+className name = sanitizeCppName (Names.localNameOf name)+-- | Create a type reference, optionally wrapped in shared_ptr+createTypeReference :: Bool -> Environment.CppEnvironment -> Core.Name -> Syntax.TypeExpression+createTypeReference isPointer env name =++      let baseType = Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (encodeName True Util.CaseConventionPascal env name))+      in (Logic.ifElse isPointer (Utils.toConstType baseType) baseType)+-- | Encode an enum value with appropriate naming convention+encodeEnumValue :: Environment.CppEnvironment -> Core.Name -> String+encodeEnumValue = encodeName False Util.CaseConventionUpperSnake+-- | Encode a field name with appropriate naming convention+encodeFieldName :: Environment.CppEnvironment -> Core.Name -> String+encodeFieldName env fname = encodeName False Util.CaseConventionLowerSnake env fname+-- | Encode a name with specified convention+encodeName :: Bool -> Util.CaseConvention -> Environment.CppEnvironment -> Core.Name -> String+encodeName isQualified conv env name =++      let focusNs = Pairs.first (Util.moduleNamesFocus (Environment.cppEnvironmentNamespaces env))+          boundVars = Pairs.second (Environment.cppEnvironmentBoundTypeVariables env)+          qualName = Names.qualifyName name+          mns = Util.qualifiedNameModuleName qualName+          local = Util.qualifiedNameLocal qualName+          cppLocal = sanitizeCppName (Formatting.convertCase Util.CaseConventionCamel conv local)+          cppNs =+                  \nsVal -> Strings.intercalate "::" (Lists.map (Formatting.convertCase Util.CaseConventionCamel Util.CaseConventionLowerSnake) (Strings.splitOn "." (Packaging.unModuleName nsVal)))+      in (Logic.ifElse isQualified (Optionals.cases (Maps.lookup name boundVars) (Optionals.cases mns cppLocal (\nsVal -> Strings.cat2 (cppNs nsVal) (Strings.cat2 "::" cppLocal))) (\n -> n)) cppLocal)+-- | Encode a qualified name with namespace+encodeNameQualified :: Environment.CppEnvironment -> Core.Name -> String+encodeNameQualified env name =++      let boundVars = Pairs.second (Environment.cppEnvironmentBoundTypeVariables env)+          focusNs = Pairs.first (Util.moduleNamesFocus (Environment.cppEnvironmentNamespaces env))+          qualName = Names.qualifyName name+          mns = Util.qualifiedNameModuleName qualName+          local = Util.qualifiedNameLocal qualName+      in (Optionals.cases (Maps.lookup name boundVars) (Logic.ifElse (Equality.equal mns (Just focusNs)) (sanitizeCppName local) (Strings.intercalate "::" (Lists.map sanitizeCppName (Strings.splitOn "." (Core.unName name))))) (\n -> n))+-- | Encode a namespace as a C++ namespace string+encodeNamespace :: Packaging.ModuleName -> String+encodeNamespace nsVal =+    Strings.intercalate "::" (Lists.map (Formatting.convertCase Util.CaseConventionCamel Util.CaseConventionLowerSnake) (Strings.splitOn "." (Packaging.unModuleName nsVal)))+-- | Encode a type variable name+encodeTypeVariable :: Core.Name -> String+encodeTypeVariable name = Formatting.capitalize (Core.unName name)+-- | Get the forward header name for a namespace+fwdHeaderName :: Packaging.ModuleName -> Core.Name+fwdHeaderName nsVal =+    Names.unqualifyName (Util.QualifiedName {+      Util.qualifiedNameModuleName = (Just nsVal),+      Util.qualifiedNameLocal = "Fwd"})+-- | Create a namespace declaration wrapping inner declarations+namespaceDecl :: Packaging.ModuleName -> [Syntax.Declaration] -> Syntax.Declaration+namespaceDecl nsVal decls =+    Syntax.DeclarationNamespace (Syntax.NamespaceDeclaration {+      Syntax.namespaceDeclarationName = (encodeNamespace nsVal),+      Syntax.namespaceDeclarationDeclarations = decls})+-- | Get the partial visitor name for a type+partialVisitorName :: Core.Name -> String+partialVisitorName name = sanitizeCppName (Strings.cat2 (Names.localNameOf name) "PartialVisitor")+-- | Sanitize a name to be valid in C+++sanitizeCppName :: String -> String+sanitizeCppName = Formatting.sanitizeWithUnderscores Language.cppReservedWords+-- | Create a reference to a term variable+termVariableReference :: Environment.CppEnvironment -> Core.Name -> Syntax.Expression+termVariableReference = variableReference Util.CaseConventionLowerSnake+-- | Create a reference to a type variable+typeVariableReference :: Environment.CppEnvironment -> Core.Name -> Syntax.TypeExpression+typeVariableReference env name =+    Syntax.TypeExpressionBasic (Syntax.BasicTypeNamed (encodeName True Util.CaseConventionPascal env name))+-- | Create a variable reference expression+variableReference :: Util.CaseConvention -> Environment.CppEnvironment -> Core.Name -> Syntax.Expression+variableReference conv env name = Utils.createIdentifierExpr (encodeName True conv env name)+-- | Get the variant name by combining type name and field name+variantName :: Core.Name -> Core.Name -> String+variantName tname fname = sanitizeCppName (Strings.cat2 (Names.localNameOf tname) (Formatting.capitalize (Core.unName fname)))+-- | Get the visitor name for a type+visitorName :: Core.Name -> String+visitorName name = sanitizeCppName (Strings.cat2 (Names.localNameOf name) "Visitor")
+ src/main/haskell/Hydra/Cpp/Serde.hs view
@@ -0,0 +1,1223 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Serialization functions for converting C++ AST to abstract expressions++module Hydra.Cpp.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Cpp.Syntax as Syntax+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Convert an access specifier to an expression+accessSpecifierToExpr :: Syntax.AccessSpecifier -> Ast.Expr+accessSpecifierToExpr a =+    case a of+      Syntax.AccessSpecifierPublic -> Serialization.cst "public"+      Syntax.AccessSpecifierProtected -> Serialization.cst "protected"+      Syntax.AccessSpecifierPrivate -> Serialization.cst "private"+      Syntax.AccessSpecifierNone -> Serialization.cst ""+-- | Convert an add operation to an expression+addOperationToExpr :: Syntax.AddOperation -> Ast.Expr+addOperationToExpr op =++      let left = Syntax.addOperationLeft op+          right = Syntax.addOperationRight op+      in (Serialization.spaceSep [+        additiveExpressionToExpr left,+        (Serialization.cst "+"),+        (multiplicativeExpressionToExpr right)])+-- | Convert an additive expression to an expression+additiveExpressionToExpr :: Syntax.AdditiveExpression -> Ast.Expr+additiveExpressionToExpr e =+    case e of+      Syntax.AdditiveExpressionMultiplicative v0 -> multiplicativeExpressionToExpr v0+      Syntax.AdditiveExpressionAdd v0 -> addOperationToExpr v0+      Syntax.AdditiveExpressionSubtract v0 -> subtractOperationToExpr v0+-- | Convert an and expression to an expression+andExpressionToExpr :: Syntax.AndExpression -> Ast.Expr+andExpressionToExpr e =+    case e of+      Syntax.AndExpressionEquality v0 -> equalityExpressionToExpr v0+      Syntax.AndExpressionBitwiseAnd v0 -> bitwiseAndOperationToExpr v0+-- | Convert an assignment expression to an expression+assignmentExpressionToExpr :: Syntax.AssignmentExpression -> Ast.Expr+assignmentExpressionToExpr a =+    case a of+      Syntax.AssignmentExpressionConditional v0 -> conditionalExpressionToExpr v0+      Syntax.AssignmentExpressionAssignment v0 -> explicitAssignmentToExpr v0+-- | Convert an assignment operator to an expression+assignmentOperatorToExpr :: Syntax.AssignmentOperator -> Ast.Expr+assignmentOperatorToExpr op =+    case op of+      Syntax.AssignmentOperatorAssign -> Serialization.cst "="+      Syntax.AssignmentOperatorPlusAssign -> Serialization.cst "+="+      Syntax.AssignmentOperatorMinusAssign -> Serialization.cst "-="+      Syntax.AssignmentOperatorMultiplyAssign -> Serialization.cst "*="+      Syntax.AssignmentOperatorDivideAssign -> Serialization.cst "/="+      Syntax.AssignmentOperatorModuloAssign -> Serialization.cst "%="+      Syntax.AssignmentOperatorLeftShiftAssign -> Serialization.cst "<<="+      Syntax.AssignmentOperatorRightShiftAssign -> Serialization.cst ">>="+      Syntax.AssignmentOperatorBitwiseAndAssign -> Serialization.cst "&="+      Syntax.AssignmentOperatorBitwiseXorAssign -> Serialization.cst "^="+      Syntax.AssignmentOperatorBitwiseOrAssign -> Serialization.cst "|="+-- | Convert a base specifier to an expression+baseSpecifierToExpr :: Syntax.BaseSpecifier -> Ast.Expr+baseSpecifierToExpr bs =++      let access = Syntax.baseSpecifierAccess bs+          name = Syntax.baseSpecifierName bs+      in (Serialization.spaceSep [+        accessSpecifierToExpr access,+        (Serialization.cst name)])+-- | Convert a basic type to an expression+basicTypeToExpr :: Syntax.BasicType -> Ast.Expr+basicTypeToExpr t =+    case t of+      Syntax.BasicTypeVoid -> Serialization.cst "void"+      Syntax.BasicTypeBool -> Serialization.cst "bool"+      Syntax.BasicTypeChar -> Serialization.cst "char"+      Syntax.BasicTypeInt -> Serialization.cst "int"+      Syntax.BasicTypeFloat -> Serialization.cst "float"+      Syntax.BasicTypeDouble -> Serialization.cst "double"+      Syntax.BasicTypeString -> Serialization.cst "std::string"+      Syntax.BasicTypeAuto -> Serialization.cst "auto"+      Syntax.BasicTypeNamed v0 -> Serialization.cst v0+-- | Convert a bitwise and operation to an expression+bitwiseAndOperationToExpr :: Syntax.BitwiseAndOperation -> Ast.Expr+bitwiseAndOperationToExpr op =++      let left = Syntax.bitwiseAndOperationLeft op+          right = Syntax.bitwiseAndOperationRight op+      in (Serialization.spaceSep [+        andExpressionToExpr left,+        (Serialization.cst "&"),+        (equalityExpressionToExpr right)])+-- | Convert a bitwise or operation to an expression+bitwiseOrOperationToExpr :: Syntax.BitwiseOrOperation -> Ast.Expr+bitwiseOrOperationToExpr op =++      let left = Syntax.bitwiseOrOperationLeft op+          right = Syntax.bitwiseOrOperationRight op+      in (Serialization.spaceSep [+        inclusiveOrExpressionToExpr left,+        (Serialization.cst "|"),+        (exclusiveOrExpressionToExpr right)])+-- | Convert a bitwise xor operation to an expression+bitwiseXorOperationToExpr :: Syntax.BitwiseXorOperation -> Ast.Expr+bitwiseXorOperationToExpr op =++      let left = Syntax.bitwiseXorOperationLeft op+          right = Syntax.bitwiseXorOperationRight op+      in (Serialization.spaceSep [+        exclusiveOrExpressionToExpr left,+        (Serialization.cst "^"),+        (andExpressionToExpr right)])+-- | Convert a boolean literal to an expression+booleanLiteralToExpr :: Syntax.BooleanLiteral -> Ast.Expr+booleanLiteralToExpr bl = Logic.ifElse (Syntax.unBooleanLiteral bl) (Serialization.cst "true") (Serialization.cst "false")+-- | Convert a capture list to an expression+captureListToExpr :: Syntax.CaptureList -> Ast.Expr+captureListToExpr cl =+    case cl of+      Syntax.CaptureListCaptureByValue -> Serialization.cst "[=]"+      Syntax.CaptureListCaptures v0 -> Serialization.bracketList Serialization.inlineStyle (Lists.map captureToExpr v0)+-- | Convert a capture to an expression+captureToExpr :: Syntax.Capture -> Ast.Expr+captureToExpr cap =++      let name = Syntax.captureName cap+          byRef = Syntax.captureByReference cap+      in (Logic.ifElse byRef (Serialization.cst (Strings.cat2 "&" name)) (Serialization.cst name))+-- | Convert a case statement to an expression+caseStatementToExpr :: Syntax.CaseStatement -> Ast.Expr+caseStatementToExpr stmt =+    case stmt of+      Syntax.CaseStatementCase v0 -> caseValueToExpr v0+      Syntax.CaseStatementDefault v0 -> Serialization.spaceSep [+        Serialization.cst "default:",+        (statementToExpr v0)]+-- | Convert a case value to an expression+caseValueToExpr :: Syntax.CaseValue -> Ast.Expr+caseValueToExpr cv =++      let value = Syntax.caseValueValue cv+          statement = Syntax.caseValueStatement cv+      in (Serialization.spaceSep [+        Serialization.cst "case",+        (Serialization.noSep [+          expressionToExpr value,+          (Serialization.cst ":")]),+        (statementToExpr statement)])+-- | Convert a class body to an expression+classBodyToExpr :: Bool -> Syntax.ClassBody -> Ast.Expr+classBodyToExpr commas cb =+    Serialization.curlyBlock Serialization.fullBlockStyle (Serialization.doubleNewlineSep (Lists.map (memberSpecificationToExpr commas) (Syntax.unClassBody cb)))+-- | Convert a class declaration to an expression+classDeclarationToExpr :: Syntax.ClassDeclaration -> Ast.Expr+classDeclarationToExpr cd =++      let spec = Syntax.classDeclarationSpecifier cd+          mbody = Syntax.classDeclarationBody cd+          key = Syntax.classSpecifierKey spec+          isEnum = Logic.or (Equality.equal key Syntax.ClassKeyEnum) (Equality.equal key Syntax.ClassKeyEnumClass)+      in (Serialization.withSemi (Serialization.spaceSep (Optionals.cat [+        Just (classSpecifierToExpr spec),+        (Optionals.map (\body -> classBodyToExpr isEnum body) mbody)])))+-- | Convert a class key to an expression+classKeyToExpr :: Syntax.ClassKey -> Ast.Expr+classKeyToExpr k =+    case k of+      Syntax.ClassKeyClass -> Serialization.cst "class"+      Syntax.ClassKeyEnum -> Serialization.cst "enum"+      Syntax.ClassKeyEnumClass -> Serialization.cst "enum class"+      Syntax.ClassKeyStruct -> Serialization.cst "struct"+-- | Convert a class specifier to an expression+classSpecifierToExpr :: Syntax.ClassSpecifier -> Ast.Expr+classSpecifierToExpr cs =++      let key = Syntax.classSpecifierKey cs+          name = Syntax.classSpecifierName cs+          inheritance = Syntax.classSpecifierInheritance cs+      in (Serialization.spaceSep (Lists.concat [+        [+          classKeyToExpr key,+          (Serialization.cst name)],+        (Logic.ifElse (Lists.null inheritance) [] [+          Serialization.cst ":",+          (Serialization.commaSep Serialization.inlineStyle (Lists.map baseSpecifierToExpr inheritance))])]))+-- | Convert a comma expression to an expression+commaExpressionToExpr :: Syntax.CommaExpression -> Ast.Expr+commaExpressionToExpr ce =++      let left = Syntax.commaExpressionLeft ce+          right = Syntax.commaExpressionRight ce+      in (Serialization.spaceSep [+        expressionToExpr left,+        (Serialization.cst ","),+        (assignmentExpressionToExpr right)])+-- | Convert a comment to an expression+commentToExpr :: Syntax.Comment -> Ast.Expr+commentToExpr c =++      let text = Syntax.commentText c+          isMultiline = Syntax.commentIsMultiline c+      in (Serialization.cst (toCppComments text isMultiline))+-- | Convert a compound statement to an expression+compoundStatementToExpr :: Syntax.CompoundStatement -> Ast.Expr+compoundStatementToExpr cs =+    Serialization.curlyBracesList (Just "") Serialization.fullBlockStyle (Lists.map statementToExpr (Syntax.unCompoundStatement cs))+-- | Convert a conditional expression to an expression+conditionalExpressionToExpr :: Syntax.ConditionalExpression -> Ast.Expr+conditionalExpressionToExpr c =+    case c of+      Syntax.ConditionalExpressionLogicalOr v0 -> logicalOrExpressionToExpr v0+      Syntax.ConditionalExpressionTernary v0 -> ternaryExpressionToExpr v0+-- | Convert a constructor declaration to an expression+constructorDeclarationToExpr :: Syntax.ConstructorDeclaration -> Ast.Expr+constructorDeclarationToExpr cd =++      let name = Syntax.constructorDeclarationName cd+          params = Syntax.constructorDeclarationParameters cd+          inits = Syntax.constructorDeclarationInitializers cd+          body = Syntax.constructorDeclarationBody cd+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.noSep [+          Serialization.cst name,+          (Serialization.parenListAdaptive (Lists.map parameterToExpr params))]),+        (Logic.ifElse (Lists.null inits) Nothing (Just (Serialization.spaceSep [+          Serialization.cst ":",+          (Serialization.commaSep Serialization.inlineStyle (Lists.map memInitializerToExpr inits))]))),+        (Just (functionBodyToExpr body))]))+-- | Convert a declaration to an expression+declarationToExpr :: Syntax.Declaration -> Ast.Expr+declarationToExpr d =+    case d of+      Syntax.DeclarationPreprocessor v0 -> preprocessorDirectiveToExpr v0+      Syntax.DeclarationClass v0 -> classDeclarationToExpr v0+      Syntax.DeclarationFunction v0 -> functionDeclarationToExpr v0+      Syntax.DeclarationVariable v0 -> variableDeclarationToExpr False v0+      Syntax.DeclarationTypedef v0 -> typedefDeclarationToExpr v0+      Syntax.DeclarationNamespace v0 -> namespaceDeclarationToExpr v0+      Syntax.DeclarationTemplate v0 -> templateDeclarationToExpr v0+-- | Convert a define directive to an expression+defineDirectiveToExpr :: Syntax.DefineDirective -> Ast.Expr+defineDirectiveToExpr dd =++      let name = Syntax.defineDirectiveName dd+          params = Syntax.defineDirectiveParameters dd+          replacement = Syntax.defineDirectiveReplacement dd+      in (Serialization.spaceSep (Lists.concat [+        [+          Serialization.cst "#define",+          (Serialization.cst name)],+        (Optionals.cases params [] (\ps -> [+          Serialization.parenListAdaptive (Lists.map (\p -> Serialization.cst p) ps)])),+        (Optionals.cases replacement [] (\r -> [+          Serialization.cst r]))]))+-- | Convert a destructor declaration to an expression+destructorDeclarationToExpr :: Syntax.DestructorDeclaration -> Ast.Expr+destructorDeclarationToExpr dd =++      let prefixSpecs = Syntax.destructorDeclarationPrefixSpecifiers dd+          name = Syntax.destructorDeclarationName dd+          suffixSpecs = Syntax.destructorDeclarationSuffixSpecifiers dd+          body = Syntax.destructorDeclarationBody dd+      in (Serialization.spaceSep (Lists.concat [+        Lists.map functionSpecifierPrefixToExpr prefixSpecs,+        [+          Serialization.noSep [+            Serialization.cst (Strings.cat2 "~" name),+            (Serialization.parens (Serialization.cst ""))]],+        (Lists.map functionSpecifierSuffixToExpr suffixSpecs),+        [+          functionBodyToExpr body]]))+-- | Convert a divide operation to an expression+divideOperationToExpr :: Syntax.DivideOperation -> Ast.Expr+divideOperationToExpr op =++      let left = Syntax.divideOperationLeft op+          right = Syntax.divideOperationRight op+      in (Serialization.spaceSep [+        multiplicativeExpressionToExpr left,+        (Serialization.cst "/"),+        (unaryExpressionToExpr right)])+-- | Convert a do statement to an expression+doStatementToExpr :: Syntax.DoStatement -> Ast.Expr+doStatementToExpr ds =++      let body = Syntax.doStatementBody ds+          cond = Syntax.doStatementCondition ds+      in (Serialization.newlineSep [+        Serialization.cst "do",+        (statementToExpr body),+        (Serialization.withSemi (Serialization.spaceSep [+          Serialization.cst "while",+          (Serialization.parens (expressionToExpr cond))]))])+-- | Convert an elif directive to an expression+elifDirectiveToExpr :: Syntax.ElifDirective -> Ast.Expr+elifDirectiveToExpr ed =+    Serialization.spaceSep [+      Serialization.cst "#elif",+      (Serialization.cst (Syntax.elifDirectiveCondition ed))]+-- | Convert an else directive to an expression+elseDirectiveToExpr :: t0 -> Ast.Expr+elseDirectiveToExpr ed = Serialization.cst "#else"+-- | Convert an endif directive to an expression+endifDirectiveToExpr :: t0 -> Ast.Expr+endifDirectiveToExpr ed = Serialization.cst "#endif"+-- | Convert an equal operation to an expression+equalOperationToExpr :: Syntax.EqualOperation -> Ast.Expr+equalOperationToExpr op =++      let left = Syntax.equalOperationLeft op+          right = Syntax.equalOperationRight op+      in (Serialization.spaceSep [+        equalityExpressionToExpr left,+        (Serialization.cst "=="),+        (relationalExpressionToExpr right)])+-- | Convert an equality expression to an expression+equalityExpressionToExpr :: Syntax.EqualityExpression -> Ast.Expr+equalityExpressionToExpr e =+    case e of+      Syntax.EqualityExpressionRelational v0 -> relationalExpressionToExpr v0+      Syntax.EqualityExpressionEqual v0 -> equalOperationToExpr v0+      Syntax.EqualityExpressionNotEqual v0 -> notEqualOperationToExpr v0+-- | Convert an error directive to an expression+errorDirectiveToExpr :: Syntax.ErrorDirective -> Ast.Expr+errorDirectiveToExpr ed =+    Serialization.spaceSep [+      Serialization.cst "#error",+      (Serialization.cst (Syntax.errorDirectiveMessage ed))]+-- | Convert an exclusive or expression to an expression+exclusiveOrExpressionToExpr :: Syntax.ExclusiveOrExpression -> Ast.Expr+exclusiveOrExpressionToExpr e =+    case e of+      Syntax.ExclusiveOrExpressionAnd v0 -> andExpressionToExpr v0+      Syntax.ExclusiveOrExpressionBitwiseXor v0 -> bitwiseXorOperationToExpr v0+-- | Convert an explicit assignment to an expression+explicitAssignmentToExpr :: Syntax.ExplicitAssignment -> Ast.Expr+explicitAssignmentToExpr ea =++      let left = Syntax.explicitAssignmentLeft ea+          op = Syntax.explicitAssignmentOp ea+          right = Syntax.explicitAssignmentRight ea+      in (Serialization.spaceSep [+        logicalOrExpressionToExpr left,+        (assignmentOperatorToExpr op),+        (assignmentExpressionToExpr right)])+-- | Convert an expression to an expression+expressionToExpr :: Syntax.Expression -> Ast.Expr+expressionToExpr e =+    case e of+      Syntax.ExpressionAssignment v0 -> assignmentExpressionToExpr v0+      Syntax.ExpressionComma v0 -> commaExpressionToExpr v0+-- | Convert a for-init to an expression+forInitToExpr :: Syntax.ForInit -> Ast.Expr+forInitToExpr i =+    case i of+      Syntax.ForInitExpression v0 -> expressionToExpr v0+      Syntax.ForInitDeclaration v0 -> variableDeclarationToExpr False v0+      Syntax.ForInitEmpty -> Serialization.cst ""+-- | Convert a for statement to an expression+forStatementToExpr :: Syntax.ForStatement -> Ast.Expr+forStatementToExpr fs =++      let init = Syntax.forStatementInit fs+          cond = Syntax.forStatementCondition fs+          inc = Syntax.forStatementIncrement fs+          body = Syntax.forStatementBody fs+      in (Serialization.newlineSep [+        Serialization.spaceSep [+          Serialization.cst "for",+          (Serialization.parens (Serialization.noSep [+            forInitToExpr init,+            (Serialization.cst ";"),+            (expressionToExpr cond),+            (Serialization.cst ";"),+            (expressionToExpr inc)]))],+        (statementToExpr body)])+-- | Convert a function application to an expression+functionApplicationToExpr :: Syntax.FunctionApplication -> Ast.Expr+functionApplicationToExpr fa =++      let func = Syntax.functionApplicationFunction fa+          args = Syntax.functionApplicationArguments fa+      in (Serialization.spaceSep [+        functionIdentifierToExpr func,+        (Serialization.parenListAdaptive (Lists.map expressionToExpr args))])+-- | Convert a function body to an expression+functionBodyToExpr :: Syntax.FunctionBody -> Ast.Expr+functionBodyToExpr b =+    case b of+      Syntax.FunctionBodyCompound v0 -> compoundStatementToExpr v0+      Syntax.FunctionBodyDeclaration -> Serialization.cst ";"+      Syntax.FunctionBodyPure -> Serialization.withSemi (Serialization.cst "= 0")+      Syntax.FunctionBodyDefault -> Serialization.withSemi (Serialization.cst "= default")+-- | Convert a function call operation to an expression+functionCallOperationToExpr :: Syntax.FunctionCallOperation -> Ast.Expr+functionCallOperationToExpr fco =++      let func = Syntax.functionCallOperationFunction fco+          args = Syntax.functionCallOperationArguments fco+      in (Serialization.noSep [+        postfixExpressionToExpr func,+        (Serialization.parenListAdaptive (Lists.map expressionToExpr args))])+-- | Convert a function declaration to an expression+functionDeclarationToExpr :: Syntax.FunctionDeclaration -> Ast.Expr+functionDeclarationToExpr fd =++      let prefixSpecs = Syntax.functionDeclarationPrefixSpecifiers fd+          retType = Syntax.functionDeclarationReturnType fd+          name = Syntax.functionDeclarationName fd+          params = Syntax.functionDeclarationParameters fd+          suffixSpecs = Syntax.functionDeclarationSuffixSpecifiers fd+          body = Syntax.functionDeclarationBody fd+      in (Serialization.spaceSep (Lists.concat [+        Lists.map functionSpecifierPrefixToExpr prefixSpecs,+        [+          typeExpressionToExpr retType,+          (Serialization.noSep [+            Serialization.cst name,+            (Serialization.parenListAdaptive (Lists.map parameterToExpr params))])],+        (Lists.map functionSpecifierSuffixToExpr suffixSpecs),+        [+          functionBodyToExpr body]]))+-- | Convert a function identifier to an expression+functionIdentifierToExpr :: Syntax.FunctionIdentifier -> Ast.Expr+functionIdentifierToExpr f =+    case f of+      Syntax.FunctionIdentifierSimple v0 -> Serialization.cst v0+      Syntax.FunctionIdentifierQualified v0 -> qualifiedIdentifierToExpr v0+-- | Convert a function specifier prefix to an expression+functionSpecifierPrefixToExpr :: Syntax.FunctionSpecifierPrefix -> Ast.Expr+functionSpecifierPrefixToExpr s =+    case s of+      Syntax.FunctionSpecifierPrefixInline -> Serialization.cst "inline"+      Syntax.FunctionSpecifierPrefixVirtual -> Serialization.cst "virtual"+      Syntax.FunctionSpecifierPrefixStatic -> Serialization.cst "static"+      Syntax.FunctionSpecifierPrefixExplicit -> Serialization.cst "explicit"+-- | Convert a function specifier suffix to an expression+functionSpecifierSuffixToExpr :: Syntax.FunctionSpecifierSuffix -> Ast.Expr+functionSpecifierSuffixToExpr s =+    case s of+      Syntax.FunctionSpecifierSuffixConst -> Serialization.cst "const"+      Syntax.FunctionSpecifierSuffixNoexcept -> Serialization.cst "noexcept"+      Syntax.FunctionSpecifierSuffixOverride -> Serialization.cst "override"+      Syntax.FunctionSpecifierSuffixFinal -> Serialization.cst "final"+-- | Convert a function type to an expression+functionTypeToExpr :: Syntax.FunctionType -> Ast.Expr+functionTypeToExpr ft =++      let retType = Syntax.functionTypeReturnType ft+          params = Syntax.functionTypeParameters ft+      in (Serialization.spaceSep [+        typeExpressionToExpr retType,+        (Serialization.parenListAdaptive (Lists.map parameterToExpr params))])+-- | Convert a greater-than-or-equal operation to an expression+greaterEqualOperationToExpr :: Syntax.GreaterEqualOperation -> Ast.Expr+greaterEqualOperationToExpr op =++      let left = Syntax.greaterEqualOperationLeft op+          right = Syntax.greaterEqualOperationRight op+      in (Serialization.spaceSep [+        relationalExpressionToExpr left,+        (Serialization.cst ">="),+        (shiftExpressionToExpr right)])+-- | Convert a greater-than operation to an expression+greaterOperationToExpr :: Syntax.GreaterOperation -> Ast.Expr+greaterOperationToExpr op =++      let left = Syntax.greaterOperationLeft op+          right = Syntax.greaterOperationRight op+      in (Serialization.spaceSep [+        relationalExpressionToExpr left,+        (Serialization.cst ">"),+        (shiftExpressionToExpr right)])+-- | Convert an if directive to an expression+ifDirectiveToExpr :: Syntax.IfDirective -> Ast.Expr+ifDirectiveToExpr ifd =+    Serialization.spaceSep [+      Serialization.cst "#if",+      (Serialization.cst (Syntax.ifDirectiveCondition ifd))]+-- | Convert an ifdef directive to an expression+ifdefDirectiveToExpr :: Syntax.IfdefDirective -> Ast.Expr+ifdefDirectiveToExpr id =+    Serialization.spaceSep [+      Serialization.cst "#ifdef",+      (Serialization.cst (Syntax.ifdefDirectiveIdentifier id))]+-- | Convert an ifndef directive to an expression+ifndefDirectiveToExpr :: Syntax.IfndefDirective -> Ast.Expr+ifndefDirectiveToExpr ind =+    Serialization.spaceSep [+      Serialization.cst "#ifndef",+      (Serialization.cst (Syntax.ifndefDirectiveIdentifier ind))]+-- | Convert an include directive to an expression+includeDirectiveToExpr :: Syntax.IncludeDirective -> Ast.Expr+includeDirectiveToExpr incl =++      let name = Syntax.includeDirectiveName incl+          isSystem = Syntax.includeDirectiveIsSystem incl+      in (Logic.ifElse isSystem (Serialization.cst (Strings.cat [+        "#include <",+        name,+        ">"])) (Serialization.cst (Strings.cat [+        "#include \"",+        name,+        "\""])))+-- | Convert an inclusive or expression to an expression+inclusiveOrExpressionToExpr :: Syntax.InclusiveOrExpression -> Ast.Expr+inclusiveOrExpressionToExpr e =+    case e of+      Syntax.InclusiveOrExpressionExclusiveOr v0 -> exclusiveOrExpressionToExpr v0+      Syntax.InclusiveOrExpressionBitwiseOr v0 -> bitwiseOrOperationToExpr v0+-- | Convert an integer literal to an expression+integerLiteralToExpr :: Syntax.IntegerLiteral -> Ast.Expr+integerLiteralToExpr i =+    case i of+      Syntax.IntegerLiteralDecimal v0 -> Serialization.cst (Literals.showBigint v0)+      Syntax.IntegerLiteralHexadecimal v0 -> Serialization.cst (Strings.cat2 "0x" v0)+      Syntax.IntegerLiteralOctal v0 -> Serialization.cst (Strings.cat2 "0" v0)+      Syntax.IntegerLiteralBinary v0 -> Serialization.cst (Strings.cat2 "0b" v0)+-- | Convert an iteration statement to an expression+iterationStatementToExpr :: Syntax.IterationStatement -> Ast.Expr+iterationStatementToExpr i =+    case i of+      Syntax.IterationStatementWhile v0 -> whileStatementToExpr v0+      Syntax.IterationStatementDo v0 -> doStatementToExpr v0+      Syntax.IterationStatementFor v0 -> forStatementToExpr v0+      Syntax.IterationStatementRangeFor v0 -> rangeForStatementToExpr v0+-- | Convert a jump statement to an expression+jumpStatementToExpr :: Syntax.JumpStatement -> Ast.Expr+jumpStatementToExpr j =+    case j of+      Syntax.JumpStatementBreak -> Serialization.withSemi (Serialization.cst "break")+      Syntax.JumpStatementContinue -> Serialization.withSemi (Serialization.cst "continue")+      Syntax.JumpStatementReturnValue v0 -> Serialization.withSemi (Serialization.spaceSep [+        Serialization.cst "return",+        (expressionToExpr v0)])+      Syntax.JumpStatementReturnVoid -> Serialization.withSemi (Serialization.cst "return")+      Syntax.JumpStatementThrow v0 -> Serialization.withSemi (Serialization.spaceSep [+        Serialization.cst "throw",+        (expressionToExpr v0)])+-- | Convert a labeled statement to an expression+labeledStatementToExpr :: Syntax.LabeledStatement -> Ast.Expr+labeledStatementToExpr ls =++      let label = Syntax.labeledStatementLabel ls+          stmt = Syntax.labeledStatementStatement ls+      in (Serialization.newlineSep [+        Serialization.cst (Strings.cat2 label ":"),+        (statementToExpr stmt)])+-- | Convert a lambda expression to an expression+lambdaExpressionToExpr :: Syntax.LambdaExpression -> Ast.Expr+lambdaExpressionToExpr le =++      let captures = Syntax.lambdaExpressionCaptures le+          params = Syntax.lambdaExpressionParameters le+          retType = Syntax.lambdaExpressionReturnType le+          body = Syntax.lambdaExpressionBody le+      in (Serialization.spaceSep [+        captureListToExpr captures,+        (Logic.ifElse (Lists.null params) (Serialization.parens (Serialization.cst "")) (Serialization.parenListAdaptive (Lists.map parameterToExpr params))),+        (Optionals.cases retType (Serialization.cst "") (\t -> Serialization.spaceSep [+          Serialization.cst "->",+          (typeExpressionToExpr t)])),+        (compoundStatementToExpr body)])+-- | Convert a left shift operation to an expression+leftShiftOperationToExpr :: Syntax.LeftShiftOperation -> Ast.Expr+leftShiftOperationToExpr op =++      let left = Syntax.leftShiftOperationLeft op+          right = Syntax.leftShiftOperationRight op+      in (Serialization.spaceSep [+        shiftExpressionToExpr left,+        (Serialization.cst "<<"),+        (additiveExpressionToExpr right)])+-- | Convert a less-than-or-equal operation to an expression+lessEqualOperationToExpr :: Syntax.LessEqualOperation -> Ast.Expr+lessEqualOperationToExpr op =++      let left = Syntax.lessEqualOperationLeft op+          right = Syntax.lessEqualOperationRight op+      in (Serialization.spaceSep [+        relationalExpressionToExpr left,+        (Serialization.cst "<="),+        (shiftExpressionToExpr right)])+-- | Convert a less-than operation to an expression+lessOperationToExpr :: Syntax.LessOperation -> Ast.Expr+lessOperationToExpr op =++      let left = Syntax.lessOperationLeft op+          right = Syntax.lessOperationRight op+      in (Serialization.spaceSep [+        relationalExpressionToExpr left,+        (Serialization.cst "<"),+        (shiftExpressionToExpr right)])+-- | Convert a line directive to an expression+lineDirectiveToExpr :: Syntax.LineDirective -> Ast.Expr+lineDirectiveToExpr ld =++      let lineNumber = Syntax.lineDirectiveLineNumber ld+          filename = Syntax.lineDirectiveFilename ld+      in (Serialization.spaceSep (Lists.concat [+        [+          Serialization.cst "#line",+          (Serialization.cst (Literals.showInt32 lineNumber))],+        (Optionals.cases filename [] (\f -> [+          Serialization.cst (Strings.cat [+            "\"",+            f,+            "\""])]))]))+-- | Convert a literal to an expression+literalToExpr :: Syntax.Literal -> Ast.Expr+literalToExpr l =+    case l of+      Syntax.LiteralInteger v0 -> integerLiteralToExpr v0+      Syntax.LiteralFloating v0 -> Serialization.cst (Literals.showFloat64 (Syntax.unFloatingLiteral v0))+      Syntax.LiteralCharacter v0 -> Serialization.cst (Strings.cat [+        "'",+        (Syntax.unCharacterLiteral v0),+        "'"])+      Syntax.LiteralString v0 -> Serialization.cst (Strings.cat [+        "\"",+        (Syntax.unStringLiteral v0),+        "\""])+      Syntax.LiteralBoolean v0 -> booleanLiteralToExpr v0+      Syntax.LiteralNull -> Serialization.cst "nullptr"+-- | Convert a logical and expression to an expression+logicalAndExpressionToExpr :: Syntax.LogicalAndExpression -> Ast.Expr+logicalAndExpressionToExpr e =+    case e of+      Syntax.LogicalAndExpressionInclusiveOr v0 -> inclusiveOrExpressionToExpr v0+      Syntax.LogicalAndExpressionLogicalAnd v0 -> logicalAndOperationToExpr v0+-- | Convert a logical and operation to an expression+logicalAndOperationToExpr :: Syntax.LogicalAndOperation -> Ast.Expr+logicalAndOperationToExpr op =++      let left = Syntax.logicalAndOperationLeft op+          right = Syntax.logicalAndOperationRight op+      in (Serialization.spaceSep [+        logicalAndExpressionToExpr left,+        (Serialization.cst "&&"),+        (inclusiveOrExpressionToExpr right)])+-- | Convert a logical or expression to an expression+logicalOrExpressionToExpr :: Syntax.LogicalOrExpression -> Ast.Expr+logicalOrExpressionToExpr e =+    case e of+      Syntax.LogicalOrExpressionLogicalAnd v0 -> logicalAndExpressionToExpr v0+      Syntax.LogicalOrExpressionLogicalOr v0 -> logicalOrOperationToExpr v0+-- | Convert a logical or operation to an expression+logicalOrOperationToExpr :: Syntax.LogicalOrOperation -> Ast.Expr+logicalOrOperationToExpr op =++      let left = Syntax.logicalOrOperationLeft op+          right = Syntax.logicalOrOperationRight op+      in (Serialization.spaceSep [+        logicalOrExpressionToExpr left,+        (Serialization.cst "||"),+        (logicalAndExpressionToExpr right)])+-- | Convert a map entry to an expression+mapEntryToExpr :: Syntax.MapEntry -> Ast.Expr+mapEntryToExpr me =++      let key = Syntax.mapEntryKey me+          val = Syntax.mapEntryValue me+      in (Serialization.spaceSep [+        Serialization.curlyBracesList Nothing Serialization.inlineStyle [+          expressionToExpr key],+        (Serialization.cst "->"),+        (expressionToExpr val)])+-- | Convert a map to an expression+mapToExpr :: Syntax.Map -> Ast.Expr+mapToExpr m =++      let keyType = Syntax.mapKeyType m+          valType = Syntax.mapValueType m+          entries = Syntax.mapEntries m+      in (Serialization.spaceSep [+        Serialization.cst "std::map<",+        (Serialization.commaSep Serialization.inlineStyle [+          typeExpressionToExpr keyType,+          (typeExpressionToExpr valType)]),+        (Serialization.cst ">"),+        (Serialization.curlyBracesList Nothing Serialization.inlineStyle (Lists.map mapEntryToExpr entries))])+-- | Convert a member initializer to an expression+memInitializerToExpr :: Syntax.MemInitializer -> Ast.Expr+memInitializerToExpr mi =++      let name = Syntax.memInitializerName mi+          args = Syntax.memInitializerArguments mi+      in (Serialization.noSep [+        Serialization.cst name,+        (Serialization.parenListAdaptive (Lists.map expressionToExpr args))])+-- | Convert a member access operation to an expression+memberAccessOperationToExpr :: Syntax.MemberAccessOperation -> Ast.Expr+memberAccessOperationToExpr mao =++      let obj = Syntax.memberAccessOperationObject mao+          member = Syntax.memberAccessOperationMember mao+      in (Serialization.noSep [+        postfixExpressionToExpr obj,+        (Serialization.cst "."),+        (Serialization.cst member)])+-- | Convert a member declaration to an expression+memberDeclarationToExpr :: Bool -> Syntax.MemberDeclaration -> Ast.Expr+memberDeclarationToExpr commas m =+    case m of+      Syntax.MemberDeclarationFunction v0 -> functionDeclarationToExpr v0+      Syntax.MemberDeclarationVariable v0 -> variableDeclarationToExpr commas v0+      Syntax.MemberDeclarationConstructor v0 -> constructorDeclarationToExpr v0+      Syntax.MemberDeclarationDestructor v0 -> destructorDeclarationToExpr v0+      Syntax.MemberDeclarationNestedClass v0 -> classDeclarationToExpr v0+      Syntax.MemberDeclarationTemplate v0 -> templateDeclarationToExpr v0+-- | Convert a member specification to an expression+memberSpecificationToExpr :: Bool -> Syntax.MemberSpecification -> Ast.Expr+memberSpecificationToExpr commas m =+    case m of+      Syntax.MemberSpecificationAccessLabel v0 -> Serialization.noSep [+        accessSpecifierToExpr v0,+        (Serialization.cst ":")]+      Syntax.MemberSpecificationMember v0 -> memberDeclarationToExpr commas v0+-- | Convert a modulo operation to an expression+moduloOperationToExpr :: Syntax.ModuloOperation -> Ast.Expr+moduloOperationToExpr op =++      let left = Syntax.moduloOperationLeft op+          right = Syntax.moduloOperationRight op+      in (Serialization.spaceSep [+        multiplicativeExpressionToExpr left,+        (Serialization.cst "%"),+        (unaryExpressionToExpr right)])+-- | Convert a multiplicative expression to an expression+multiplicativeExpressionToExpr :: Syntax.MultiplicativeExpression -> Ast.Expr+multiplicativeExpressionToExpr e =+    case e of+      Syntax.MultiplicativeExpressionUnary v0 -> unaryExpressionToExpr v0+      Syntax.MultiplicativeExpressionMultiply v0 -> multiplyOperationToExpr v0+      Syntax.MultiplicativeExpressionDivide v0 -> divideOperationToExpr v0+      Syntax.MultiplicativeExpressionModulo v0 -> moduloOperationToExpr v0+-- | Convert a multiply operation to an expression+multiplyOperationToExpr :: Syntax.MultiplyOperation -> Ast.Expr+multiplyOperationToExpr op =++      let left = Syntax.multiplyOperationLeft op+          right = Syntax.multiplyOperationRight op+      in (Serialization.spaceSep [+        multiplicativeExpressionToExpr left,+        (Serialization.cst "*"),+        (unaryExpressionToExpr right)])+-- | Convert a namespace declaration to an expression+namespaceDeclarationToExpr :: Syntax.NamespaceDeclaration -> Ast.Expr+namespaceDeclarationToExpr nd =++      let name = Syntax.namespaceDeclarationName nd+          decls = Syntax.namespaceDeclarationDeclarations nd+      in (Serialization.spaceSep [+        Serialization.cst (Strings.cat2 "namespace " name),+        (Serialization.curlyBlock Serialization.fullBlockStyle (Serialization.doubleNewlineSep (Lists.map declarationToExpr decls)))])+-- | Convert a not-equal operation to an expression+notEqualOperationToExpr :: Syntax.NotEqualOperation -> Ast.Expr+notEqualOperationToExpr op =++      let left = Syntax.notEqualOperationLeft op+          right = Syntax.notEqualOperationRight op+      in (Serialization.spaceSep [+        equalityExpressionToExpr left,+        (Serialization.cst "!="),+        (relationalExpressionToExpr right)])+-- | Convert an optional to an expression+optionalToExpr :: Syntax.Optional -> Ast.Expr+optionalToExpr opt =++      let valType = Syntax.optionalValueType opt+          val = Syntax.optionalValue opt+      in (Serialization.spaceSep [+        Serialization.cst "std::optional<",+        (typeExpressionToExpr valType),+        (Serialization.cst ">"),+        (Optionals.cases val (Serialization.cst "{}") (\v -> Serialization.curlyBracesList Nothing Serialization.inlineStyle [+          expressionToExpr v]))])+-- | Convert overloaded lambdas to an expression+overloadedLambdasToExpr :: Syntax.OverloadedLambdas -> Ast.Expr+overloadedLambdasToExpr ol =+    Serialization.spaceSep [+      Serialization.cst "overloaded",+      (Serialization.curlyBlock Serialization.fullBlockStyle (Serialization.newlineSep (Lists.map lambdaExpressionToExpr (Syntax.unOverloadedLambdas ol))))]+-- | Convert a parameter to an expression+parameterToExpr :: Syntax.Parameter -> Ast.Expr+parameterToExpr p =++      let typ = Syntax.parameterType p+          name = Syntax.parameterName p+          unnamed = Syntax.parameterUnnamed p+          defaultVal = Syntax.parameterDefaultValue p+          nameExpr =+                  Serialization.cst (Logic.ifElse unnamed (Strings.cat [+                    "/*",+                    name,+                    "*/"]) name)+      in (Serialization.spaceSep (Lists.concat [+        [+          typeExpressionToExpr typ,+          nameExpr],+        (Optionals.cases defaultVal [] (\expr -> [+          Serialization.cst "=",+          (expressionToExpr expr)]))]))+-- | Convert a pattern match to an expression+patternMatchToExpr :: Syntax.PatternMatch -> Ast.Expr+patternMatchToExpr pm =++      let visitor = Syntax.patternMatchVisitor pm+          variant = Syntax.patternMatchVariant pm+      in (Serialization.spaceSep [+        Serialization.cst "std::visit",+        (Serialization.parenListAdaptive [+          visitorToExpr visitor,+          (expressionToExpr variant)])])+-- | Convert a pointer member access operation to an expression+pointerMemberAccessOperationToExpr :: Syntax.PointerMemberAccessOperation -> Ast.Expr+pointerMemberAccessOperationToExpr pmao =++      let ptr = Syntax.pointerMemberAccessOperationPointer pmao+          member = Syntax.pointerMemberAccessOperationMember pmao+      in (Serialization.noSep [+        postfixExpressionToExpr ptr,+        (Serialization.cst "->"),+        (Serialization.cst member)])+-- | Convert a postfix expression to an expression+postfixExpressionToExpr :: Syntax.PostfixExpression -> Ast.Expr+postfixExpressionToExpr e =+    case e of+      Syntax.PostfixExpressionPrimary v0 -> primaryExpressionToExpr v0+      Syntax.PostfixExpressionSubscript v0 -> subscriptOperationToExpr v0+      Syntax.PostfixExpressionFunctionCall v0 -> functionCallOperationToExpr v0+      Syntax.PostfixExpressionTemplateFunctionCall v0 -> templateFunctionCallOperationToExpr v0+      Syntax.PostfixExpressionMemberAccess v0 -> memberAccessOperationToExpr v0+      Syntax.PostfixExpressionPointerMemberAccess v0 -> pointerMemberAccessOperationToExpr v0+      Syntax.PostfixExpressionPostIncrement v0 -> Serialization.noSep [+        postfixExpressionToExpr v0,+        (Serialization.cst "++")]+      Syntax.PostfixExpressionPostDecrement v0 -> Serialization.noSep [+        postfixExpressionToExpr v0,+        (Serialization.cst "--")]+-- | Convert a pragma directive to an expression+pragmaDirectiveToExpr :: Syntax.PragmaDirective -> Ast.Expr+pragmaDirectiveToExpr pd = Serialization.cst (Strings.cat2 "#pragma " (Syntax.pragmaDirectiveContent pd))+-- | Convert a preprocessor directive to an expression+preprocessorDirectiveToExpr :: Syntax.PreprocessorDirective -> Ast.Expr+preprocessorDirectiveToExpr d =+    case d of+      Syntax.PreprocessorDirectiveInclude v0 -> includeDirectiveToExpr v0+      Syntax.PreprocessorDirectivePragma v0 -> pragmaDirectiveToExpr v0+      Syntax.PreprocessorDirectiveDefine v0 -> defineDirectiveToExpr v0+      Syntax.PreprocessorDirectiveUndef v0 -> undefDirectiveToExpr v0+      Syntax.PreprocessorDirectiveIfdef v0 -> ifdefDirectiveToExpr v0+      Syntax.PreprocessorDirectiveIfndef v0 -> ifndefDirectiveToExpr v0+      Syntax.PreprocessorDirectiveIf v0 -> ifDirectiveToExpr v0+      Syntax.PreprocessorDirectiveElif v0 -> elifDirectiveToExpr v0+      Syntax.PreprocessorDirectiveElse v0 -> elseDirectiveToExpr v0+      Syntax.PreprocessorDirectiveEndif v0 -> endifDirectiveToExpr v0+      Syntax.PreprocessorDirectiveLine v0 -> lineDirectiveToExpr v0+      Syntax.PreprocessorDirectiveError v0 -> errorDirectiveToExpr v0+      Syntax.PreprocessorDirectiveWarning v0 -> warningDirectiveToExpr v0+-- | Convert a primary expression to an expression+primaryExpressionToExpr :: Syntax.PrimaryExpression -> Ast.Expr+primaryExpressionToExpr e =+    case e of+      Syntax.PrimaryExpressionIdentifier v0 -> Serialization.cst v0+      Syntax.PrimaryExpressionLiteral v0 -> literalToExpr v0+      Syntax.PrimaryExpressionParenthesized v0 -> Serialization.parens (expressionToExpr v0)+      Syntax.PrimaryExpressionLambda v0 -> lambdaExpressionToExpr v0+-- | Convert a program to an expression+programToExpr :: Syntax.Program -> Ast.Expr+programToExpr prog =++      let preps = Syntax.programPreprocessorDirectives prog+          includes = Syntax.programIncludes prog+          decls = Syntax.programDeclarations prog+          separate = \sep -> \defs -> Logic.ifElse (Lists.null defs) Nothing (Just (sep defs))+      in (Serialization.doubleNewlineSep (Optionals.cat [+        separate Serialization.newlineSep (Lists.map preprocessorDirectiveToExpr preps),+        (separate Serialization.newlineSep (Lists.map includeDirectiveToExpr includes)),+        (separate Serialization.doubleNewlineSep (Lists.map declarationToExpr decls))]))+-- | Convert a qualified identifier to an expression+qualifiedIdentifierToExpr :: Syntax.QualifiedIdentifier -> Ast.Expr+qualifiedIdentifierToExpr qi =++      let ns = Syntax.qualifiedIdentifierNamespace qi+          name = Syntax.qualifiedIdentifierName qi+      in (Serialization.cst (Strings.cat [+        ns,+        "::",+        name]))+-- | Convert a qualified type to an expression+qualifiedTypeToExpr :: Syntax.QualifiedType -> Ast.Expr+qualifiedTypeToExpr qt =++      let baseType = Syntax.qualifiedTypeBaseType qt+          qualifier = Syntax.qualifiedTypeQualifier qt+      in case qualifier of+        Syntax.TypeQualifierConst -> Serialization.spaceSep [+          Serialization.cst "const",+          (typeExpressionToExpr baseType)]+        Syntax.TypeQualifierLvalueRef -> Serialization.noSep [+          typeExpressionToExpr baseType,+          (Serialization.cst "&")]+        Syntax.TypeQualifierRvalueRef -> Serialization.noSep [+          typeExpressionToExpr baseType,+          (Serialization.cst "&&")]+        Syntax.TypeQualifierPointer -> Serialization.noSep [+          typeExpressionToExpr baseType,+          (Serialization.cst "*")]+-- | Convert a range-for statement to an expression+rangeForStatementToExpr :: Syntax.RangeForStatement -> Ast.Expr+rangeForStatementToExpr rfs =++      let typ = Syntax.rangeForStatementType rfs+          var = Syntax.rangeForStatementVariable rfs+          range = Syntax.rangeForStatementRange rfs+          body = Syntax.rangeForStatementBody rfs+      in (Serialization.newlineSep [+        Serialization.spaceSep [+          Serialization.cst "for",+          (Serialization.parens (Serialization.spaceSep [+            typeExpressionToExpr typ,+            (Serialization.cst var),+            (Serialization.cst ":"),+            (expressionToExpr range)]))],+        (statementToExpr body)])+-- | Convert a relational expression to an expression+relationalExpressionToExpr :: Syntax.RelationalExpression -> Ast.Expr+relationalExpressionToExpr e =+    case e of+      Syntax.RelationalExpressionShift v0 -> shiftExpressionToExpr v0+      Syntax.RelationalExpressionLess v0 -> lessOperationToExpr v0+      Syntax.RelationalExpressionGreater v0 -> greaterOperationToExpr v0+      Syntax.RelationalExpressionLessEqual v0 -> lessEqualOperationToExpr v0+      Syntax.RelationalExpressionGreaterEqual v0 -> greaterEqualOperationToExpr v0+-- | Convert a right shift operation to an expression+rightShiftOperationToExpr :: Syntax.RightShiftOperation -> Ast.Expr+rightShiftOperationToExpr op =++      let left = Syntax.rightShiftOperationLeft op+          right = Syntax.rightShiftOperationRight op+      in (Serialization.spaceSep [+        shiftExpressionToExpr left,+        (Serialization.cst ">>"),+        (additiveExpressionToExpr right)])+-- | Convert a selection statement to an expression+selectionStatementToExpr :: Syntax.SelectionStatement -> Ast.Expr+selectionStatementToExpr ss =++      let cond = Syntax.selectionStatementCondition ss+          thenBranch = Syntax.selectionStatementThenBranch ss+          elseBranch = Syntax.selectionStatementElseBranch ss+      in (Serialization.newlineSep [+        Serialization.spaceSep [+          Serialization.cst "if",+          (Serialization.parens (expressionToExpr cond))],+        (statementToExpr thenBranch),+        (Optionals.cases elseBranch (Serialization.cst "") (\stmt -> Serialization.newlineSep [+          Serialization.cst "else",+          (statementToExpr stmt)]))])+-- | Convert a set to an expression+setToExpr :: Syntax.Set -> Ast.Expr+setToExpr s =++      let elemType = Syntax.setElementType s+          elems = Syntax.setElements s+      in (Serialization.spaceSep [+        Serialization.cst "std::set<",+        (typeExpressionToExpr elemType),+        (Serialization.cst ">"),+        (Serialization.curlyBracesList Nothing Serialization.inlineStyle (Lists.map expressionToExpr elems))])+-- | Convert a shift expression to an expression+shiftExpressionToExpr :: Syntax.ShiftExpression -> Ast.Expr+shiftExpressionToExpr e =+    case e of+      Syntax.ShiftExpressionAdditive v0 -> additiveExpressionToExpr v0+      Syntax.ShiftExpressionLeftShift v0 -> leftShiftOperationToExpr v0+      Syntax.ShiftExpressionRightShift v0 -> rightShiftOperationToExpr v0+-- | Convert a sizeof expression to an expression+sizeofExpressionToExpr :: Syntax.SizeofExpression -> Ast.Expr+sizeofExpressionToExpr se =+    Serialization.spaceSep [+      Serialization.cst "sizeof",+      (Serialization.parens (typeExpressionToExpr (Syntax.unSizeofExpression se)))]+-- | Convert a statement to an expression+statementToExpr :: Syntax.Statement -> Ast.Expr+statementToExpr s =+    case s of+      Syntax.StatementLabeled v0 -> labeledStatementToExpr v0+      Syntax.StatementCompound v0 -> compoundStatementToExpr v0+      Syntax.StatementSelection v0 -> selectionStatementToExpr v0+      Syntax.StatementSwitch v0 -> switchStatementToExpr v0+      Syntax.StatementIteration v0 -> iterationStatementToExpr v0+      Syntax.StatementJump v0 -> jumpStatementToExpr v0+      Syntax.StatementDeclaration v0 -> Serialization.withSemi (variableDeclarationToExpr False v0)+      Syntax.StatementExpression v0 -> Serialization.withSemi (expressionToExpr v0)+-- | Convert a subscript operation to an expression+subscriptOperationToExpr :: Syntax.SubscriptOperation -> Ast.Expr+subscriptOperationToExpr so =++      let array = Syntax.subscriptOperationArray so+          index = Syntax.subscriptOperationIndex so+      in (Serialization.noSep [+        postfixExpressionToExpr array,+        (Serialization.cst "["),+        (expressionToExpr index),+        (Serialization.cst "]")])+-- | Convert a subtract operation to an expression+subtractOperationToExpr :: Syntax.SubtractOperation -> Ast.Expr+subtractOperationToExpr op =++      let left = Syntax.subtractOperationLeft op+          right = Syntax.subtractOperationRight op+      in (Serialization.spaceSep [+        additiveExpressionToExpr left,+        (Serialization.cst "-"),+        (multiplicativeExpressionToExpr right)])+-- | Convert a switch statement to an expression+switchStatementToExpr :: Syntax.SwitchStatement -> Ast.Expr+switchStatementToExpr ss =++      let value = Syntax.switchStatementValue ss+          cases = Syntax.switchStatementCases ss+      in (Serialization.spaceSep [+        Serialization.cst "switch",+        (Serialization.parens (expressionToExpr value)),+        (Serialization.curlyBlock Serialization.fullBlockStyle (Serialization.newlineSep (Lists.map caseStatementToExpr cases)))])+-- | Convert a template argument to an expression+templateArgumentToExpr :: Syntax.TemplateArgument -> Ast.Expr+templateArgumentToExpr a =+    case a of+      Syntax.TemplateArgumentType v0 -> typeExpressionToExpr v0+      Syntax.TemplateArgumentValue v0 -> expressionToExpr v0+-- | Convert a template declaration to an expression+templateDeclarationToExpr :: Syntax.TemplateDeclaration -> Ast.Expr+templateDeclarationToExpr td =++      let inline = Syntax.templateDeclarationInline td+          params = Syntax.templateDeclarationParameters td+          declaration = Syntax.templateDeclarationDeclaration td+          sep = Logic.ifElse inline Serialization.spaceSep Serialization.newlineSep+      in (sep [+        Serialization.noSep [+          Serialization.cst "template",+          (Serialization.angleBracesList Serialization.inlineStyle (Lists.map (\p -> Serialization.cst p) params))],+        (declarationToExpr declaration)])+-- | Convert a template function call operation to an expression+templateFunctionCallOperationToExpr :: Syntax.TemplateFunctionCallOperation -> Ast.Expr+templateFunctionCallOperationToExpr tfco =++      let func = Syntax.templateFunctionCallOperationFunction tfco+          templateArgs = Syntax.templateFunctionCallOperationTemplateArguments tfco+          args = Syntax.templateFunctionCallOperationArguments tfco+      in (Serialization.noSep [+        postfixExpressionToExpr func,+        (Serialization.angleBracesList Serialization.inlineStyle (Lists.map templateArgumentToExpr templateArgs)),+        (Serialization.parenListAdaptive (Lists.map expressionToExpr args))])+-- | Convert a template type to an expression+templateTypeToExpr :: Syntax.TemplateType -> Ast.Expr+templateTypeToExpr tt =++      let name = Syntax.templateTypeName tt+          args = Syntax.templateTypeArguments tt+      in (Serialization.noSep [+        Serialization.cst name,+        (Serialization.angleBracesList Serialization.inlineStyle (Lists.map templateArgumentToExpr args))])+-- | Convert a ternary expression to an expression+ternaryExpressionToExpr :: Syntax.TernaryExpression -> Ast.Expr+ternaryExpressionToExpr te =++      let cond = Syntax.ternaryExpressionCondition te+          trueExpr = Syntax.ternaryExpressionTrueExpr te+          falseExpr = Syntax.ternaryExpressionFalseExpr te+      in (Serialization.spaceSep [+        logicalOrExpressionToExpr cond,+        (Serialization.cst "?"),+        (expressionToExpr trueExpr),+        (Serialization.cst ":"),+        (conditionalExpressionToExpr falseExpr)])+-- | Convert a string to a C++ comment. Empty single-line comments emit `//` (no trailing space).+toCppComments :: String -> Bool -> String+toCppComments s isMultiline =+    Logic.ifElse isMultiline (Strings.cat [+      "/* ",+      s,+      " */"]) (Logic.ifElse (Equality.equal s "") "//" (Strings.cat2 "// " s))+-- | Convert a type expression to an expression+typeExpressionToExpr :: Syntax.TypeExpression -> Ast.Expr+typeExpressionToExpr t =+    case t of+      Syntax.TypeExpressionBasic v0 -> basicTypeToExpr v0+      Syntax.TypeExpressionQualified v0 -> qualifiedTypeToExpr v0+      Syntax.TypeExpressionTemplate v0 -> templateTypeToExpr v0+      Syntax.TypeExpressionFunction v0 -> functionTypeToExpr v0+      Syntax.TypeExpressionAuto -> Serialization.cst "auto"+-- | Convert a typedef declaration to an expression+typedefDeclarationToExpr :: Syntax.TypedefDeclaration -> Ast.Expr+typedefDeclarationToExpr td =++      let name = Syntax.typedefDeclarationName td+          typ = Syntax.typedefDeclarationType td+          isUsing = Syntax.typedefDeclarationIsUsing td+      in (Logic.ifElse isUsing (Serialization.withSemi (Serialization.spaceSep [+        Serialization.cst (Strings.cat2 "using " name),+        (Serialization.cst "="),+        (typeExpressionToExpr typ)])) (Serialization.withSemi (Serialization.spaceSep [+        Serialization.cst "typedef",+        (typeExpressionToExpr typ),+        (Serialization.cst name)])))+-- | Convert a unary expression to an expression+unaryExpressionToExpr :: Syntax.UnaryExpression -> Ast.Expr+unaryExpressionToExpr e =+    case e of+      Syntax.UnaryExpressionPostfix v0 -> postfixExpressionToExpr v0+      Syntax.UnaryExpressionUnaryOp v0 -> unaryOperationToExpr v0+      Syntax.UnaryExpressionSizeof v0 -> sizeofExpressionToExpr v0+-- | Convert a unary operation to an expression+unaryOperationToExpr :: Syntax.UnaryOperation -> Ast.Expr+unaryOperationToExpr uo =++      let op = Syntax.unaryOperationOperator uo+          operand = Syntax.unaryOperationOperand uo+      in (Serialization.spaceSep [+        unaryOperatorToExpr op,+        (unaryExpressionToExpr operand)])+-- | Convert a unary operator to an expression+unaryOperatorToExpr :: Syntax.UnaryOperator -> Ast.Expr+unaryOperatorToExpr op =+    case op of+      Syntax.UnaryOperatorPlus -> Serialization.cst "+"+      Syntax.UnaryOperatorMinus -> Serialization.cst "-"+      Syntax.UnaryOperatorLogicalNot -> Serialization.cst "!"+      Syntax.UnaryOperatorBitwiseNot -> Serialization.cst "~"+      Syntax.UnaryOperatorDereference -> Serialization.cst "*"+      Syntax.UnaryOperatorAddressOf -> Serialization.cst "&"+      Syntax.UnaryOperatorPreIncrement -> Serialization.cst "++"+      Syntax.UnaryOperatorPreDecrement -> Serialization.cst "--"+-- | Convert an undef directive to an expression+undefDirectiveToExpr :: Syntax.UndefDirective -> Ast.Expr+undefDirectiveToExpr ud =+    Serialization.spaceSep [+      Serialization.cst "#undef",+      (Serialization.cst (Syntax.undefDirectiveName ud))]+-- | Convert a variable declaration to an expression+variableDeclarationToExpr :: Bool -> Syntax.VariableDeclaration -> Ast.Expr+variableDeclarationToExpr commas vd =++      let typ = Syntax.variableDeclarationType vd+          name = Syntax.variableDeclarationName vd+          init = Syntax.variableDeclarationInitializer vd+          isAuto = Syntax.variableDeclarationIsAuto vd+          terminator = Logic.ifElse commas Serialization.withComma Serialization.withSemi+      in (terminator (Serialization.spaceSep (Lists.concat [+        Logic.ifElse isAuto [+          Serialization.cst "auto"] (Optionals.cases typ [] (\t -> [+          typeExpressionToExpr t])),+        [+          Serialization.cst name],+        (Optionals.cases init [] (\expr -> [+          Serialization.cst "=",+          (expressionToExpr expr)]))])))+-- | Convert a vector to an expression+vectorToExpr :: Syntax.Vector -> Ast.Expr+vectorToExpr v =++      let elemType = Syntax.vectorElementType v+          elems = Syntax.vectorElements v+      in (Serialization.spaceSep [+        Serialization.cst "std::vector<",+        (typeExpressionToExpr elemType),+        (Serialization.cst ">"),+        (Serialization.curlyBracesList Nothing Serialization.inlineStyle (Lists.map expressionToExpr elems))])+-- | Convert a visitor to an expression+visitorToExpr :: Syntax.Visitor -> Ast.Expr+visitorToExpr v =+    case v of+      Syntax.VisitorLambda v0 -> lambdaExpressionToExpr v0+      Syntax.VisitorOverloaded v0 -> overloadedLambdasToExpr v0+-- | Convert a warning directive to an expression+warningDirectiveToExpr :: Syntax.WarningDirective -> Ast.Expr+warningDirectiveToExpr wd =+    Serialization.spaceSep [+      Serialization.cst "#warning",+      (Serialization.cst (Syntax.warningDirectiveMessage wd))]+-- | Convert a while statement to an expression+whileStatementToExpr :: Syntax.WhileStatement -> Ast.Expr+whileStatementToExpr ws =++      let cond = Syntax.whileStatementCondition ws+          body = Syntax.whileStatementBody ws+      in (Serialization.newlineSep [+        Serialization.spaceSep [+          Serialization.cst "while",+          (Serialization.parens (expressionToExpr cond))],+        (statementToExpr body)])
+ src/main/haskell/Hydra/Cpp/Syntax.hs view
@@ -0,0 +1,1253 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A C++ syntax model, focusing on features for representing algebraic data types and declarative computations++module Hydra.Cpp.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+data AccessSpecifier =+  AccessSpecifierPublic |+  AccessSpecifierProtected |+  AccessSpecifierPrivate |+  AccessSpecifierNone+  deriving (Eq, Ord, Read, Show)+_AccessSpecifier = Core.Name "hydra.cpp.syntax.AccessSpecifier"+_AccessSpecifier_public = Core.Name "public"+_AccessSpecifier_protected = Core.Name "protected"+_AccessSpecifier_private = Core.Name "private"+_AccessSpecifier_none = Core.Name "none"+data Program =+  Program {+    programPreprocessorDirectives :: [PreprocessorDirective],+    programIncludes :: [IncludeDirective],+    programDeclarations :: [Declaration]}+  deriving (Eq, Ord, Read, Show)+_Program = Core.Name "hydra.cpp.syntax.Program"+_Program_preprocessorDirectives = Core.Name "preprocessorDirectives"+_Program_includes = Core.Name "includes"+_Program_declarations = Core.Name "declarations"+data IncludeDirective =+  IncludeDirective {+    includeDirectiveName :: String,+    includeDirectiveIsSystem :: Bool}+  deriving (Eq, Ord, Read, Show)+_IncludeDirective = Core.Name "hydra.cpp.syntax.IncludeDirective"+_IncludeDirective_name = Core.Name "name"+_IncludeDirective_isSystem = Core.Name "isSystem"+data Declaration =+  DeclarationPreprocessor PreprocessorDirective |+  DeclarationClass ClassDeclaration |+  DeclarationFunction FunctionDeclaration |+  DeclarationVariable VariableDeclaration |+  DeclarationTypedef TypedefDeclaration |+  DeclarationNamespace NamespaceDeclaration |+  DeclarationTemplate TemplateDeclaration+  deriving (Eq, Ord, Read, Show)+_Declaration = Core.Name "hydra.cpp.syntax.Declaration"+_Declaration_preprocessor = Core.Name "preprocessor"+_Declaration_class = Core.Name "class"+_Declaration_function = Core.Name "function"+_Declaration_variable = Core.Name "variable"+_Declaration_typedef = Core.Name "typedef"+_Declaration_namespace = Core.Name "namespace"+_Declaration_template = Core.Name "template"+data NamespaceDeclaration =+  NamespaceDeclaration {+    namespaceDeclarationName :: String,+    namespaceDeclarationDeclarations :: [Declaration]}+  deriving (Eq, Ord, Read, Show)+_NamespaceDeclaration = Core.Name "hydra.cpp.syntax.NamespaceDeclaration"+_NamespaceDeclaration_name = Core.Name "name"+_NamespaceDeclaration_declarations = Core.Name "declarations"+data TypedefDeclaration =+  TypedefDeclaration {+    typedefDeclarationName :: String,+    typedefDeclarationType :: TypeExpression,+    typedefDeclarationIsUsing :: Bool}+  deriving (Eq, Ord, Read, Show)+_TypedefDeclaration = Core.Name "hydra.cpp.syntax.TypedefDeclaration"+_TypedefDeclaration_name = Core.Name "name"+_TypedefDeclaration_type = Core.Name "type"+_TypedefDeclaration_isUsing = Core.Name "isUsing"+data ClassDeclaration =+  ClassDeclaration {+    classDeclarationSpecifier :: ClassSpecifier,+    classDeclarationBody :: (Maybe ClassBody)}+  deriving (Eq, Ord, Read, Show)+_ClassDeclaration = Core.Name "hydra.cpp.syntax.ClassDeclaration"+_ClassDeclaration_specifier = Core.Name "specifier"+_ClassDeclaration_body = Core.Name "body"+data TemplateDeclaration =+  TemplateDeclaration {+    templateDeclarationInline :: Bool,+    templateDeclarationParameters :: [String],+    templateDeclarationDeclaration :: Declaration}+  deriving (Eq, Ord, Read, Show)+_TemplateDeclaration = Core.Name "hydra.cpp.syntax.TemplateDeclaration"+_TemplateDeclaration_inline = Core.Name "inline"+_TemplateDeclaration_parameters = Core.Name "parameters"+_TemplateDeclaration_declaration = Core.Name "declaration"+data PreprocessorDirective =+  PreprocessorDirectiveInclude IncludeDirective |+  PreprocessorDirectivePragma PragmaDirective |+  PreprocessorDirectiveDefine DefineDirective |+  PreprocessorDirectiveUndef UndefDirective |+  PreprocessorDirectiveIfdef IfdefDirective |+  PreprocessorDirectiveIfndef IfndefDirective |+  PreprocessorDirectiveIf IfDirective |+  PreprocessorDirectiveElif ElifDirective |+  PreprocessorDirectiveElse ElseDirective |+  PreprocessorDirectiveEndif EndifDirective |+  PreprocessorDirectiveLine LineDirective |+  PreprocessorDirectiveError ErrorDirective |+  PreprocessorDirectiveWarning WarningDirective+  deriving (Eq, Ord, Read, Show)+_PreprocessorDirective = Core.Name "hydra.cpp.syntax.PreprocessorDirective"+_PreprocessorDirective_include = Core.Name "include"+_PreprocessorDirective_pragma = Core.Name "pragma"+_PreprocessorDirective_define = Core.Name "define"+_PreprocessorDirective_undef = Core.Name "undef"+_PreprocessorDirective_ifdef = Core.Name "ifdef"+_PreprocessorDirective_ifndef = Core.Name "ifndef"+_PreprocessorDirective_if = Core.Name "if"+_PreprocessorDirective_elif = Core.Name "elif"+_PreprocessorDirective_else = Core.Name "else"+_PreprocessorDirective_endif = Core.Name "endif"+_PreprocessorDirective_line = Core.Name "line"+_PreprocessorDirective_error = Core.Name "error"+_PreprocessorDirective_warning = Core.Name "warning"+data PragmaDirective =+  PragmaDirective {+    pragmaDirectiveContent :: String}+  deriving (Eq, Ord, Read, Show)+_PragmaDirective = Core.Name "hydra.cpp.syntax.PragmaDirective"+_PragmaDirective_content = Core.Name "content"+data DefineDirective =+  DefineDirective {+    defineDirectiveName :: String,+    defineDirectiveParameters :: (Maybe [String]),+    defineDirectiveReplacement :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_DefineDirective = Core.Name "hydra.cpp.syntax.DefineDirective"+_DefineDirective_name = Core.Name "name"+_DefineDirective_parameters = Core.Name "parameters"+_DefineDirective_replacement = Core.Name "replacement"+data UndefDirective =+  UndefDirective {+    undefDirectiveName :: String}+  deriving (Eq, Ord, Read, Show)+_UndefDirective = Core.Name "hydra.cpp.syntax.UndefDirective"+_UndefDirective_name = Core.Name "name"+data IfdefDirective =+  IfdefDirective {+    ifdefDirectiveIdentifier :: String}+  deriving (Eq, Ord, Read, Show)+_IfdefDirective = Core.Name "hydra.cpp.syntax.IfdefDirective"+_IfdefDirective_identifier = Core.Name "identifier"+data IfndefDirective =+  IfndefDirective {+    ifndefDirectiveIdentifier :: String}+  deriving (Eq, Ord, Read, Show)+_IfndefDirective = Core.Name "hydra.cpp.syntax.IfndefDirective"+_IfndefDirective_identifier = Core.Name "identifier"+data IfDirective =+  IfDirective {+    ifDirectiveCondition :: String}+  deriving (Eq, Ord, Read, Show)+_IfDirective = Core.Name "hydra.cpp.syntax.IfDirective"+_IfDirective_condition = Core.Name "condition"+data ElifDirective =+  ElifDirective {+    elifDirectiveCondition :: String}+  deriving (Eq, Ord, Read, Show)+_ElifDirective = Core.Name "hydra.cpp.syntax.ElifDirective"+_ElifDirective_condition = Core.Name "condition"+type ElseDirective = ()+_ElseDirective = Core.Name "hydra.cpp.syntax.ElseDirective"+type EndifDirective = ()+_EndifDirective = Core.Name "hydra.cpp.syntax.EndifDirective"+data LineDirective =+  LineDirective {+    lineDirectiveLineNumber :: Int,+    lineDirectiveFilename :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_LineDirective = Core.Name "hydra.cpp.syntax.LineDirective"+_LineDirective_lineNumber = Core.Name "lineNumber"+_LineDirective_filename = Core.Name "filename"+data ErrorDirective =+  ErrorDirective {+    errorDirectiveMessage :: String}+  deriving (Eq, Ord, Read, Show)+_ErrorDirective = Core.Name "hydra.cpp.syntax.ErrorDirective"+_ErrorDirective_message = Core.Name "message"+data WarningDirective =+  WarningDirective {+    warningDirectiveMessage :: String}+  deriving (Eq, Ord, Read, Show)+_WarningDirective = Core.Name "hydra.cpp.syntax.WarningDirective"+_WarningDirective_message = Core.Name "message"+data ClassSpecifier =+  ClassSpecifier {+    classSpecifierKey :: ClassKey,+    classSpecifierName :: String,+    classSpecifierInheritance :: [BaseSpecifier]}+  deriving (Eq, Ord, Read, Show)+_ClassSpecifier = Core.Name "hydra.cpp.syntax.ClassSpecifier"+_ClassSpecifier_key = Core.Name "key"+_ClassSpecifier_name = Core.Name "name"+_ClassSpecifier_inheritance = Core.Name "inheritance"+data ClassKey =+  ClassKeyClass |+  ClassKeyEnum |+  ClassKeyEnumClass |+  ClassKeyStruct+  deriving (Eq, Ord, Read, Show)+_ClassKey = Core.Name "hydra.cpp.syntax.ClassKey"+_ClassKey_class = Core.Name "class"+_ClassKey_enum = Core.Name "enum"+_ClassKey_enumClass = Core.Name "enumClass"+_ClassKey_struct = Core.Name "struct"+data BaseSpecifier =+  BaseSpecifier {+    baseSpecifierAccess :: AccessSpecifier,+    baseSpecifierName :: String}+  deriving (Eq, Ord, Read, Show)+_BaseSpecifier = Core.Name "hydra.cpp.syntax.BaseSpecifier"+_BaseSpecifier_access = Core.Name "access"+_BaseSpecifier_name = Core.Name "name"+newtype ClassBody =+  ClassBody {+    unClassBody :: [MemberSpecification]}+  deriving (Eq, Ord, Read, Show)+_ClassBody = Core.Name "hydra.cpp.syntax.ClassBody"+data MemberSpecification =+  MemberSpecificationAccessLabel AccessSpecifier |+  MemberSpecificationMember MemberDeclaration+  deriving (Eq, Ord, Read, Show)+_MemberSpecification = Core.Name "hydra.cpp.syntax.MemberSpecification"+_MemberSpecification_accessLabel = Core.Name "accessLabel"+_MemberSpecification_member = Core.Name "member"+data MemberDeclaration =+  MemberDeclarationFunction FunctionDeclaration |+  MemberDeclarationVariable VariableDeclaration |+  MemberDeclarationConstructor ConstructorDeclaration |+  MemberDeclarationDestructor DestructorDeclaration |+  MemberDeclarationNestedClass ClassDeclaration |+  MemberDeclarationTemplate TemplateDeclaration+  deriving (Eq, Ord, Read, Show)+_MemberDeclaration = Core.Name "hydra.cpp.syntax.MemberDeclaration"+_MemberDeclaration_function = Core.Name "function"+_MemberDeclaration_variable = Core.Name "variable"+_MemberDeclaration_constructor = Core.Name "constructor"+_MemberDeclaration_destructor = Core.Name "destructor"+_MemberDeclaration_nestedClass = Core.Name "nestedClass"+_MemberDeclaration_template = Core.Name "template"+data ConstructorDeclaration =+  ConstructorDeclaration {+    constructorDeclarationName :: String,+    constructorDeclarationParameters :: [Parameter],+    constructorDeclarationInitializers :: [MemInitializer],+    constructorDeclarationBody :: FunctionBody}+  deriving (Eq, Ord, Read, Show)+_ConstructorDeclaration = Core.Name "hydra.cpp.syntax.ConstructorDeclaration"+_ConstructorDeclaration_name = Core.Name "name"+_ConstructorDeclaration_parameters = Core.Name "parameters"+_ConstructorDeclaration_initializers = Core.Name "initializers"+_ConstructorDeclaration_body = Core.Name "body"+data MemInitializer =+  MemInitializer {+    memInitializerName :: String,+    memInitializerArguments :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_MemInitializer = Core.Name "hydra.cpp.syntax.MemInitializer"+_MemInitializer_name = Core.Name "name"+_MemInitializer_arguments = Core.Name "arguments"+data DestructorDeclaration =+  DestructorDeclaration {+    destructorDeclarationPrefixSpecifiers :: [FunctionSpecifierPrefix],+    destructorDeclarationName :: String,+    destructorDeclarationSuffixSpecifiers :: [FunctionSpecifierSuffix],+    destructorDeclarationBody :: FunctionBody}+  deriving (Eq, Ord, Read, Show)+_DestructorDeclaration = Core.Name "hydra.cpp.syntax.DestructorDeclaration"+_DestructorDeclaration_prefixSpecifiers = Core.Name "prefixSpecifiers"+_DestructorDeclaration_name = Core.Name "name"+_DestructorDeclaration_suffixSpecifiers = Core.Name "suffixSpecifiers"+_DestructorDeclaration_body = Core.Name "body"+data FunctionDeclaration =+  FunctionDeclaration {+    functionDeclarationPrefixSpecifiers :: [FunctionSpecifierPrefix],+    functionDeclarationReturnType :: TypeExpression,+    functionDeclarationName :: String,+    functionDeclarationParameters :: [Parameter],+    functionDeclarationSuffixSpecifiers :: [FunctionSpecifierSuffix],+    functionDeclarationBody :: FunctionBody}+  deriving (Eq, Ord, Read, Show)+_FunctionDeclaration = Core.Name "hydra.cpp.syntax.FunctionDeclaration"+_FunctionDeclaration_prefixSpecifiers = Core.Name "prefixSpecifiers"+_FunctionDeclaration_returnType = Core.Name "returnType"+_FunctionDeclaration_name = Core.Name "name"+_FunctionDeclaration_parameters = Core.Name "parameters"+_FunctionDeclaration_suffixSpecifiers = Core.Name "suffixSpecifiers"+_FunctionDeclaration_body = Core.Name "body"+data FunctionSpecifierPrefix =+  FunctionSpecifierPrefixInline |+  FunctionSpecifierPrefixVirtual |+  FunctionSpecifierPrefixStatic |+  FunctionSpecifierPrefixExplicit+  deriving (Eq, Ord, Read, Show)+_FunctionSpecifierPrefix = Core.Name "hydra.cpp.syntax.FunctionSpecifierPrefix"+_FunctionSpecifierPrefix_inline = Core.Name "inline"+_FunctionSpecifierPrefix_virtual = Core.Name "virtual"+_FunctionSpecifierPrefix_static = Core.Name "static"+_FunctionSpecifierPrefix_explicit = Core.Name "explicit"+data FunctionSpecifierSuffix =+  FunctionSpecifierSuffixConst |+  FunctionSpecifierSuffixNoexcept |+  FunctionSpecifierSuffixOverride |+  FunctionSpecifierSuffixFinal+  deriving (Eq, Ord, Read, Show)+_FunctionSpecifierSuffix = Core.Name "hydra.cpp.syntax.FunctionSpecifierSuffix"+_FunctionSpecifierSuffix_const = Core.Name "const"+_FunctionSpecifierSuffix_noexcept = Core.Name "noexcept"+_FunctionSpecifierSuffix_override = Core.Name "override"+_FunctionSpecifierSuffix_final = Core.Name "final"+data Parameter =+  Parameter {+    parameterType :: TypeExpression,+    parameterName :: String,+    parameterUnnamed :: Bool,+    parameterDefaultValue :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_Parameter = Core.Name "hydra.cpp.syntax.Parameter"+_Parameter_type = Core.Name "type"+_Parameter_name = Core.Name "name"+_Parameter_unnamed = Core.Name "unnamed"+_Parameter_defaultValue = Core.Name "defaultValue"+data FunctionBody =+  FunctionBodyCompound CompoundStatement |+  FunctionBodyDeclaration |+  FunctionBodyPure |+  FunctionBodyDefault+  deriving (Eq, Ord, Read, Show)+_FunctionBody = Core.Name "hydra.cpp.syntax.FunctionBody"+_FunctionBody_compound = Core.Name "compound"+_FunctionBody_declaration = Core.Name "declaration"+_FunctionBody_pure = Core.Name "pure"+_FunctionBody_default = Core.Name "default"+data VariableDeclaration =+  VariableDeclaration {+    variableDeclarationType :: (Maybe TypeExpression),+    variableDeclarationName :: String,+    variableDeclarationInitializer :: (Maybe Expression),+    variableDeclarationIsAuto :: Bool}+  deriving (Eq, Ord, Read, Show)+_VariableDeclaration = Core.Name "hydra.cpp.syntax.VariableDeclaration"+_VariableDeclaration_type = Core.Name "type"+_VariableDeclaration_name = Core.Name "name"+_VariableDeclaration_initializer = Core.Name "initializer"+_VariableDeclaration_isAuto = Core.Name "isAuto"+data VariantDeclaration =+  VariantDeclaration {+    variantDeclarationTypes :: [TypeExpression],+    variantDeclarationName :: String}+  deriving (Eq, Ord, Read, Show)+_VariantDeclaration = Core.Name "hydra.cpp.syntax.VariantDeclaration"+_VariantDeclaration_types = Core.Name "types"+_VariantDeclaration_name = Core.Name "name"+data ProductDeclaration =+  ProductDeclaration {+    productDeclarationName :: String,+    productDeclarationFields :: [VariableDeclaration]}+  deriving (Eq, Ord, Read, Show)+_ProductDeclaration = Core.Name "hydra.cpp.syntax.ProductDeclaration"+_ProductDeclaration_name = Core.Name "name"+_ProductDeclaration_fields = Core.Name "fields"+data ContainerDeclaration =+  ContainerDeclarationList ListDeclaration |+  ContainerDeclarationMap MapDeclaration |+  ContainerDeclarationSet SetDeclaration |+  ContainerDeclarationOptional OptionalDeclaration+  deriving (Eq, Ord, Read, Show)+_ContainerDeclaration = Core.Name "hydra.cpp.syntax.ContainerDeclaration"+_ContainerDeclaration_list = Core.Name "list"+_ContainerDeclaration_map = Core.Name "map"+_ContainerDeclaration_set = Core.Name "set"+_ContainerDeclaration_optional = Core.Name "optional"+data ListDeclaration =+  ListDeclaration {+    listDeclarationElementType :: TypeExpression,+    listDeclarationName :: String}+  deriving (Eq, Ord, Read, Show)+_ListDeclaration = Core.Name "hydra.cpp.syntax.ListDeclaration"+_ListDeclaration_elementType = Core.Name "elementType"+_ListDeclaration_name = Core.Name "name"+data MapDeclaration =+  MapDeclaration {+    mapDeclarationKeyType :: TypeExpression,+    mapDeclarationValueType :: TypeExpression,+    mapDeclarationName :: String}+  deriving (Eq, Ord, Read, Show)+_MapDeclaration = Core.Name "hydra.cpp.syntax.MapDeclaration"+_MapDeclaration_keyType = Core.Name "keyType"+_MapDeclaration_valueType = Core.Name "valueType"+_MapDeclaration_name = Core.Name "name"+data SetDeclaration =+  SetDeclaration {+    setDeclarationElementType :: TypeExpression,+    setDeclarationName :: String}+  deriving (Eq, Ord, Read, Show)+_SetDeclaration = Core.Name "hydra.cpp.syntax.SetDeclaration"+_SetDeclaration_elementType = Core.Name "elementType"+_SetDeclaration_name = Core.Name "name"+data OptionalDeclaration =+  OptionalDeclaration {+    optionalDeclarationValueType :: TypeExpression,+    optionalDeclarationName :: String}+  deriving (Eq, Ord, Read, Show)+_OptionalDeclaration = Core.Name "hydra.cpp.syntax.OptionalDeclaration"+_OptionalDeclaration_valueType = Core.Name "valueType"+_OptionalDeclaration_name = Core.Name "name"+data Expression =+  ExpressionAssignment AssignmentExpression |+  ExpressionComma CommaExpression+  deriving (Eq, Ord, Read, Show)+_Expression = Core.Name "hydra.cpp.syntax.Expression"+_Expression_assignment = Core.Name "assignment"+_Expression_comma = Core.Name "comma"+data CommaExpression =+  CommaExpression {+    commaExpressionLeft :: Expression,+    commaExpressionRight :: AssignmentExpression}+  deriving (Eq, Ord, Read, Show)+_CommaExpression = Core.Name "hydra.cpp.syntax.CommaExpression"+_CommaExpression_left = Core.Name "left"+_CommaExpression_right = Core.Name "right"+data AssignmentExpression =+  AssignmentExpressionConditional ConditionalExpression |+  AssignmentExpressionAssignment ExplicitAssignment+  deriving (Eq, Ord, Read, Show)+_AssignmentExpression = Core.Name "hydra.cpp.syntax.AssignmentExpression"+_AssignmentExpression_conditional = Core.Name "conditional"+_AssignmentExpression_assignment = Core.Name "assignment"+data ExplicitAssignment =+  ExplicitAssignment {+    explicitAssignmentLeft :: LogicalOrExpression,+    explicitAssignmentOp :: AssignmentOperator,+    explicitAssignmentRight :: AssignmentExpression}+  deriving (Eq, Ord, Read, Show)+_ExplicitAssignment = Core.Name "hydra.cpp.syntax.ExplicitAssignment"+_ExplicitAssignment_left = Core.Name "left"+_ExplicitAssignment_op = Core.Name "op"+_ExplicitAssignment_right = Core.Name "right"+data AssignmentOperator =+  AssignmentOperatorAssign |+  AssignmentOperatorPlusAssign |+  AssignmentOperatorMinusAssign |+  AssignmentOperatorMultiplyAssign |+  AssignmentOperatorDivideAssign |+  AssignmentOperatorModuloAssign |+  AssignmentOperatorLeftShiftAssign |+  AssignmentOperatorRightShiftAssign |+  AssignmentOperatorBitwiseAndAssign |+  AssignmentOperatorBitwiseXorAssign |+  AssignmentOperatorBitwiseOrAssign+  deriving (Eq, Ord, Read, Show)+_AssignmentOperator = Core.Name "hydra.cpp.syntax.AssignmentOperator"+_AssignmentOperator_assign = Core.Name "assign"+_AssignmentOperator_plusAssign = Core.Name "plusAssign"+_AssignmentOperator_minusAssign = Core.Name "minusAssign"+_AssignmentOperator_multiplyAssign = Core.Name "multiplyAssign"+_AssignmentOperator_divideAssign = Core.Name "divideAssign"+_AssignmentOperator_moduloAssign = Core.Name "moduloAssign"+_AssignmentOperator_leftShiftAssign = Core.Name "leftShiftAssign"+_AssignmentOperator_rightShiftAssign = Core.Name "rightShiftAssign"+_AssignmentOperator_bitwiseAndAssign = Core.Name "bitwiseAndAssign"+_AssignmentOperator_bitwiseXorAssign = Core.Name "bitwiseXorAssign"+_AssignmentOperator_bitwiseOrAssign = Core.Name "bitwiseOrAssign"+data ConditionalExpression =+  ConditionalExpressionLogicalOr LogicalOrExpression |+  ConditionalExpressionTernary TernaryExpression+  deriving (Eq, Ord, Read, Show)+_ConditionalExpression = Core.Name "hydra.cpp.syntax.ConditionalExpression"+_ConditionalExpression_logicalOr = Core.Name "logicalOr"+_ConditionalExpression_ternary = Core.Name "ternary"+data TernaryExpression =+  TernaryExpression {+    ternaryExpressionCondition :: LogicalOrExpression,+    ternaryExpressionTrueExpr :: Expression,+    ternaryExpressionFalseExpr :: ConditionalExpression}+  deriving (Eq, Ord, Read, Show)+_TernaryExpression = Core.Name "hydra.cpp.syntax.TernaryExpression"+_TernaryExpression_condition = Core.Name "condition"+_TernaryExpression_trueExpr = Core.Name "trueExpr"+_TernaryExpression_falseExpr = Core.Name "falseExpr"+data LogicalOrExpression =+  LogicalOrExpressionLogicalAnd LogicalAndExpression |+  LogicalOrExpressionLogicalOr LogicalOrOperation+  deriving (Eq, Ord, Read, Show)+_LogicalOrExpression = Core.Name "hydra.cpp.syntax.LogicalOrExpression"+_LogicalOrExpression_logicalAnd = Core.Name "logicalAnd"+_LogicalOrExpression_logicalOr = Core.Name "logicalOr"+data LogicalOrOperation =+  LogicalOrOperation {+    logicalOrOperationLeft :: LogicalOrExpression,+    logicalOrOperationRight :: LogicalAndExpression}+  deriving (Eq, Ord, Read, Show)+_LogicalOrOperation = Core.Name "hydra.cpp.syntax.LogicalOrOperation"+_LogicalOrOperation_left = Core.Name "left"+_LogicalOrOperation_right = Core.Name "right"+data LogicalAndExpression =+  LogicalAndExpressionInclusiveOr InclusiveOrExpression |+  LogicalAndExpressionLogicalAnd LogicalAndOperation+  deriving (Eq, Ord, Read, Show)+_LogicalAndExpression = Core.Name "hydra.cpp.syntax.LogicalAndExpression"+_LogicalAndExpression_inclusiveOr = Core.Name "inclusiveOr"+_LogicalAndExpression_logicalAnd = Core.Name "logicalAnd"+data LogicalAndOperation =+  LogicalAndOperation {+    logicalAndOperationLeft :: LogicalAndExpression,+    logicalAndOperationRight :: InclusiveOrExpression}+  deriving (Eq, Ord, Read, Show)+_LogicalAndOperation = Core.Name "hydra.cpp.syntax.LogicalAndOperation"+_LogicalAndOperation_left = Core.Name "left"+_LogicalAndOperation_right = Core.Name "right"+data InclusiveOrExpression =+  InclusiveOrExpressionExclusiveOr ExclusiveOrExpression |+  InclusiveOrExpressionBitwiseOr BitwiseOrOperation+  deriving (Eq, Ord, Read, Show)+_InclusiveOrExpression = Core.Name "hydra.cpp.syntax.InclusiveOrExpression"+_InclusiveOrExpression_exclusiveOr = Core.Name "exclusiveOr"+_InclusiveOrExpression_bitwiseOr = Core.Name "bitwiseOr"+data BitwiseOrOperation =+  BitwiseOrOperation {+    bitwiseOrOperationLeft :: InclusiveOrExpression,+    bitwiseOrOperationRight :: ExclusiveOrExpression}+  deriving (Eq, Ord, Read, Show)+_BitwiseOrOperation = Core.Name "hydra.cpp.syntax.BitwiseOrOperation"+_BitwiseOrOperation_left = Core.Name "left"+_BitwiseOrOperation_right = Core.Name "right"+data ExclusiveOrExpression =+  ExclusiveOrExpressionAnd AndExpression |+  ExclusiveOrExpressionBitwiseXor BitwiseXorOperation+  deriving (Eq, Ord, Read, Show)+_ExclusiveOrExpression = Core.Name "hydra.cpp.syntax.ExclusiveOrExpression"+_ExclusiveOrExpression_and = Core.Name "and"+_ExclusiveOrExpression_bitwiseXor = Core.Name "bitwiseXor"+data BitwiseXorOperation =+  BitwiseXorOperation {+    bitwiseXorOperationLeft :: ExclusiveOrExpression,+    bitwiseXorOperationRight :: AndExpression}+  deriving (Eq, Ord, Read, Show)+_BitwiseXorOperation = Core.Name "hydra.cpp.syntax.BitwiseXorOperation"+_BitwiseXorOperation_left = Core.Name "left"+_BitwiseXorOperation_right = Core.Name "right"+data AndExpression =+  AndExpressionEquality EqualityExpression |+  AndExpressionBitwiseAnd BitwiseAndOperation+  deriving (Eq, Ord, Read, Show)+_AndExpression = Core.Name "hydra.cpp.syntax.AndExpression"+_AndExpression_equality = Core.Name "equality"+_AndExpression_bitwiseAnd = Core.Name "bitwiseAnd"+data BitwiseAndOperation =+  BitwiseAndOperation {+    bitwiseAndOperationLeft :: AndExpression,+    bitwiseAndOperationRight :: EqualityExpression}+  deriving (Eq, Ord, Read, Show)+_BitwiseAndOperation = Core.Name "hydra.cpp.syntax.BitwiseAndOperation"+_BitwiseAndOperation_left = Core.Name "left"+_BitwiseAndOperation_right = Core.Name "right"+data EqualityExpression =+  EqualityExpressionRelational RelationalExpression |+  EqualityExpressionEqual EqualOperation |+  EqualityExpressionNotEqual NotEqualOperation+  deriving (Eq, Ord, Read, Show)+_EqualityExpression = Core.Name "hydra.cpp.syntax.EqualityExpression"+_EqualityExpression_relational = Core.Name "relational"+_EqualityExpression_equal = Core.Name "equal"+_EqualityExpression_notEqual = Core.Name "notEqual"+data EqualOperation =+  EqualOperation {+    equalOperationLeft :: EqualityExpression,+    equalOperationRight :: RelationalExpression}+  deriving (Eq, Ord, Read, Show)+_EqualOperation = Core.Name "hydra.cpp.syntax.EqualOperation"+_EqualOperation_left = Core.Name "left"+_EqualOperation_right = Core.Name "right"+data NotEqualOperation =+  NotEqualOperation {+    notEqualOperationLeft :: EqualityExpression,+    notEqualOperationRight :: RelationalExpression}+  deriving (Eq, Ord, Read, Show)+_NotEqualOperation = Core.Name "hydra.cpp.syntax.NotEqualOperation"+_NotEqualOperation_left = Core.Name "left"+_NotEqualOperation_right = Core.Name "right"+data RelationalExpression =+  RelationalExpressionShift ShiftExpression |+  RelationalExpressionLess LessOperation |+  RelationalExpressionGreater GreaterOperation |+  RelationalExpressionLessEqual LessEqualOperation |+  RelationalExpressionGreaterEqual GreaterEqualOperation+  deriving (Eq, Ord, Read, Show)+_RelationalExpression = Core.Name "hydra.cpp.syntax.RelationalExpression"+_RelationalExpression_shift = Core.Name "shift"+_RelationalExpression_less = Core.Name "less"+_RelationalExpression_greater = Core.Name "greater"+_RelationalExpression_lessEqual = Core.Name "lessEqual"+_RelationalExpression_greaterEqual = Core.Name "greaterEqual"+data LessOperation =+  LessOperation {+    lessOperationLeft :: RelationalExpression,+    lessOperationRight :: ShiftExpression}+  deriving (Eq, Ord, Read, Show)+_LessOperation = Core.Name "hydra.cpp.syntax.LessOperation"+_LessOperation_left = Core.Name "left"+_LessOperation_right = Core.Name "right"+data GreaterOperation =+  GreaterOperation {+    greaterOperationLeft :: RelationalExpression,+    greaterOperationRight :: ShiftExpression}+  deriving (Eq, Ord, Read, Show)+_GreaterOperation = Core.Name "hydra.cpp.syntax.GreaterOperation"+_GreaterOperation_left = Core.Name "left"+_GreaterOperation_right = Core.Name "right"+data LessEqualOperation =+  LessEqualOperation {+    lessEqualOperationLeft :: RelationalExpression,+    lessEqualOperationRight :: ShiftExpression}+  deriving (Eq, Ord, Read, Show)+_LessEqualOperation = Core.Name "hydra.cpp.syntax.LessEqualOperation"+_LessEqualOperation_left = Core.Name "left"+_LessEqualOperation_right = Core.Name "right"+data GreaterEqualOperation =+  GreaterEqualOperation {+    greaterEqualOperationLeft :: RelationalExpression,+    greaterEqualOperationRight :: ShiftExpression}+  deriving (Eq, Ord, Read, Show)+_GreaterEqualOperation = Core.Name "hydra.cpp.syntax.GreaterEqualOperation"+_GreaterEqualOperation_left = Core.Name "left"+_GreaterEqualOperation_right = Core.Name "right"+data ShiftExpression =+  ShiftExpressionAdditive AdditiveExpression |+  ShiftExpressionLeftShift LeftShiftOperation |+  ShiftExpressionRightShift RightShiftOperation+  deriving (Eq, Ord, Read, Show)+_ShiftExpression = Core.Name "hydra.cpp.syntax.ShiftExpression"+_ShiftExpression_additive = Core.Name "additive"+_ShiftExpression_leftShift = Core.Name "leftShift"+_ShiftExpression_rightShift = Core.Name "rightShift"+data LeftShiftOperation =+  LeftShiftOperation {+    leftShiftOperationLeft :: ShiftExpression,+    leftShiftOperationRight :: AdditiveExpression}+  deriving (Eq, Ord, Read, Show)+_LeftShiftOperation = Core.Name "hydra.cpp.syntax.LeftShiftOperation"+_LeftShiftOperation_left = Core.Name "left"+_LeftShiftOperation_right = Core.Name "right"+data RightShiftOperation =+  RightShiftOperation {+    rightShiftOperationLeft :: ShiftExpression,+    rightShiftOperationRight :: AdditiveExpression}+  deriving (Eq, Ord, Read, Show)+_RightShiftOperation = Core.Name "hydra.cpp.syntax.RightShiftOperation"+_RightShiftOperation_left = Core.Name "left"+_RightShiftOperation_right = Core.Name "right"+data AdditiveExpression =+  AdditiveExpressionMultiplicative MultiplicativeExpression |+  AdditiveExpressionAdd AddOperation |+  AdditiveExpressionSubtract SubtractOperation+  deriving (Eq, Ord, Read, Show)+_AdditiveExpression = Core.Name "hydra.cpp.syntax.AdditiveExpression"+_AdditiveExpression_multiplicative = Core.Name "multiplicative"+_AdditiveExpression_add = Core.Name "add"+_AdditiveExpression_subtract = Core.Name "subtract"+data AddOperation =+  AddOperation {+    addOperationLeft :: AdditiveExpression,+    addOperationRight :: MultiplicativeExpression}+  deriving (Eq, Ord, Read, Show)+_AddOperation = Core.Name "hydra.cpp.syntax.AddOperation"+_AddOperation_left = Core.Name "left"+_AddOperation_right = Core.Name "right"+data SubtractOperation =+  SubtractOperation {+    subtractOperationLeft :: AdditiveExpression,+    subtractOperationRight :: MultiplicativeExpression}+  deriving (Eq, Ord, Read, Show)+_SubtractOperation = Core.Name "hydra.cpp.syntax.SubtractOperation"+_SubtractOperation_left = Core.Name "left"+_SubtractOperation_right = Core.Name "right"+data MultiplicativeExpression =+  MultiplicativeExpressionUnary UnaryExpression |+  MultiplicativeExpressionMultiply MultiplyOperation |+  MultiplicativeExpressionDivide DivideOperation |+  MultiplicativeExpressionModulo ModuloOperation+  deriving (Eq, Ord, Read, Show)+_MultiplicativeExpression = Core.Name "hydra.cpp.syntax.MultiplicativeExpression"+_MultiplicativeExpression_unary = Core.Name "unary"+_MultiplicativeExpression_multiply = Core.Name "multiply"+_MultiplicativeExpression_divide = Core.Name "divide"+_MultiplicativeExpression_modulo = Core.Name "modulo"+data MultiplyOperation =+  MultiplyOperation {+    multiplyOperationLeft :: MultiplicativeExpression,+    multiplyOperationRight :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_MultiplyOperation = Core.Name "hydra.cpp.syntax.MultiplyOperation"+_MultiplyOperation_left = Core.Name "left"+_MultiplyOperation_right = Core.Name "right"+data DivideOperation =+  DivideOperation {+    divideOperationLeft :: MultiplicativeExpression,+    divideOperationRight :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_DivideOperation = Core.Name "hydra.cpp.syntax.DivideOperation"+_DivideOperation_left = Core.Name "left"+_DivideOperation_right = Core.Name "right"+data ModuloOperation =+  ModuloOperation {+    moduloOperationLeft :: MultiplicativeExpression,+    moduloOperationRight :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_ModuloOperation = Core.Name "hydra.cpp.syntax.ModuloOperation"+_ModuloOperation_left = Core.Name "left"+_ModuloOperation_right = Core.Name "right"+data UnaryExpression =+  UnaryExpressionPostfix PostfixExpression |+  UnaryExpressionUnaryOp UnaryOperation |+  UnaryExpressionSizeof SizeofExpression+  deriving (Eq, Ord, Read, Show)+_UnaryExpression = Core.Name "hydra.cpp.syntax.UnaryExpression"+_UnaryExpression_postfix = Core.Name "postfix"+_UnaryExpression_unaryOp = Core.Name "unaryOp"+_UnaryExpression_sizeof = Core.Name "sizeof"+data UnaryOperation =+  UnaryOperation {+    unaryOperationOperator :: UnaryOperator,+    unaryOperationOperand :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_UnaryOperation = Core.Name "hydra.cpp.syntax.UnaryOperation"+_UnaryOperation_operator = Core.Name "operator"+_UnaryOperation_operand = Core.Name "operand"+data UnaryOperator =+  UnaryOperatorPlus |+  UnaryOperatorMinus |+  UnaryOperatorLogicalNot |+  UnaryOperatorBitwiseNot |+  UnaryOperatorDereference |+  UnaryOperatorAddressOf |+  UnaryOperatorPreIncrement |+  UnaryOperatorPreDecrement+  deriving (Eq, Ord, Read, Show)+_UnaryOperator = Core.Name "hydra.cpp.syntax.UnaryOperator"+_UnaryOperator_plus = Core.Name "plus"+_UnaryOperator_minus = Core.Name "minus"+_UnaryOperator_logicalNot = Core.Name "logicalNot"+_UnaryOperator_bitwiseNot = Core.Name "bitwiseNot"+_UnaryOperator_dereference = Core.Name "dereference"+_UnaryOperator_addressOf = Core.Name "addressOf"+_UnaryOperator_preIncrement = Core.Name "preIncrement"+_UnaryOperator_preDecrement = Core.Name "preDecrement"+newtype SizeofExpression =+  SizeofExpression {+    unSizeofExpression :: TypeExpression}+  deriving (Eq, Ord, Read, Show)+_SizeofExpression = Core.Name "hydra.cpp.syntax.SizeofExpression"+data PostfixExpression =+  PostfixExpressionPrimary PrimaryExpression |+  PostfixExpressionSubscript SubscriptOperation |+  PostfixExpressionFunctionCall FunctionCallOperation |+  PostfixExpressionTemplateFunctionCall TemplateFunctionCallOperation |+  PostfixExpressionMemberAccess MemberAccessOperation |+  PostfixExpressionPointerMemberAccess PointerMemberAccessOperation |+  PostfixExpressionPostIncrement PostfixExpression |+  PostfixExpressionPostDecrement PostfixExpression+  deriving (Eq, Ord, Read, Show)+_PostfixExpression = Core.Name "hydra.cpp.syntax.PostfixExpression"+_PostfixExpression_primary = Core.Name "primary"+_PostfixExpression_subscript = Core.Name "subscript"+_PostfixExpression_functionCall = Core.Name "functionCall"+_PostfixExpression_templateFunctionCall = Core.Name "templateFunctionCall"+_PostfixExpression_memberAccess = Core.Name "memberAccess"+_PostfixExpression_pointerMemberAccess = Core.Name "pointerMemberAccess"+_PostfixExpression_postIncrement = Core.Name "postIncrement"+_PostfixExpression_postDecrement = Core.Name "postDecrement"+data SubscriptOperation =+  SubscriptOperation {+    subscriptOperationArray :: PostfixExpression,+    subscriptOperationIndex :: Expression}+  deriving (Eq, Ord, Read, Show)+_SubscriptOperation = Core.Name "hydra.cpp.syntax.SubscriptOperation"+_SubscriptOperation_array = Core.Name "array"+_SubscriptOperation_index = Core.Name "index"+data FunctionCallOperation =+  FunctionCallOperation {+    functionCallOperationFunction :: PostfixExpression,+    functionCallOperationArguments :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_FunctionCallOperation = Core.Name "hydra.cpp.syntax.FunctionCallOperation"+_FunctionCallOperation_function = Core.Name "function"+_FunctionCallOperation_arguments = Core.Name "arguments"+data MemberAccessOperation =+  MemberAccessOperation {+    memberAccessOperationObject :: PostfixExpression,+    memberAccessOperationMember :: String}+  deriving (Eq, Ord, Read, Show)+_MemberAccessOperation = Core.Name "hydra.cpp.syntax.MemberAccessOperation"+_MemberAccessOperation_object = Core.Name "object"+_MemberAccessOperation_member = Core.Name "member"+data PointerMemberAccessOperation =+  PointerMemberAccessOperation {+    pointerMemberAccessOperationPointer :: PostfixExpression,+    pointerMemberAccessOperationMember :: String}+  deriving (Eq, Ord, Read, Show)+_PointerMemberAccessOperation = Core.Name "hydra.cpp.syntax.PointerMemberAccessOperation"+_PointerMemberAccessOperation_pointer = Core.Name "pointer"+_PointerMemberAccessOperation_member = Core.Name "member"+data TemplateFunctionCallOperation =+  TemplateFunctionCallOperation {+    templateFunctionCallOperationFunction :: PostfixExpression,+    templateFunctionCallOperationTemplateArguments :: [TemplateArgument],+    templateFunctionCallOperationArguments :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_TemplateFunctionCallOperation = Core.Name "hydra.cpp.syntax.TemplateFunctionCallOperation"+_TemplateFunctionCallOperation_function = Core.Name "function"+_TemplateFunctionCallOperation_templateArguments = Core.Name "templateArguments"+_TemplateFunctionCallOperation_arguments = Core.Name "arguments"+data PrimaryExpression =+  PrimaryExpressionIdentifier String |+  PrimaryExpressionLiteral Literal |+  PrimaryExpressionParenthesized Expression |+  PrimaryExpressionLambda LambdaExpression+  deriving (Eq, Ord, Read, Show)+_PrimaryExpression = Core.Name "hydra.cpp.syntax.PrimaryExpression"+_PrimaryExpression_identifier = Core.Name "identifier"+_PrimaryExpression_literal = Core.Name "literal"+_PrimaryExpression_parenthesized = Core.Name "parenthesized"+_PrimaryExpression_lambda = Core.Name "lambda"+data LambdaExpression =+  LambdaExpression {+    lambdaExpressionCaptures :: CaptureList,+    lambdaExpressionParameters :: [Parameter],+    lambdaExpressionReturnType :: (Maybe TypeExpression),+    lambdaExpressionBody :: CompoundStatement}+  deriving (Eq, Ord, Read, Show)+_LambdaExpression = Core.Name "hydra.cpp.syntax.LambdaExpression"+_LambdaExpression_captures = Core.Name "captures"+_LambdaExpression_parameters = Core.Name "parameters"+_LambdaExpression_returnType = Core.Name "returnType"+_LambdaExpression_body = Core.Name "body"+data CaptureList =+  CaptureListCaptureByValue |+  CaptureListCaptures [Capture]+  deriving (Eq, Ord, Read, Show)+_CaptureList = Core.Name "hydra.cpp.syntax.CaptureList"+_CaptureList_captureByValue = Core.Name "captureByValue"+_CaptureList_captures = Core.Name "captures"+data Capture =+  Capture {+    captureName :: String,+    captureByReference :: Bool}+  deriving (Eq, Ord, Read, Show)+_Capture = Core.Name "hydra.cpp.syntax.Capture"+_Capture_name = Core.Name "name"+_Capture_byReference = Core.Name "byReference"+data PatternMatch =+  PatternMatch {+    patternMatchVisitor :: Visitor,+    patternMatchVariant :: Expression}+  deriving (Eq, Ord, Read, Show)+_PatternMatch = Core.Name "hydra.cpp.syntax.PatternMatch"+_PatternMatch_visitor = Core.Name "visitor"+_PatternMatch_variant = Core.Name "variant"+data Visitor =+  VisitorLambda LambdaExpression |+  VisitorOverloaded OverloadedLambdas+  deriving (Eq, Ord, Read, Show)+_Visitor = Core.Name "hydra.cpp.syntax.Visitor"+_Visitor_lambda = Core.Name "lambda"+_Visitor_overloaded = Core.Name "overloaded"+newtype OverloadedLambdas =+  OverloadedLambdas {+    unOverloadedLambdas :: [LambdaExpression]}+  deriving (Eq, Ord, Read, Show)+_OverloadedLambdas = Core.Name "hydra.cpp.syntax.OverloadedLambdas"+data FunctionApplication =+  FunctionApplication {+    functionApplicationFunction :: FunctionIdentifier,+    functionApplicationArguments :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_FunctionApplication = Core.Name "hydra.cpp.syntax.FunctionApplication"+_FunctionApplication_function = Core.Name "function"+_FunctionApplication_arguments = Core.Name "arguments"+data FunctionIdentifier =+  FunctionIdentifierSimple String |+  FunctionIdentifierQualified QualifiedIdentifier+  deriving (Eq, Ord, Read, Show)+_FunctionIdentifier = Core.Name "hydra.cpp.syntax.FunctionIdentifier"+_FunctionIdentifier_simple = Core.Name "simple"+_FunctionIdentifier_qualified = Core.Name "qualified"+data QualifiedIdentifier =+  QualifiedIdentifier {+    qualifiedIdentifierNamespace :: String,+    qualifiedIdentifierName :: String}+  deriving (Eq, Ord, Read, Show)+_QualifiedIdentifier = Core.Name "hydra.cpp.syntax.QualifiedIdentifier"+_QualifiedIdentifier_namespace = Core.Name "namespace"+_QualifiedIdentifier_name = Core.Name "name"+data Statement =+  StatementLabeled LabeledStatement |+  StatementCompound CompoundStatement |+  StatementSelection SelectionStatement |+  StatementSwitch SwitchStatement |+  StatementIteration IterationStatement |+  StatementJump JumpStatement |+  StatementDeclaration VariableDeclaration |+  StatementExpression Expression+  deriving (Eq, Ord, Read, Show)+_Statement = Core.Name "hydra.cpp.syntax.Statement"+_Statement_labeled = Core.Name "labeled"+_Statement_compound = Core.Name "compound"+_Statement_selection = Core.Name "selection"+_Statement_switch = Core.Name "switch"+_Statement_iteration = Core.Name "iteration"+_Statement_jump = Core.Name "jump"+_Statement_declaration = Core.Name "declaration"+_Statement_expression = Core.Name "expression"+data LabeledStatement =+  LabeledStatement {+    labeledStatementLabel :: String,+    labeledStatementStatement :: Statement}+  deriving (Eq, Ord, Read, Show)+_LabeledStatement = Core.Name "hydra.cpp.syntax.LabeledStatement"+_LabeledStatement_label = Core.Name "label"+_LabeledStatement_statement = Core.Name "statement"+newtype CompoundStatement =+  CompoundStatement {+    unCompoundStatement :: [Statement]}+  deriving (Eq, Ord, Read, Show)+_CompoundStatement = Core.Name "hydra.cpp.syntax.CompoundStatement"+data SelectionStatement =+  SelectionStatement {+    selectionStatementCondition :: Expression,+    selectionStatementThenBranch :: Statement,+    selectionStatementElseBranch :: (Maybe Statement)}+  deriving (Eq, Ord, Read, Show)+_SelectionStatement = Core.Name "hydra.cpp.syntax.SelectionStatement"+_SelectionStatement_condition = Core.Name "condition"+_SelectionStatement_thenBranch = Core.Name "thenBranch"+_SelectionStatement_elseBranch = Core.Name "elseBranch"+data SwitchStatement =+  SwitchStatement {+    switchStatementValue :: Expression,+    switchStatementCases :: [CaseStatement]}+  deriving (Eq, Ord, Read, Show)+_SwitchStatement = Core.Name "hydra.cpp.syntax.SwitchStatement"+_SwitchStatement_value = Core.Name "value"+_SwitchStatement_cases = Core.Name "cases"+data CaseStatement =+  CaseStatementCase CaseValue |+  CaseStatementDefault Statement+  deriving (Eq, Ord, Read, Show)+_CaseStatement = Core.Name "hydra.cpp.syntax.CaseStatement"+_CaseStatement_case = Core.Name "case"+_CaseStatement_default = Core.Name "default"+data CaseValue =+  CaseValue {+    caseValueValue :: Expression,+    caseValueStatement :: Statement}+  deriving (Eq, Ord, Read, Show)+_CaseValue = Core.Name "hydra.cpp.syntax.CaseValue"+_CaseValue_value = Core.Name "value"+_CaseValue_statement = Core.Name "statement"+data IterationStatement =+  IterationStatementWhile WhileStatement |+  IterationStatementDo DoStatement |+  IterationStatementFor ForStatement |+  IterationStatementRangeFor RangeForStatement+  deriving (Eq, Ord, Read, Show)+_IterationStatement = Core.Name "hydra.cpp.syntax.IterationStatement"+_IterationStatement_while = Core.Name "while"+_IterationStatement_do = Core.Name "do"+_IterationStatement_for = Core.Name "for"+_IterationStatement_rangeFor = Core.Name "rangeFor"+data WhileStatement =+  WhileStatement {+    whileStatementCondition :: Expression,+    whileStatementBody :: Statement}+  deriving (Eq, Ord, Read, Show)+_WhileStatement = Core.Name "hydra.cpp.syntax.WhileStatement"+_WhileStatement_condition = Core.Name "condition"+_WhileStatement_body = Core.Name "body"+data DoStatement =+  DoStatement {+    doStatementBody :: Statement,+    doStatementCondition :: Expression}+  deriving (Eq, Ord, Read, Show)+_DoStatement = Core.Name "hydra.cpp.syntax.DoStatement"+_DoStatement_body = Core.Name "body"+_DoStatement_condition = Core.Name "condition"+data ForStatement =+  ForStatement {+    forStatementInit :: ForInit,+    forStatementCondition :: Expression,+    forStatementIncrement :: Expression,+    forStatementBody :: Statement}+  deriving (Eq, Ord, Read, Show)+_ForStatement = Core.Name "hydra.cpp.syntax.ForStatement"+_ForStatement_init = Core.Name "init"+_ForStatement_condition = Core.Name "condition"+_ForStatement_increment = Core.Name "increment"+_ForStatement_body = Core.Name "body"+data ForInit =+  ForInitExpression Expression |+  ForInitDeclaration VariableDeclaration |+  ForInitEmpty+  deriving (Eq, Ord, Read, Show)+_ForInit = Core.Name "hydra.cpp.syntax.ForInit"+_ForInit_expression = Core.Name "expression"+_ForInit_declaration = Core.Name "declaration"+_ForInit_empty = Core.Name "empty"+data RangeForStatement =+  RangeForStatement {+    rangeForStatementType :: TypeExpression,+    rangeForStatementVariable :: String,+    rangeForStatementRange :: Expression,+    rangeForStatementBody :: Statement}+  deriving (Eq, Ord, Read, Show)+_RangeForStatement = Core.Name "hydra.cpp.syntax.RangeForStatement"+_RangeForStatement_type = Core.Name "type"+_RangeForStatement_variable = Core.Name "variable"+_RangeForStatement_range = Core.Name "range"+_RangeForStatement_body = Core.Name "body"+data JumpStatement =+  JumpStatementBreak |+  JumpStatementContinue |+  JumpStatementReturnValue Expression |+  JumpStatementReturnVoid |+  JumpStatementThrow Expression+  deriving (Eq, Ord, Read, Show)+_JumpStatement = Core.Name "hydra.cpp.syntax.JumpStatement"+_JumpStatement_break = Core.Name "break"+_JumpStatement_continue = Core.Name "continue"+_JumpStatement_returnValue = Core.Name "returnValue"+_JumpStatement_returnVoid = Core.Name "returnVoid"+_JumpStatement_throw = Core.Name "throw"+newtype ExpressionStatement =+  ExpressionStatement {+    unExpressionStatement :: Expression}+  deriving (Eq, Ord, Read, Show)+_ExpressionStatement = Core.Name "hydra.cpp.syntax.ExpressionStatement"+data TypeExpression =+  TypeExpressionBasic BasicType |+  TypeExpressionQualified QualifiedType |+  TypeExpressionTemplate TemplateType |+  TypeExpressionFunction FunctionType |+  TypeExpressionAuto+  deriving (Eq, Ord, Read, Show)+_TypeExpression = Core.Name "hydra.cpp.syntax.TypeExpression"+_TypeExpression_basic = Core.Name "basic"+_TypeExpression_qualified = Core.Name "qualified"+_TypeExpression_template = Core.Name "template"+_TypeExpression_function = Core.Name "function"+_TypeExpression_auto = Core.Name "auto"+data BasicType =+  BasicTypeVoid |+  BasicTypeBool |+  BasicTypeChar |+  BasicTypeInt |+  BasicTypeFloat |+  BasicTypeDouble |+  BasicTypeString |+  BasicTypeAuto |+  BasicTypeNamed String+  deriving (Eq, Ord, Read, Show)+_BasicType = Core.Name "hydra.cpp.syntax.BasicType"+_BasicType_void = Core.Name "void"+_BasicType_bool = Core.Name "bool"+_BasicType_char = Core.Name "char"+_BasicType_int = Core.Name "int"+_BasicType_float = Core.Name "float"+_BasicType_double = Core.Name "double"+_BasicType_string = Core.Name "string"+_BasicType_auto = Core.Name "auto"+_BasicType_named = Core.Name "named"+data QualifiedType =+  QualifiedType {+    qualifiedTypeBaseType :: TypeExpression,+    qualifiedTypeQualifier :: TypeQualifier}+  deriving (Eq, Ord, Read, Show)+_QualifiedType = Core.Name "hydra.cpp.syntax.QualifiedType"+_QualifiedType_baseType = Core.Name "baseType"+_QualifiedType_qualifier = Core.Name "qualifier"+data TypeQualifier =+  TypeQualifierConst |+  TypeQualifierLvalueRef |+  TypeQualifierRvalueRef |+  TypeQualifierPointer+  deriving (Eq, Ord, Read, Show)+_TypeQualifier = Core.Name "hydra.cpp.syntax.TypeQualifier"+_TypeQualifier_const = Core.Name "const"+_TypeQualifier_lvalueRef = Core.Name "lvalueRef"+_TypeQualifier_rvalueRef = Core.Name "rvalueRef"+_TypeQualifier_pointer = Core.Name "pointer"+data TemplateType =+  TemplateType {+    templateTypeName :: String,+    templateTypeArguments :: [TemplateArgument]}+  deriving (Eq, Ord, Read, Show)+_TemplateType = Core.Name "hydra.cpp.syntax.TemplateType"+_TemplateType_name = Core.Name "name"+_TemplateType_arguments = Core.Name "arguments"+data TemplateArgument =+  TemplateArgumentType TypeExpression |+  TemplateArgumentValue Expression+  deriving (Eq, Ord, Read, Show)+_TemplateArgument = Core.Name "hydra.cpp.syntax.TemplateArgument"+_TemplateArgument_type = Core.Name "type"+_TemplateArgument_value = Core.Name "value"+data FunctionType =+  FunctionType {+    functionTypeReturnType :: TypeExpression,+    functionTypeParameters :: [Parameter]}+  deriving (Eq, Ord, Read, Show)+_FunctionType = Core.Name "hydra.cpp.syntax.FunctionType"+_FunctionType_returnType = Core.Name "returnType"+_FunctionType_parameters = Core.Name "parameters"+data Literal =+  LiteralInteger IntegerLiteral |+  LiteralFloating FloatingLiteral |+  LiteralCharacter CharacterLiteral |+  LiteralString StringLiteral |+  LiteralBoolean BooleanLiteral |+  LiteralNull+  deriving (Eq, Ord, Read, Show)+_Literal = Core.Name "hydra.cpp.syntax.Literal"+_Literal_integer = Core.Name "integer"+_Literal_floating = Core.Name "floating"+_Literal_character = Core.Name "character"+_Literal_string = Core.Name "string"+_Literal_boolean = Core.Name "boolean"+_Literal_null = Core.Name "null"+data IntegerLiteral =+  IntegerLiteralDecimal Integer |+  IntegerLiteralHexadecimal String |+  IntegerLiteralOctal String |+  IntegerLiteralBinary String+  deriving (Eq, Ord, Read, Show)+_IntegerLiteral = Core.Name "hydra.cpp.syntax.IntegerLiteral"+_IntegerLiteral_decimal = Core.Name "decimal"+_IntegerLiteral_hexadecimal = Core.Name "hexadecimal"+_IntegerLiteral_octal = Core.Name "octal"+_IntegerLiteral_binary = Core.Name "binary"+newtype FloatingLiteral =+  FloatingLiteral {+    unFloatingLiteral :: Double}+  deriving (Eq, Ord, Read, Show)+_FloatingLiteral = Core.Name "hydra.cpp.syntax.FloatingLiteral"+newtype CharacterLiteral =+  CharacterLiteral {+    unCharacterLiteral :: String}+  deriving (Eq, Ord, Read, Show)+_CharacterLiteral = Core.Name "hydra.cpp.syntax.CharacterLiteral"+newtype StringLiteral =+  StringLiteral {+    unStringLiteral :: String}+  deriving (Eq, Ord, Read, Show)+_StringLiteral = Core.Name "hydra.cpp.syntax.StringLiteral"+newtype BooleanLiteral =+  BooleanLiteral {+    unBooleanLiteral :: Bool}+  deriving (Eq, Ord, Read, Show)+_BooleanLiteral = Core.Name "hydra.cpp.syntax.BooleanLiteral"+data Vector =+  Vector {+    vectorElementType :: TypeExpression,+    vectorElements :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_Vector = Core.Name "hydra.cpp.syntax.Vector"+_Vector_elementType = Core.Name "elementType"+_Vector_elements = Core.Name "elements"+data Map =+  Map {+    mapKeyType :: TypeExpression,+    mapValueType :: TypeExpression,+    mapEntries :: [MapEntry]}+  deriving (Eq, Ord, Read, Show)+_Map = Core.Name "hydra.cpp.syntax.Map"+_Map_keyType = Core.Name "keyType"+_Map_valueType = Core.Name "valueType"+_Map_entries = Core.Name "entries"+data MapEntry =+  MapEntry {+    mapEntryKey :: Expression,+    mapEntryValue :: Expression}+  deriving (Eq, Ord, Read, Show)+_MapEntry = Core.Name "hydra.cpp.syntax.MapEntry"+_MapEntry_key = Core.Name "key"+_MapEntry_value = Core.Name "value"+data Set =+  Set {+    setElementType :: TypeExpression,+    setElements :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_Set = Core.Name "hydra.cpp.syntax.Set"+_Set_elementType = Core.Name "elementType"+_Set_elements = Core.Name "elements"+data Optional =+  Optional {+    optionalValueType :: TypeExpression,+    optionalValue :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_Optional = Core.Name "hydra.cpp.syntax.Optional"+_Optional_valueType = Core.Name "valueType"+_Optional_value = Core.Name "value"+type Identifier = String+_Identifier = Core.Name "hydra.cpp.syntax.Identifier"+data Comment =+  Comment {+    commentText :: String,+    commentIsMultiline :: Bool}+  deriving (Eq, Ord, Read, Show)+_Comment = Core.Name "hydra.cpp.syntax.Comment"+_Comment_text = Core.Name "text"+_Comment_isMultiline = Core.Name "isMultiline"+data BinaryOperator =+  BinaryOperatorPlus |+  BinaryOperatorMinus |+  BinaryOperatorMultiply |+  BinaryOperatorDivide |+  BinaryOperatorModulo |+  BinaryOperatorBitwiseAnd |+  BinaryOperatorBitwiseOr |+  BinaryOperatorBitwiseXor |+  BinaryOperatorLogicalAnd |+  BinaryOperatorLogicalOr |+  BinaryOperatorEqual |+  BinaryOperatorNotEqual |+  BinaryOperatorLess |+  BinaryOperatorGreater |+  BinaryOperatorLessEqual |+  BinaryOperatorGreaterEqual |+  BinaryOperatorLeftShift |+  BinaryOperatorRightShift+  deriving (Eq, Ord, Read, Show)+_BinaryOperator = Core.Name "hydra.cpp.syntax.BinaryOperator"+_BinaryOperator_plus = Core.Name "plus"+_BinaryOperator_minus = Core.Name "minus"+_BinaryOperator_multiply = Core.Name "multiply"+_BinaryOperator_divide = Core.Name "divide"+_BinaryOperator_modulo = Core.Name "modulo"+_BinaryOperator_bitwiseAnd = Core.Name "bitwiseAnd"+_BinaryOperator_bitwiseOr = Core.Name "bitwiseOr"+_BinaryOperator_bitwiseXor = Core.Name "bitwiseXor"+_BinaryOperator_logicalAnd = Core.Name "logicalAnd"+_BinaryOperator_logicalOr = Core.Name "logicalOr"+_BinaryOperator_equal = Core.Name "equal"+_BinaryOperator_notEqual = Core.Name "notEqual"+_BinaryOperator_less = Core.Name "less"+_BinaryOperator_greater = Core.Name "greater"+_BinaryOperator_lessEqual = Core.Name "lessEqual"+_BinaryOperator_greaterEqual = Core.Name "greaterEqual"+_BinaryOperator_leftShift = Core.Name "leftShift"+_BinaryOperator_rightShift = Core.Name "rightShift"
+ src/main/haskell/Hydra/Cpp/Utils.hs view
@@ -0,0 +1,259 @@+-- Note: this is an automatically generated file. Do not edit.+-- | C++ utilities for constructing C++ syntax trees++module Hydra.Cpp.Utils where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Cpp.Syntax as Syntax+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Create a const reference parameter+constParameter :: String -> Syntax.TypeExpression -> Syntax.Parameter+constParameter name typ =+    Syntax.Parameter {+      Syntax.parameterType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+        Syntax.qualifiedTypeBaseType = (Syntax.TypeExpressionQualified (Syntax.QualifiedType {+          Syntax.qualifiedTypeBaseType = typ,+          Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierConst})),+        Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierLvalueRef})),+      Syntax.parameterName = name,+      Syntax.parameterUnnamed = False,+      Syntax.parameterDefaultValue = Nothing}+-- | Create a C++ class declaration+cppClassDeclaration :: String -> [Syntax.BaseSpecifier] -> Maybe Syntax.ClassBody -> Syntax.Declaration+cppClassDeclaration name baseSpecs mbody =+    Syntax.DeclarationClass (Syntax.ClassDeclaration {+      Syntax.classDeclarationSpecifier = Syntax.ClassSpecifier {+        Syntax.classSpecifierKey = Syntax.ClassKeyClass,+        Syntax.classSpecifierName = name,+        Syntax.classSpecifierInheritance = baseSpecs},+      Syntax.classDeclarationBody = mbody})+-- | Create a C++ enum class declaration+cppEnumDeclaration :: String -> Maybe Syntax.ClassBody -> Syntax.Declaration+cppEnumDeclaration name mbody =+    Syntax.DeclarationClass (Syntax.ClassDeclaration {+      Syntax.classDeclarationSpecifier = Syntax.ClassSpecifier {+        Syntax.classSpecifierKey = Syntax.ClassKeyEnumClass,+        Syntax.classSpecifierName = name,+        Syntax.classSpecifierInheritance = []},+      Syntax.classDeclarationBody = mbody})+-- | Create a C++ enum class forward declaration+cppEnumForwardDeclaration :: String -> Syntax.Declaration+cppEnumForwardDeclaration name =+    Syntax.DeclarationClass (Syntax.ClassDeclaration {+      Syntax.classDeclarationSpecifier = Syntax.ClassSpecifier {+        Syntax.classSpecifierKey = Syntax.ClassKeyEnumClass,+        Syntax.classSpecifierName = name,+        Syntax.classSpecifierInheritance = []},+      Syntax.classDeclarationBody = Nothing})+-- | Convert a PostfixExpression to an Expression+cppPostfixExpressionToCppExpression :: Syntax.PostfixExpression -> Syntax.Expression+cppPostfixExpressionToCppExpression pf = cppUnaryExpressionToCppExpression (Syntax.UnaryExpressionPostfix pf)+-- | Convert a PrimaryExpression to an Expression+cppPrimaryExpressionToCppExpression :: Syntax.PrimaryExpression -> Syntax.Expression+cppPrimaryExpressionToCppExpression prim = cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary prim)+-- | Convert a UnaryExpression to an Expression+cppUnaryExpressionToCppExpression :: Syntax.UnaryExpression -> Syntax.Expression+cppUnaryExpressionToCppExpression ue =+    Syntax.ExpressionAssignment (Syntax.AssignmentExpressionConditional (Syntax.ConditionalExpressionLogicalOr (cppUnaryExpressionToCppLogicalOrExpression ue)))+-- | Convert a UnaryExpression to a LogicalOrExpression+cppUnaryExpressionToCppLogicalOrExpression :: Syntax.UnaryExpression -> Syntax.LogicalOrExpression+cppUnaryExpressionToCppLogicalOrExpression ue =+    Syntax.LogicalOrExpressionLogicalAnd (Syntax.LogicalAndExpressionInclusiveOr (Syntax.InclusiveOrExpressionExclusiveOr (Syntax.ExclusiveOrExpressionAnd (Syntax.AndExpressionEquality (Syntax.EqualityExpressionRelational (Syntax.RelationalExpressionShift (Syntax.ShiftExpressionAdditive (Syntax.AdditiveExpressionMultiplicative (Syntax.MultiplicativeExpressionUnary ue)))))))))+-- | Create a cast expression+createCastExpr :: t0 -> Syntax.Expression -> Syntax.Expression+createCastExpr targetType expr =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionParenthesized (cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionParenthesized expr)))+-- | Create a compound statement+createCompoundStmt :: [Syntax.Statement] -> Syntax.CompoundStatement+createCompoundStmt stmts = Syntax.CompoundStatement stmts+-- | Create a const reference type+createConstRefType :: Syntax.TypeExpression -> Syntax.TypeExpression+createConstRefType baseType = createReferenceType (createConstType baseType)+-- | Create a const-qualified type+createConstType :: Syntax.TypeExpression -> Syntax.TypeExpression+createConstType baseType = createQualifiedType baseType Syntax.TypeQualifierConst+-- | Create a constructor body (default if no params, empty otherwise)+createConstructorBody :: [t0] -> Syntax.FunctionBody+createConstructorBody params = Logic.ifElse (Lists.null params) Syntax.FunctionBodyDefault emptyFunctionBody+-- | Create an enum access expression+createEnumAccessExpr :: String -> String -> Syntax.Expression+createEnumAccessExpr enumName valueName =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionMemberAccess (Syntax.MemberAccessOperation {+      Syntax.memberAccessOperationObject = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier enumName)),+      Syntax.memberAccessOperationMember = valueName}))+-- | Create a function call expression+createFunctionCallExpr :: String -> [Syntax.Expression] -> Syntax.Expression+createFunctionCallExpr funcName args =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+      Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier funcName)),+      Syntax.functionCallOperationArguments = args}))+-- | Create a header file with pragma once+createHeaderFile :: [Syntax.IncludeDirective] -> [Syntax.Declaration] -> Syntax.Program+createHeaderFile includes decls =+    Syntax.Program {+      Syntax.programPreprocessorDirectives = [+        Syntax.PreprocessorDirectivePragma (Syntax.PragmaDirective {+          Syntax.pragmaDirectiveContent = "once"})],+      Syntax.programIncludes = includes,+      Syntax.programDeclarations = decls}+-- | Create an identifier expression+createIdentifierExpr :: String -> Syntax.Expression+createIdentifierExpr name = cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionIdentifier name)+-- | Create a lambda expression+createLambdaExpr :: [Syntax.Parameter] -> Syntax.Expression -> Syntax.Expression+createLambdaExpr params body =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionLambda (Syntax.LambdaExpression {+      Syntax.lambdaExpressionCaptures = (Syntax.CaptureListCaptures []),+      Syntax.lambdaExpressionParameters = params,+      Syntax.lambdaExpressionReturnType = Nothing,+      Syntax.lambdaExpressionBody = (Syntax.CompoundStatement [+        Syntax.StatementExpression body])})))+-- | Create a boolean literal expression+createLiteralBoolExpr :: Bool -> Syntax.Expression+createLiteralBoolExpr val =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralBoolean (Syntax.BooleanLiteral val)))+-- | Create an integer literal expression+createLiteralIntExpr :: Integer -> Syntax.Expression+createLiteralIntExpr val =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteralDecimal val)))+-- | Create a string literal expression+createLiteralStringExpr :: String -> Syntax.Expression+createLiteralStringExpr val =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralString (Syntax.StringLiteral val)))+-- | Create a member access expression+createMemberAccessExpr :: Syntax.Expression -> String -> Syntax.Expression+createMemberAccessExpr objExpr member =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionMemberAccess (Syntax.MemberAccessOperation {+      Syntax.memberAccessOperationObject = (extractPostfixExpression objExpr),+      Syntax.memberAccessOperationMember = member}))+-- | Create a qualified type with a qualifier+createQualifiedType :: Syntax.TypeExpression -> Syntax.TypeQualifier -> Syntax.TypeExpression+createQualifiedType baseType qualifier =+    Syntax.TypeExpressionQualified (Syntax.QualifiedType {+      Syntax.qualifiedTypeBaseType = baseType,+      Syntax.qualifiedTypeQualifier = qualifier})+-- | Create a reference type+createReferenceType :: Syntax.TypeExpression -> Syntax.TypeExpression+createReferenceType baseType = createQualifiedType baseType Syntax.TypeQualifierLvalueRef+-- | Create a return statement with a value+createReturnStmt :: Syntax.Expression -> Syntax.Statement+createReturnStmt expr = Syntax.StatementJump (Syntax.JumpStatementReturnValue expr)+-- | Create a void return statement+createReturnVoidStmt :: Syntax.Statement+createReturnVoidStmt = Syntax.StatementJump Syntax.JumpStatementReturnVoid+-- | Create a template type+createTemplateType :: String -> [Syntax.TypeExpression] -> Syntax.TypeExpression+createTemplateType name args =+    Syntax.TypeExpressionTemplate (Syntax.TemplateType {+      Syntax.templateTypeName = name,+      Syntax.templateTypeArguments = (Lists.map (\a -> Syntax.TemplateArgumentType a) args)})+-- | Create a *this expression+createThisExpr :: Syntax.Expression+createThisExpr =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "*this"))+-- | Create a throw statement+createThrowStmt :: String -> Syntax.Expression -> Syntax.Statement+createThrowStmt exceptionType arg =+    Syntax.StatementJump (Syntax.JumpStatementThrow (createFunctionCallExpr exceptionType [+      arg]))+-- | Create a typeid(...).name() call expression+createTypeIdNameCall :: Syntax.Expression+createTypeIdNameCall =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+      Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionMemberAccess (Syntax.MemberAccessOperation {+        Syntax.memberAccessOperationObject = (Syntax.PostfixExpressionFunctionCall (Syntax.FunctionCallOperation {+          Syntax.functionCallOperationFunction = (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "typeid")),+          Syntax.functionCallOperationArguments = [+            cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionParenthesized createThisExpr)]})),+        Syntax.memberAccessOperationMember = "name"})),+      Syntax.functionCallOperationArguments = []}))+-- | Create a type name expression+createTypeNameExpr :: String -> Syntax.Expression+createTypeNameExpr typeName =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier typeName))+-- | Create a variant expression+createVariantExpr :: Syntax.Expression+createVariantExpr =+    cppPostfixExpressionToCppExpression (Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "variant"))+-- | An empty function body+emptyFunctionBody :: Syntax.FunctionBody+emptyFunctionBody = Syntax.FunctionBodyCompound (Syntax.CompoundStatement [])+-- | Extract the PostfixExpression from a fully-wrapped Expression+extractPostfixExpression :: Syntax.Expression -> Syntax.PostfixExpression+extractPostfixExpression expr =+    case expr of+      Syntax.ExpressionAssignment v0 -> case v0 of+        Syntax.AssignmentExpressionConditional v1 -> case v1 of+          Syntax.ConditionalExpressionLogicalOr v2 -> case v2 of+            Syntax.LogicalOrExpressionLogicalAnd v3 -> case v3 of+              Syntax.LogicalAndExpressionInclusiveOr v4 -> case v4 of+                Syntax.InclusiveOrExpressionExclusiveOr v5 -> case v5 of+                  Syntax.ExclusiveOrExpressionAnd v6 -> case v6 of+                    Syntax.AndExpressionEquality v7 -> case v7 of+                      Syntax.EqualityExpressionRelational v8 -> case v8 of+                        Syntax.RelationalExpressionShift v9 -> case v9 of+                          Syntax.ShiftExpressionAdditive v10 -> case v10 of+                            Syntax.AdditiveExpressionMultiplicative v11 -> case v11 of+                              Syntax.MultiplicativeExpressionUnary v12 -> case v12 of+                                Syntax.UnaryExpressionPostfix v13 -> v13+                                _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                              _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                            _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                          _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                        _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                      _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                    _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                  _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+                _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+              _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+            _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+          _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+        _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+      _ -> Syntax.PostfixExpressionPrimary (Syntax.PrimaryExpressionIdentifier "error")+-- | Protected access specifier member specification+memberSpecificationProtected :: Syntax.MemberSpecification+memberSpecificationProtected = Syntax.MemberSpecificationAccessLabel Syntax.AccessSpecifierProtected+-- | Public access specifier member specification+memberSpecificationPublic :: Syntax.MemberSpecification+memberSpecificationPublic = Syntax.MemberSpecificationAccessLabel Syntax.AccessSpecifierPublic+-- | Create a string expression+stringExpression :: String -> Syntax.Expression+stringExpression s =+    cppPrimaryExpressionToCppExpression (Syntax.PrimaryExpressionLiteral (Syntax.LiteralString (Syntax.StringLiteral s)))+-- | Add const qualifier to a type+toConstType :: Syntax.TypeExpression -> Syntax.TypeExpression+toConstType baseType =+    Syntax.TypeExpressionQualified (Syntax.QualifiedType {+      Syntax.qualifiedTypeBaseType = baseType,+      Syntax.qualifiedTypeQualifier = Syntax.TypeQualifierConst})+-- | Create an unnamed parameter+unnamedParameter :: String -> Syntax.TypeExpression -> Syntax.Parameter+unnamedParameter name typ =+    Syntax.Parameter {+      Syntax.parameterType = typ,+      Syntax.parameterName = name,+      Syntax.parameterUnnamed = True,+      Syntax.parameterDefaultValue = Nothing}
+ src/main/haskell/Hydra/Csharp/Language.hs view
@@ -0,0 +1,219 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints and reserved words for C Sharp (C#)++module Hydra.Csharp.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | Language constraints for C Sharp (C#)+csharpLanguage :: Coders.Language+csharpLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.csharp"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt8,+          Core.IntegerTypeInt16,+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64,+          Core.IntegerTypeUint8,+          Core.IntegerTypeUint16,+          Core.IntegerTypeUint32,+          Core.IntegerTypeUint64]+    termVariants =+        Sets.fromList [+          Variants.TermVariantApplication,+          Variants.TermVariantCases,+          Variants.TermVariantLambda,+          Variants.TermVariantProject,+          Variants.TermVariantUnwrap,+          Variants.TermVariantTypeApplication,+          Variants.TermVariantTypeLambda,+          Variants.TermVariantLet,+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantRecord,+          Variants.TermVariantSet,+          Variants.TermVariantInject,+          Variants.TermVariantVariable,+          Variants.TermVariantWrap]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantApplication,+          Variants.TypeVariantFunction,+          Variants.TypeVariantForall,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantRecord,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnion,+          Variants.TypeVariantVariable,+          Variants.TypeVariantWrap]+    typePredicate = \_ -> True+-- | A set of reserved words in C#. Both the "keywords" and "contextual keywords" are drawn from section 6.4.4 of the C# documentation:+-- | https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#64-tokens+csharpReservedWords :: S.Set String+csharpReservedWords =+    Sets.fromList (Lists.concat [+      keywords,+      contextualKeywords])+  where+    keywords =+        [+          "DEFAULT",+          "FALSE",+          "NULL",+          "TRUE",+          "abstract",+          "as",+          "base",+          "bool",+          "break",+          "byte",+          "case",+          "catch",+          "char",+          "checked",+          "class",+          "const",+          "continue",+          "decimal",+          "delegate",+          "do",+          "double",+          "else",+          "enum",+          "event",+          "explicit",+          "extern",+          "finally",+          "fixed",+          "float",+          "for",+          "foreach",+          "goto",+          "if",+          "implicit",+          "in",+          "int",+          "interface",+          "internal",+          "is",+          "lock",+          "long",+          "namespace",+          "new",+          "object",+          "operator",+          "out",+          "override",+          "params",+          "private",+          "protected",+          "public",+          "readonly",+          "ref",+          "return",+          "sbyte",+          "sealed",+          "short",+          "sizeof",+          "stackalloc",+          "static",+          "string",+          "struct",+          "switch",+          "this",+          "throw",+          "try",+          "typeof",+          "uint",+          "ulong",+          "unchecked",+          "unsafe",+          "ushort",+          "using",+          "virtual",+          "void",+          "volatile",+          "while"]+    contextualKeywords =+        [+          "add",+          "alias",+          "ascending",+          "async",+          "await",+          "by",+          "descending",+          "dynamic",+          "equals",+          "from",+          "get",+          "global",+          "group",+          "into",+          "join",+          "let",+          "nameof",+          "on",+          "orderby",+          "partial",+          "remove",+          "select",+          "set",+          "unmanaged",+          "value",+          "var",+          "when",+          "where",+          "yield"]
+ src/main/haskell/Hydra/Csharp/Syntax.hs view
@@ -0,0 +1,3276 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A C# syntax module based on the ANTLR grammar dated 02/07/2024 and available at:+-- |   https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/grammar++module Hydra.Csharp.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+newtype Identifier =+  Identifier {+    unIdentifier :: String}+  deriving (Eq, Ord, Read, Show)+_Identifier = Core.Name "hydra.csharp.syntax.Identifier"+newtype Keyword =+  Keyword {+    unKeyword :: String}+  deriving (Eq, Ord, Read, Show)+_Keyword = Core.Name "hydra.csharp.syntax.Keyword"+data Literal =+  LiteralBoolean Bool |+  LiteralInteger IntegerLiteral |+  LiteralReal Double |+  LiteralCharacter String |+  LiteralString String |+  LiteralNull+  deriving (Eq, Ord, Read, Show)+_Literal = Core.Name "hydra.csharp.syntax.Literal"+_Literal_boolean = Core.Name "boolean"+_Literal_integer = Core.Name "integer"+_Literal_real = Core.Name "real"+_Literal_character = Core.Name "character"+_Literal_string = Core.Name "string"+_Literal_null = Core.Name "null"+data IntegerLiteral =+  IntegerLiteralDecimal String |+  IntegerLiteralHexadecimal String |+  IntegerLiteralBinary Integer+  deriving (Eq, Ord, Read, Show)+_IntegerLiteral = Core.Name "hydra.csharp.syntax.IntegerLiteral"+_IntegerLiteral_decimal = Core.Name "decimal"+_IntegerLiteral_hexadecimal = Core.Name "hexadecimal"+_IntegerLiteral_binary = Core.Name "binary"+newtype NamespaceName =+  NamespaceName {+    unNamespaceName :: NamespaceOrTypeName}+  deriving (Eq, Ord, Read, Show)+_NamespaceName = Core.Name "hydra.csharp.syntax.NamespaceName"+newtype TypeName =+  TypeName {+    unTypeName :: NamespaceOrTypeName}+  deriving (Eq, Ord, Read, Show)+_TypeName = Core.Name "hydra.csharp.syntax.TypeName"+data NamespaceOrTypeName =+  NamespaceOrTypeNameIdentifier IdentifierNamespaceOrTypeName |+  NamespaceOrTypeNameQualified QualifiedNamespaceOrTypeName |+  NamespaceOrTypeNameAlias QualifiedAliasMember+  deriving (Eq, Ord, Read, Show)+_NamespaceOrTypeName = Core.Name "hydra.csharp.syntax.NamespaceOrTypeName"+_NamespaceOrTypeName_identifier = Core.Name "identifier"+_NamespaceOrTypeName_qualified = Core.Name "qualified"+_NamespaceOrTypeName_alias = Core.Name "alias"+data IdentifierNamespaceOrTypeName =+  IdentifierNamespaceOrTypeName {+    identifierNamespaceOrTypeNameIdentifier :: Identifier,+    identifierNamespaceOrTypeNameArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_IdentifierNamespaceOrTypeName = Core.Name "hydra.csharp.syntax.IdentifierNamespaceOrTypeName"+_IdentifierNamespaceOrTypeName_identifier = Core.Name "identifier"+_IdentifierNamespaceOrTypeName_arguments = Core.Name "arguments"+data QualifiedNamespaceOrTypeName =+  QualifiedNamespaceOrTypeName {+    qualifiedNamespaceOrTypeNameNamespaceOrType :: NamespaceOrTypeName,+    qualifiedNamespaceOrTypeNameIdentifier :: Identifier,+    qualifiedNamespaceOrTypeNameArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_QualifiedNamespaceOrTypeName = Core.Name "hydra.csharp.syntax.QualifiedNamespaceOrTypeName"+_QualifiedNamespaceOrTypeName_namespaceOrType = Core.Name "namespaceOrType"+_QualifiedNamespaceOrTypeName_identifier = Core.Name "identifier"+_QualifiedNamespaceOrTypeName_arguments = Core.Name "arguments"+data Type =+  TypeReference ReferenceType |+  TypeValue ValueType |+  TypeParam TypeParameter |+  TypePointer PointerType+  deriving (Eq, Ord, Read, Show)+_Type = Core.Name "hydra.csharp.syntax.Type"+_Type_reference = Core.Name "reference"+_Type_value = Core.Name "value"+_Type_param = Core.Name "param"+_Type_pointer = Core.Name "pointer"+data ReferenceType =+  ReferenceTypeClass ClassType |+  ReferenceTypeInterface InterfaceType |+  ReferenceTypeArray ArrayType |+  ReferenceTypeDelegate DelegateType |+  ReferenceTypeDynamic+  deriving (Eq, Ord, Read, Show)+_ReferenceType = Core.Name "hydra.csharp.syntax.ReferenceType"+_ReferenceType_class = Core.Name "class"+_ReferenceType_interface = Core.Name "interface"+_ReferenceType_array = Core.Name "array"+_ReferenceType_delegate = Core.Name "delegate"+_ReferenceType_dynamic = Core.Name "dynamic"+data ClassType =+  ClassTypeTypeName TypeName |+  ClassTypeObject |+  ClassTypeString+  deriving (Eq, Ord, Read, Show)+_ClassType = Core.Name "hydra.csharp.syntax.ClassType"+_ClassType_typeName = Core.Name "typeName"+_ClassType_object = Core.Name "object"+_ClassType_string = Core.Name "string"+newtype InterfaceType =+  InterfaceType {+    unInterfaceType :: TypeName}+  deriving (Eq, Ord, Read, Show)+_InterfaceType = Core.Name "hydra.csharp.syntax.InterfaceType"+data ArrayType =+  ArrayType {+    arrayTypeType :: NonArrayType,+    arrayTypeRank :: [RankSpecifier]}+  deriving (Eq, Ord, Read, Show)+_ArrayType = Core.Name "hydra.csharp.syntax.ArrayType"+_ArrayType_type = Core.Name "type"+_ArrayType_rank = Core.Name "rank"+data NonArrayType =+  NonArrayTypeValue ValueType |+  NonArrayTypeClass ClassType |+  NonArrayTypeInterface InterfaceType |+  NonArrayTypeDelegate DelegateType |+  NonArrayTypeDynamic |+  NonArrayTypeParameter TypeParameter |+  NonArrayTypePointer PointerType+  deriving (Eq, Ord, Read, Show)+_NonArrayType = Core.Name "hydra.csharp.syntax.NonArrayType"+_NonArrayType_value = Core.Name "value"+_NonArrayType_class = Core.Name "class"+_NonArrayType_interface = Core.Name "interface"+_NonArrayType_delegate = Core.Name "delegate"+_NonArrayType_dynamic = Core.Name "dynamic"+_NonArrayType_parameter = Core.Name "parameter"+_NonArrayType_pointer = Core.Name "pointer"+newtype RankSpecifier =+  RankSpecifier {+    unRankSpecifier :: Int}+  deriving (Eq, Ord, Read, Show)+_RankSpecifier = Core.Name "hydra.csharp.syntax.RankSpecifier"+newtype DelegateType =+  DelegateType {+    unDelegateType :: TypeName}+  deriving (Eq, Ord, Read, Show)+_DelegateType = Core.Name "hydra.csharp.syntax.DelegateType"+data ValueType =+  ValueTypeNonNullable StructOrEnumType |+  ValueTypeNullable StructOrEnumType+  deriving (Eq, Ord, Read, Show)+_ValueType = Core.Name "hydra.csharp.syntax.ValueType"+_ValueType_nonNullable = Core.Name "nonNullable"+_ValueType_nullable = Core.Name "nullable"+data StructOrEnumType =+  StructOrEnumTypeStruct StructType |+  StructOrEnumTypeEnum EnumType+  deriving (Eq, Ord, Read, Show)+_StructOrEnumType = Core.Name "hydra.csharp.syntax.StructOrEnumType"+_StructOrEnumType_struct = Core.Name "struct"+_StructOrEnumType_enum = Core.Name "enum"+data StructType =+  StructTypeTypeName TypeName |+  StructTypeSimple SimpleType |+  StructTypeTuple TupleType+  deriving (Eq, Ord, Read, Show)+_StructType = Core.Name "hydra.csharp.syntax.StructType"+_StructType_typeName = Core.Name "typeName"+_StructType_simple = Core.Name "simple"+_StructType_tuple = Core.Name "tuple"+data SimpleType =+  SimpleTypeNumeric NumericType |+  SimpleTypeBool+  deriving (Eq, Ord, Read, Show)+_SimpleType = Core.Name "hydra.csharp.syntax.SimpleType"+_SimpleType_numeric = Core.Name "numeric"+_SimpleType_bool = Core.Name "bool"+data NumericType =+  NumericTypeIntegral IntegralType |+  NumericTypeFloatingPoint FloatingPointType |+  NumericTypeDecimal+  deriving (Eq, Ord, Read, Show)+_NumericType = Core.Name "hydra.csharp.syntax.NumericType"+_NumericType_integral = Core.Name "integral"+_NumericType_floatingPoint = Core.Name "floatingPoint"+_NumericType_decimal = Core.Name "decimal"+data IntegralType =+  IntegralTypeSbyte |+  IntegralTypeByte |+  IntegralTypeShort |+  IntegralTypeUshort |+  IntegralTypeInt |+  IntegralTypeUint |+  IntegralTypeLong |+  IntegralTypeUlong |+  IntegralTypeChar+  deriving (Eq, Ord, Read, Show)+_IntegralType = Core.Name "hydra.csharp.syntax.IntegralType"+_IntegralType_sbyte = Core.Name "sbyte"+_IntegralType_byte = Core.Name "byte"+_IntegralType_short = Core.Name "short"+_IntegralType_ushort = Core.Name "ushort"+_IntegralType_int = Core.Name "int"+_IntegralType_uint = Core.Name "uint"+_IntegralType_long = Core.Name "long"+_IntegralType_ulong = Core.Name "ulong"+_IntegralType_char = Core.Name "char"+data FloatingPointType =+  FloatingPointTypeFloat |+  FloatingPointTypeDouble+  deriving (Eq, Ord, Read, Show)+_FloatingPointType = Core.Name "hydra.csharp.syntax.FloatingPointType"+_FloatingPointType_float = Core.Name "float"+_FloatingPointType_double = Core.Name "double"+newtype TupleType =+  TupleType {+    unTupleType :: [TupleTypeElement]}+  deriving (Eq, Ord, Read, Show)+_TupleType = Core.Name "hydra.csharp.syntax.TupleType"+data TupleTypeElement =+  TupleTypeElement {+    tupleTypeElementType :: Type,+    tupleTypeElementIdentifier :: (Maybe Identifier)}+  deriving (Eq, Ord, Read, Show)+_TupleTypeElement = Core.Name "hydra.csharp.syntax.TupleTypeElement"+_TupleTypeElement_type = Core.Name "type"+_TupleTypeElement_identifier = Core.Name "identifier"+newtype EnumType =+  EnumType {+    unEnumType :: TypeName}+  deriving (Eq, Ord, Read, Show)+_EnumType = Core.Name "hydra.csharp.syntax.EnumType"+newtype TypeArgumentList =+  TypeArgumentList {+    unTypeArgumentList :: [Type]}+  deriving (Eq, Ord, Read, Show)+_TypeArgumentList = Core.Name "hydra.csharp.syntax.TypeArgumentList"+newtype TypeParameter =+  TypeParameter {+    unTypeParameter :: Identifier}+  deriving (Eq, Ord, Read, Show)+_TypeParameter = Core.Name "hydra.csharp.syntax.TypeParameter"+data UnmanagedType =+  UnmanagedTypeValue ValueType |+  UnmanagedTypePointer PointerType+  deriving (Eq, Ord, Read, Show)+_UnmanagedType = Core.Name "hydra.csharp.syntax.UnmanagedType"+_UnmanagedType_value = Core.Name "value"+_UnmanagedType_pointer = Core.Name "pointer"+newtype VariableReference =+  VariableReference {+    unVariableReference :: Expression}+  deriving (Eq, Ord, Read, Show)+_VariableReference = Core.Name "hydra.csharp.syntax.VariableReference"+data Pattern =+  PatternDeclaration DeclarationPattern |+  PatternConstant Expression |+  PatternVar Designation+  deriving (Eq, Ord, Read, Show)+_Pattern = Core.Name "hydra.csharp.syntax.Pattern"+_Pattern_declaration = Core.Name "declaration"+_Pattern_constant = Core.Name "constant"+_Pattern_var = Core.Name "var"+data DeclarationPattern =+  DeclarationPattern {+    declarationPatternType :: Type,+    declarationPatternDesignation :: Designation}+  deriving (Eq, Ord, Read, Show)+_DeclarationPattern = Core.Name "hydra.csharp.syntax.DeclarationPattern"+_DeclarationPattern_type = Core.Name "type"+_DeclarationPattern_designation = Core.Name "designation"+newtype Designation =+  Designation {+    unDesignation :: Identifier}+  deriving (Eq, Ord, Read, Show)+_Designation = Core.Name "hydra.csharp.syntax.Designation"+newtype ArgumentList =+  ArgumentList {+    unArgumentList :: [Argument]}+  deriving (Eq, Ord, Read, Show)+_ArgumentList = Core.Name "hydra.csharp.syntax.ArgumentList"+data Argument =+  Argument {+    argumentName :: (Maybe Identifier),+    argumentValue :: ArgumentValue}+  deriving (Eq, Ord, Read, Show)+_Argument = Core.Name "hydra.csharp.syntax.Argument"+_Argument_name = Core.Name "name"+_Argument_value = Core.Name "value"+data ArgumentValue =+  ArgumentValueExpression Expression |+  ArgumentValueIn VariableReference |+  ArgumentValueRef VariableReference |+  ArgumentValueOut VariableReference+  deriving (Eq, Ord, Read, Show)+_ArgumentValue = Core.Name "hydra.csharp.syntax.ArgumentValue"+_ArgumentValue_expression = Core.Name "expression"+_ArgumentValue_in = Core.Name "in"+_ArgumentValue_ref = Core.Name "ref"+_ArgumentValue_out = Core.Name "out"+data PrimaryExpression =+  PrimaryExpressionNoArray PrimaryNoArrayCreationExpression |+  PrimaryExpressionArray ArrayCreationExpression+  deriving (Eq, Ord, Read, Show)+_PrimaryExpression = Core.Name "hydra.csharp.syntax.PrimaryExpression"+_PrimaryExpression_noArray = Core.Name "noArray"+_PrimaryExpression_array = Core.Name "array"+data PrimaryNoArrayCreationExpression =+  PrimaryNoArrayCreationExpressionLiteral Literal |+  PrimaryNoArrayCreationExpressionInterpolatedString InterpolatedStringExpression |+  PrimaryNoArrayCreationExpressionSimpleName SimpleName |+  PrimaryNoArrayCreationExpressionParenthesized Expression |+  PrimaryNoArrayCreationExpressionTuple TupleExpression |+  PrimaryNoArrayCreationExpressionMemberAccess MemberAccess |+  PrimaryNoArrayCreationExpressionNullConditionalMemberAccess NullConditionalMemberAccess |+  PrimaryNoArrayCreationExpressionInvocation InvocationExpression |+  PrimaryNoArrayCreationExpressionElementAccess ElementAccess |+  PrimaryNoArrayCreationExpressionNullConditionalElementAccess NullConditionalElementAccess |+  PrimaryNoArrayCreationExpressionThisAccess |+  PrimaryNoArrayCreationExpressionBaseAccess BaseAccess |+  PrimaryNoArrayCreationExpressionPostIncrement PrimaryExpression |+  PrimaryNoArrayCreationExpressionPostDecrement PrimaryExpression |+  PrimaryNoArrayCreationExpressionObjectCreation ObjectCreationExpression |+  PrimaryNoArrayCreationExpressionDelegateCreation DelegateCreationExpression |+  PrimaryNoArrayCreationExpressionAnonymousObjectCreation (Maybe MemberDeclaratorList) |+  PrimaryNoArrayCreationExpressionTypeof TypeofExpression |+  PrimaryNoArrayCreationExpressionSizeof UnmanagedType |+  PrimaryNoArrayCreationExpressionChecked Expression |+  PrimaryNoArrayCreationExpressionUnchecked Expression |+  PrimaryNoArrayCreationExpressionDefaultValue DefaultValueExpression |+  PrimaryNoArrayCreationExpressionNameof NamedEntity |+  PrimaryNoArrayCreationExpressionAnonymousMethod AnonymousMethodExpression |+  PrimaryNoArrayCreationExpressionPointerMemberAccess PointerMemberAccess |+  PrimaryNoArrayCreationExpressionPointerElementAccess PointerElementAccess |+  PrimaryNoArrayCreationExpressionStackalloc StackallocExpression+  deriving (Eq, Ord, Read, Show)+_PrimaryNoArrayCreationExpression = Core.Name "hydra.csharp.syntax.PrimaryNoArrayCreationExpression"+_PrimaryNoArrayCreationExpression_literal = Core.Name "literal"+_PrimaryNoArrayCreationExpression_interpolatedString = Core.Name "interpolatedString"+_PrimaryNoArrayCreationExpression_simpleName = Core.Name "simpleName"+_PrimaryNoArrayCreationExpression_parenthesized = Core.Name "parenthesized"+_PrimaryNoArrayCreationExpression_tuple = Core.Name "tuple"+_PrimaryNoArrayCreationExpression_memberAccess = Core.Name "memberAccess"+_PrimaryNoArrayCreationExpression_nullConditionalMemberAccess = Core.Name "nullConditionalMemberAccess"+_PrimaryNoArrayCreationExpression_invocation = Core.Name "invocation"+_PrimaryNoArrayCreationExpression_elementAccess = Core.Name "elementAccess"+_PrimaryNoArrayCreationExpression_nullConditionalElementAccess = Core.Name "nullConditionalElementAccess"+_PrimaryNoArrayCreationExpression_thisAccess = Core.Name "thisAccess"+_PrimaryNoArrayCreationExpression_baseAccess = Core.Name "baseAccess"+_PrimaryNoArrayCreationExpression_postIncrement = Core.Name "postIncrement"+_PrimaryNoArrayCreationExpression_postDecrement = Core.Name "postDecrement"+_PrimaryNoArrayCreationExpression_objectCreation = Core.Name "objectCreation"+_PrimaryNoArrayCreationExpression_delegateCreation = Core.Name "delegateCreation"+_PrimaryNoArrayCreationExpression_anonymousObjectCreation = Core.Name "anonymousObjectCreation"+_PrimaryNoArrayCreationExpression_typeof = Core.Name "typeof"+_PrimaryNoArrayCreationExpression_sizeof = Core.Name "sizeof"+_PrimaryNoArrayCreationExpression_checked = Core.Name "checked"+_PrimaryNoArrayCreationExpression_unchecked = Core.Name "unchecked"+_PrimaryNoArrayCreationExpression_defaultValue = Core.Name "defaultValue"+_PrimaryNoArrayCreationExpression_nameof = Core.Name "nameof"+_PrimaryNoArrayCreationExpression_anonymousMethod = Core.Name "anonymousMethod"+_PrimaryNoArrayCreationExpression_pointerMemberAccess = Core.Name "pointerMemberAccess"+_PrimaryNoArrayCreationExpression_pointerElementAccess = Core.Name "pointerElementAccess"+_PrimaryNoArrayCreationExpression_stackalloc = Core.Name "stackalloc"+data InterpolatedStringExpression =+  InterpolatedStringExpressionRegular InterpolatedRegularStringExpression |+  InterpolatedStringExpressionVerbatim InterpolatedVerbatimStringExpression+  deriving (Eq, Ord, Read, Show)+_InterpolatedStringExpression = Core.Name "hydra.csharp.syntax.InterpolatedStringExpression"+_InterpolatedStringExpression_regular = Core.Name "regular"+_InterpolatedStringExpression_verbatim = Core.Name "verbatim"+newtype InterpolatedRegularStringExpression =+  InterpolatedRegularStringExpression {+    unInterpolatedRegularStringExpression :: String}+  deriving (Eq, Ord, Read, Show)+_InterpolatedRegularStringExpression = Core.Name "hydra.csharp.syntax.InterpolatedRegularStringExpression"+data RegularInterpolation =+  RegularInterpolation {+    regularInterpolationExpression :: Expression,+    regularInterpolationWidth :: (Maybe Expression),+    regularInterpolationFormat :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_RegularInterpolation = Core.Name "hydra.csharp.syntax.RegularInterpolation"+_RegularInterpolation_expression = Core.Name "expression"+_RegularInterpolation_width = Core.Name "width"+_RegularInterpolation_format = Core.Name "format"+newtype InterpolatedVerbatimStringExpression =+  InterpolatedVerbatimStringExpression {+    unInterpolatedVerbatimStringExpression :: String}+  deriving (Eq, Ord, Read, Show)+_InterpolatedVerbatimStringExpression = Core.Name "hydra.csharp.syntax.InterpolatedVerbatimStringExpression"+data VerbatimInterpolation =+  VerbatimInterpolation {+    verbatimInterpolationExpression :: Expression,+    verbatimInterpolationWidth :: (Maybe ConstantExpression),+    verbatimInterpolationFormat :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_VerbatimInterpolation = Core.Name "hydra.csharp.syntax.VerbatimInterpolation"+_VerbatimInterpolation_expression = Core.Name "expression"+_VerbatimInterpolation_width = Core.Name "width"+_VerbatimInterpolation_format = Core.Name "format"+data SimpleName =+  SimpleName {+    simpleNameIdentifier :: Identifier,+    simpleNameTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_SimpleName = Core.Name "hydra.csharp.syntax.SimpleName"+_SimpleName_identifier = Core.Name "identifier"+_SimpleName_typeArguments = Core.Name "typeArguments"+data TupleExpression =+  TupleExpressionElements [TupleElement] |+  TupleExpressionDeconstruction DeconstructionTuple+  deriving (Eq, Ord, Read, Show)+_TupleExpression = Core.Name "hydra.csharp.syntax.TupleExpression"+_TupleExpression_elements = Core.Name "elements"+_TupleExpression_deconstruction = Core.Name "deconstruction"+data TupleElement =+  TupleElement {+    tupleElementName :: (Maybe Identifier),+    tupleElementExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_TupleElement = Core.Name "hydra.csharp.syntax.TupleElement"+_TupleElement_name = Core.Name "name"+_TupleElement_expression = Core.Name "expression"+newtype DeconstructionTuple =+  DeconstructionTuple {+    unDeconstructionTuple :: [DeconstructionElement]}+  deriving (Eq, Ord, Read, Show)+_DeconstructionTuple = Core.Name "hydra.csharp.syntax.DeconstructionTuple"+data DeconstructionElement =+  DeconstructionElementTuple DeconstructionTuple |+  DeconstructionElementIdentifier Identifier+  deriving (Eq, Ord, Read, Show)+_DeconstructionElement = Core.Name "hydra.csharp.syntax.DeconstructionElement"+_DeconstructionElement_tuple = Core.Name "tuple"+_DeconstructionElement_identifier = Core.Name "identifier"+data MemberAccess =+  MemberAccess {+    memberAccessHead :: MemberAccessHead,+    memberAccessIdentifier :: Identifier,+    memberAccessTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_MemberAccess = Core.Name "hydra.csharp.syntax.MemberAccess"+_MemberAccess_head = Core.Name "head"+_MemberAccess_identifier = Core.Name "identifier"+_MemberAccess_typeArguments = Core.Name "typeArguments"+data MemberAccessHead =+  MemberAccessHeadPrimary PrimaryExpression |+  MemberAccessHeadPredefined PredefinedType |+  MemberAccessHeadQualifiedAlias QualifiedAliasMember+  deriving (Eq, Ord, Read, Show)+_MemberAccessHead = Core.Name "hydra.csharp.syntax.MemberAccessHead"+_MemberAccessHead_primary = Core.Name "primary"+_MemberAccessHead_predefined = Core.Name "predefined"+_MemberAccessHead_qualifiedAlias = Core.Name "qualifiedAlias"+data PredefinedType =+  PredefinedTypeBool |+  PredefinedTypeByte |+  PredefinedTypeChar |+  PredefinedTypeDecimal |+  PredefinedTypeDouble |+  PredefinedTypeFloat |+  PredefinedTypeInt |+  PredefinedTypeLong |+  PredefinedTypeObject |+  PredefinedTypeSbyte |+  PredefinedTypeShort |+  PredefinedTypeString |+  PredefinedTypeUint |+  PredefinedTypeUlong |+  PredefinedTypeUshort+  deriving (Eq, Ord, Read, Show)+_PredefinedType = Core.Name "hydra.csharp.syntax.PredefinedType"+_PredefinedType_bool = Core.Name "bool"+_PredefinedType_byte = Core.Name "byte"+_PredefinedType_char = Core.Name "char"+_PredefinedType_decimal = Core.Name "decimal"+_PredefinedType_double = Core.Name "double"+_PredefinedType_float = Core.Name "float"+_PredefinedType_int = Core.Name "int"+_PredefinedType_long = Core.Name "long"+_PredefinedType_object = Core.Name "object"+_PredefinedType_sbyte = Core.Name "sbyte"+_PredefinedType_short = Core.Name "short"+_PredefinedType_string = Core.Name "string"+_PredefinedType_uint = Core.Name "uint"+_PredefinedType_ulong = Core.Name "ulong"+_PredefinedType_ushort = Core.Name "ushort"+data NullConditionalMemberAccess =+  NullConditionalMemberAccess {+    nullConditionalMemberAccessExpression :: PrimaryExpression,+    nullConditionalMemberAccessIdentifier :: Identifier,+    nullConditionalMemberAccessTypeArguments :: (Maybe TypeArgumentList),+    nullConditionalMemberAccessDependentAccess :: [DependentAccess]}+  deriving (Eq, Ord, Read, Show)+_NullConditionalMemberAccess = Core.Name "hydra.csharp.syntax.NullConditionalMemberAccess"+_NullConditionalMemberAccess_expression = Core.Name "expression"+_NullConditionalMemberAccess_identifier = Core.Name "identifier"+_NullConditionalMemberAccess_typeArguments = Core.Name "typeArguments"+_NullConditionalMemberAccess_dependentAccess = Core.Name "dependentAccess"+data DependentAccess =+  DependentAccessMemberAccess DependentAccessForMember |+  DependentAccessElementAccess ArgumentList |+  DependentAccessInvocation (Maybe ArgumentList)+  deriving (Eq, Ord, Read, Show)+_DependentAccess = Core.Name "hydra.csharp.syntax.DependentAccess"+_DependentAccess_memberAccess = Core.Name "memberAccess"+_DependentAccess_elementAccess = Core.Name "elementAccess"+_DependentAccess_invocation = Core.Name "invocation"+data DependentAccessForMember =+  DependentAccessForMember {+    dependentAccessForMemberIdentifier :: Identifier,+    dependentAccessForMemberTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_DependentAccessForMember = Core.Name "hydra.csharp.syntax.DependentAccessForMember"+_DependentAccessForMember_identifier = Core.Name "identifier"+_DependentAccessForMember_typeArguments = Core.Name "typeArguments"+data NullConditionalProjectionInitializer =+  NullConditionalProjectionInitializer {+    nullConditionalProjectionInitializerExpression :: PrimaryExpression,+    nullConditionalProjectionInitializerIdentifier :: Identifier,+    nullConditionalProjectionInitializerTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_NullConditionalProjectionInitializer = Core.Name "hydra.csharp.syntax.NullConditionalProjectionInitializer"+_NullConditionalProjectionInitializer_expression = Core.Name "expression"+_NullConditionalProjectionInitializer_identifier = Core.Name "identifier"+_NullConditionalProjectionInitializer_typeArguments = Core.Name "typeArguments"+data InvocationExpression =+  InvocationExpression {+    invocationExpressionExpression :: PrimaryExpression,+    invocationExpressionArguments :: (Maybe ArgumentList)}+  deriving (Eq, Ord, Read, Show)+_InvocationExpression = Core.Name "hydra.csharp.syntax.InvocationExpression"+_InvocationExpression_expression = Core.Name "expression"+_InvocationExpression_arguments = Core.Name "arguments"+data NullConditionalInvocationExpression =+  NullConditionalInvocationExpression {+    nullConditionalInvocationExpressionHead :: NullConditionalInvocationExpressionHead,+    nullConditionalInvocationExpressionArguments :: (Maybe ArgumentList)}+  deriving (Eq, Ord, Read, Show)+_NullConditionalInvocationExpression = Core.Name "hydra.csharp.syntax.NullConditionalInvocationExpression"+_NullConditionalInvocationExpression_head = Core.Name "head"+_NullConditionalInvocationExpression_arguments = Core.Name "arguments"+data NullConditionalInvocationExpressionHead =+  NullConditionalInvocationExpressionHeadMember NullConditionalMemberAccess |+  NullConditionalInvocationExpressionHeadElement NullConditionalElementAccess+  deriving (Eq, Ord, Read, Show)+_NullConditionalInvocationExpressionHead = Core.Name "hydra.csharp.syntax.NullConditionalInvocationExpressionHead"+_NullConditionalInvocationExpressionHead_member = Core.Name "member"+_NullConditionalInvocationExpressionHead_element = Core.Name "element"+data ElementAccess =+  ElementAccess {+    elementAccessExpression :: PrimaryNoArrayCreationExpression,+    elementAccessArguments :: ArgumentList}+  deriving (Eq, Ord, Read, Show)+_ElementAccess = Core.Name "hydra.csharp.syntax.ElementAccess"+_ElementAccess_expression = Core.Name "expression"+_ElementAccess_arguments = Core.Name "arguments"+data NullConditionalElementAccess =+  NullConditionalElementAccess {+    nullConditionalElementAccessExpression :: PrimaryNoArrayCreationExpression,+    nullConditionalElementAccessArguments :: ArgumentList,+    nullConditionalElementAccessDependentAccess :: [DependentAccess]}+  deriving (Eq, Ord, Read, Show)+_NullConditionalElementAccess = Core.Name "hydra.csharp.syntax.NullConditionalElementAccess"+_NullConditionalElementAccess_expression = Core.Name "expression"+_NullConditionalElementAccess_arguments = Core.Name "arguments"+_NullConditionalElementAccess_dependentAccess = Core.Name "dependentAccess"+data BaseAccess =+  BaseAccessIdentifier BaseAccessWithIdentifier |+  BaseAccessArguments ArgumentList+  deriving (Eq, Ord, Read, Show)+_BaseAccess = Core.Name "hydra.csharp.syntax.BaseAccess"+_BaseAccess_identifier = Core.Name "identifier"+_BaseAccess_arguments = Core.Name "arguments"+data BaseAccessWithIdentifier =+  BaseAccessWithIdentifier {+    baseAccessWithIdentifierIdentifier :: Identifier,+    baseAccessWithIdentifierTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_BaseAccessWithIdentifier = Core.Name "hydra.csharp.syntax.BaseAccessWithIdentifier"+_BaseAccessWithIdentifier_identifier = Core.Name "identifier"+_BaseAccessWithIdentifier_typeArguments = Core.Name "typeArguments"+data ObjectCreationExpression =+  ObjectCreationExpression {+    objectCreationExpressionType :: Type,+    objectCreationExpressionArguments :: (Maybe ArgumentList),+    objectCreationExpressionInitializer :: (Maybe ObjectOrCollectionInitializer)}+  deriving (Eq, Ord, Read, Show)+_ObjectCreationExpression = Core.Name "hydra.csharp.syntax.ObjectCreationExpression"+_ObjectCreationExpression_type = Core.Name "type"+_ObjectCreationExpression_arguments = Core.Name "arguments"+_ObjectCreationExpression_initializer = Core.Name "initializer"+data ObjectOrCollectionInitializer =+  ObjectOrCollectionInitializerObject [MemberInitializer] |+  ObjectOrCollectionInitializerCollection [ElementInitializer]+  deriving (Eq, Ord, Read, Show)+_ObjectOrCollectionInitializer = Core.Name "hydra.csharp.syntax.ObjectOrCollectionInitializer"+_ObjectOrCollectionInitializer_object = Core.Name "object"+_ObjectOrCollectionInitializer_collection = Core.Name "collection"+data MemberInitializer =+  MemberInitializer {+    memberInitializerTarget :: InitializerTarget,+    memberInitializerValue :: InitializerValue}+  deriving (Eq, Ord, Read, Show)+_MemberInitializer = Core.Name "hydra.csharp.syntax.MemberInitializer"+_MemberInitializer_target = Core.Name "target"+_MemberInitializer_value = Core.Name "value"+data InitializerTarget =+  InitializerTargetIdentifier Identifier |+  InitializerTargetArguments ArgumentList+  deriving (Eq, Ord, Read, Show)+_InitializerTarget = Core.Name "hydra.csharp.syntax.InitializerTarget"+_InitializerTarget_identifier = Core.Name "identifier"+_InitializerTarget_arguments = Core.Name "arguments"+data InitializerValue =+  InitializerValueExpression Expression |+  InitializerValueObjectOrCollection ObjectOrCollectionInitializer+  deriving (Eq, Ord, Read, Show)+_InitializerValue = Core.Name "hydra.csharp.syntax.InitializerValue"+_InitializerValue_expression = Core.Name "expression"+_InitializerValue_objectOrCollection = Core.Name "objectOrCollection"+data ElementInitializer =+  ElementInitializerSingle NonAssignmentExpression |+  ElementInitializerList ExpressionList+  deriving (Eq, Ord, Read, Show)+_ElementInitializer = Core.Name "hydra.csharp.syntax.ElementInitializer"+_ElementInitializer_single = Core.Name "single"+_ElementInitializer_list = Core.Name "list"+newtype ExpressionList =+  ExpressionList {+    unExpressionList :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_ExpressionList = Core.Name "hydra.csharp.syntax.ExpressionList"+data ArrayCreationExpression =+  ArrayCreationExpressionNonArrayType NonArrayTypeArrayCreationExpression |+  ArrayCreationExpressionArrayType ArrayTypeArrayCreationExpression |+  ArrayCreationExpressionRankSpecifier RankSpecifierArrayCreationExpression+  deriving (Eq, Ord, Read, Show)+_ArrayCreationExpression = Core.Name "hydra.csharp.syntax.ArrayCreationExpression"+_ArrayCreationExpression_nonArrayType = Core.Name "nonArrayType"+_ArrayCreationExpression_arrayType = Core.Name "arrayType"+_ArrayCreationExpression_rankSpecifier = Core.Name "rankSpecifier"+data NonArrayTypeArrayCreationExpression =+  NonArrayTypeArrayCreationExpression {+    nonArrayTypeArrayCreationExpressionType :: NonArrayType,+    nonArrayTypeArrayCreationExpressionExpressions :: ExpressionList,+    nonArrayTypeArrayCreationExpressionRankSpecifiers :: [RankSpecifier],+    nonArrayTypeArrayCreationExpressionInitializer :: (Maybe ArrayInitializer)}+  deriving (Eq, Ord, Read, Show)+_NonArrayTypeArrayCreationExpression = Core.Name "hydra.csharp.syntax.NonArrayTypeArrayCreationExpression"+_NonArrayTypeArrayCreationExpression_type = Core.Name "type"+_NonArrayTypeArrayCreationExpression_expressions = Core.Name "expressions"+_NonArrayTypeArrayCreationExpression_rankSpecifiers = Core.Name "rankSpecifiers"+_NonArrayTypeArrayCreationExpression_initializer = Core.Name "initializer"+data ArrayTypeArrayCreationExpression =+  ArrayTypeArrayCreationExpression {+    arrayTypeArrayCreationExpressionType :: ArrayType,+    arrayTypeArrayCreationExpressionInitializer :: ArrayInitializer}+  deriving (Eq, Ord, Read, Show)+_ArrayTypeArrayCreationExpression = Core.Name "hydra.csharp.syntax.ArrayTypeArrayCreationExpression"+_ArrayTypeArrayCreationExpression_type = Core.Name "type"+_ArrayTypeArrayCreationExpression_initializer = Core.Name "initializer"+data RankSpecifierArrayCreationExpression =+  RankSpecifierArrayCreationExpression {+    rankSpecifierArrayCreationExpressionRankSpecifier :: RankSpecifier,+    rankSpecifierArrayCreationExpressionInitializer :: ArrayInitializer}+  deriving (Eq, Ord, Read, Show)+_RankSpecifierArrayCreationExpression = Core.Name "hydra.csharp.syntax.RankSpecifierArrayCreationExpression"+_RankSpecifierArrayCreationExpression_rankSpecifier = Core.Name "rankSpecifier"+_RankSpecifierArrayCreationExpression_initializer = Core.Name "initializer"+data DelegateCreationExpression =+  DelegateCreationExpression {+    delegateCreationExpressionType :: DelegateType,+    delegateCreationExpressionExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_DelegateCreationExpression = Core.Name "hydra.csharp.syntax.DelegateCreationExpression"+_DelegateCreationExpression_type = Core.Name "type"+_DelegateCreationExpression_expression = Core.Name "expression"+newtype MemberDeclaratorList =+  MemberDeclaratorList {+    unMemberDeclaratorList :: [MemberDeclarator]}+  deriving (Eq, Ord, Read, Show)+_MemberDeclaratorList = Core.Name "hydra.csharp.syntax.MemberDeclaratorList"+data MemberDeclarator =+  MemberDeclaratorName SimpleName |+  MemberDeclaratorMemberAccess MemberAccess |+  MemberDeclaratorNullConditionalProjectionInitializer NullConditionalProjectionInitializer |+  MemberDeclaratorBaseAccess BaseAccess |+  MemberDeclaratorAssignment AssignmentMemberDeclarator+  deriving (Eq, Ord, Read, Show)+_MemberDeclarator = Core.Name "hydra.csharp.syntax.MemberDeclarator"+_MemberDeclarator_name = Core.Name "name"+_MemberDeclarator_memberAccess = Core.Name "memberAccess"+_MemberDeclarator_nullConditionalProjectionInitializer = Core.Name "nullConditionalProjectionInitializer"+_MemberDeclarator_baseAccess = Core.Name "baseAccess"+_MemberDeclarator_assignment = Core.Name "assignment"+data AssignmentMemberDeclarator =+  AssignmentMemberDeclarator {+    assignmentMemberDeclaratorIdentifier :: Identifier,+    assignmentMemberDeclaratorExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_AssignmentMemberDeclarator = Core.Name "hydra.csharp.syntax.AssignmentMemberDeclarator"+_AssignmentMemberDeclarator_identifier = Core.Name "identifier"+_AssignmentMemberDeclarator_expression = Core.Name "expression"+data TypeofExpression =+  TypeofExpressionType Type |+  TypeofExpressionUnboundTypeName UnboundTypeName |+  TypeofExpressionVoid+  deriving (Eq, Ord, Read, Show)+_TypeofExpression = Core.Name "hydra.csharp.syntax.TypeofExpression"+_TypeofExpression_type = Core.Name "type"+_TypeofExpression_unboundTypeName = Core.Name "unboundTypeName"+_TypeofExpression_void = Core.Name "void"+newtype UnboundTypeName =+  UnboundTypeName {+    unUnboundTypeName :: [UnboundTypeNamePart]}+  deriving (Eq, Ord, Read, Show)+_UnboundTypeName = Core.Name "hydra.csharp.syntax.UnboundTypeName"+data UnboundTypeNamePart =+  UnboundTypeNamePart {+    unboundTypeNamePartIdentifier :: Identifier,+    unboundTypeNamePartAliased :: Bool,+    unboundTypeNamePartDimension :: (Maybe Int)}+  deriving (Eq, Ord, Read, Show)+_UnboundTypeNamePart = Core.Name "hydra.csharp.syntax.UnboundTypeNamePart"+_UnboundTypeNamePart_identifier = Core.Name "identifier"+_UnboundTypeNamePart_aliased = Core.Name "aliased"+_UnboundTypeNamePart_dimension = Core.Name "dimension"+data DefaultValueExpression =+  DefaultValueExpressionExplicitlyTyped Type |+  DefaultValueExpressionDefaultLiteral+  deriving (Eq, Ord, Read, Show)+_DefaultValueExpression = Core.Name "hydra.csharp.syntax.DefaultValueExpression"+_DefaultValueExpression_explicitlyTyped = Core.Name "explicitlyTyped"+_DefaultValueExpression_defaultLiteral = Core.Name "defaultLiteral"+data StackallocExpression =+  StackallocExpression {+    stackallocExpressionType :: (Maybe UnmanagedType),+    stackallocExpressionExpression :: (Maybe ConstantExpression),+    stackallocExpressionInitializer :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_StackallocExpression = Core.Name "hydra.csharp.syntax.StackallocExpression"+_StackallocExpression_type = Core.Name "type"+_StackallocExpression_expression = Core.Name "expression"+_StackallocExpression_initializer = Core.Name "initializer"+data NamedEntity =+  NamedEntity {+    namedEntityTarget :: NamedEntityTarget,+    namedEntityParts :: [NamedEntityPart]}+  deriving (Eq, Ord, Read, Show)+_NamedEntity = Core.Name "hydra.csharp.syntax.NamedEntity"+_NamedEntity_target = Core.Name "target"+_NamedEntity_parts = Core.Name "parts"+data NamedEntityPart =+  NamedEntityPart {+    namedEntityPartIdentifier :: Identifier,+    namedEntityPartTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_NamedEntityPart = Core.Name "hydra.csharp.syntax.NamedEntityPart"+_NamedEntityPart_identifier = Core.Name "identifier"+_NamedEntityPart_typeArguments = Core.Name "typeArguments"+data NamedEntityTarget =+  NamedEntityTargetName SimpleName |+  NamedEntityTargetThis |+  NamedEntityTargetBase |+  NamedEntityTargetPredefinedType PredefinedType |+  NamedEntityTargetQualifiedAliasMember QualifiedAliasMember+  deriving (Eq, Ord, Read, Show)+_NamedEntityTarget = Core.Name "hydra.csharp.syntax.NamedEntityTarget"+_NamedEntityTarget_name = Core.Name "name"+_NamedEntityTarget_this = Core.Name "this"+_NamedEntityTarget_base = Core.Name "base"+_NamedEntityTarget_predefinedType = Core.Name "predefinedType"+_NamedEntityTarget_qualifiedAliasMember = Core.Name "qualifiedAliasMember"+data UnaryExpression =+  UnaryExpressionPrimary PrimaryExpression |+  UnaryExpressionPlus UnaryExpression |+  UnaryExpressionMinus UnaryExpression |+  UnaryExpressionNot UnaryExpression |+  UnaryExpressionBitwiseComplement UnaryExpression |+  UnaryExpressionPreIncrement UnaryExpression |+  UnaryExpressionPreDecrement UnaryExpression |+  UnaryExpressionCast CastExpression |+  UnaryExpressionAwait UnaryExpression |+  UnaryExpressionPointerIndirection UnaryExpression |+  UnaryExpressionAddressOf UnaryExpression+  deriving (Eq, Ord, Read, Show)+_UnaryExpression = Core.Name "hydra.csharp.syntax.UnaryExpression"+_UnaryExpression_primary = Core.Name "primary"+_UnaryExpression_plus = Core.Name "plus"+_UnaryExpression_minus = Core.Name "minus"+_UnaryExpression_not = Core.Name "not"+_UnaryExpression_bitwiseComplement = Core.Name "bitwiseComplement"+_UnaryExpression_preIncrement = Core.Name "preIncrement"+_UnaryExpression_preDecrement = Core.Name "preDecrement"+_UnaryExpression_cast = Core.Name "cast"+_UnaryExpression_await = Core.Name "await"+_UnaryExpression_pointerIndirection = Core.Name "pointerIndirection"+_UnaryExpression_addressOf = Core.Name "addressOf"+data CastExpression =+  CastExpression {+    castExpressionType :: Type,+    castExpressionExpression :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_CastExpression = Core.Name "hydra.csharp.syntax.CastExpression"+_CastExpression_type = Core.Name "type"+_CastExpression_expression = Core.Name "expression"+data MultiplicativeExpression =+  MultiplicativeExpressionSimple UnaryExpression |+  MultiplicativeExpressionBinary BinaryMultiplicativeExpression+  deriving (Eq, Ord, Read, Show)+_MultiplicativeExpression = Core.Name "hydra.csharp.syntax.MultiplicativeExpression"+_MultiplicativeExpression_simple = Core.Name "simple"+_MultiplicativeExpression_binary = Core.Name "binary"+data BinaryMultiplicativeExpression =+  BinaryMultiplicativeExpression {+    binaryMultiplicativeExpressionLeft :: MultiplicativeExpression,+    binaryMultiplicativeExpressionOperator :: MultiplicativeOperator,+    binaryMultiplicativeExpressionRight :: UnaryExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryMultiplicativeExpression = Core.Name "hydra.csharp.syntax.BinaryMultiplicativeExpression"+_BinaryMultiplicativeExpression_left = Core.Name "left"+_BinaryMultiplicativeExpression_operator = Core.Name "operator"+_BinaryMultiplicativeExpression_right = Core.Name "right"+data MultiplicativeOperator =+  MultiplicativeOperatorTimes |+  MultiplicativeOperatorDivide |+  MultiplicativeOperatorModulo+  deriving (Eq, Ord, Read, Show)+_MultiplicativeOperator = Core.Name "hydra.csharp.syntax.MultiplicativeOperator"+_MultiplicativeOperator_times = Core.Name "times"+_MultiplicativeOperator_divide = Core.Name "divide"+_MultiplicativeOperator_modulo = Core.Name "modulo"+data AdditiveExpression =+  AdditiveExpressionSimple MultiplicativeExpression |+  AdditiveExpressionBinary BinaryAdditiveExpression+  deriving (Eq, Ord, Read, Show)+_AdditiveExpression = Core.Name "hydra.csharp.syntax.AdditiveExpression"+_AdditiveExpression_simple = Core.Name "simple"+_AdditiveExpression_binary = Core.Name "binary"+data BinaryAdditiveExpression =+  BinaryAdditiveExpression {+    binaryAdditiveExpressionLeft :: AdditiveExpression,+    binaryAdditiveExpressionOperator :: AdditiveOperator,+    binaryAdditiveExpressionRight :: MultiplicativeExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryAdditiveExpression = Core.Name "hydra.csharp.syntax.BinaryAdditiveExpression"+_BinaryAdditiveExpression_left = Core.Name "left"+_BinaryAdditiveExpression_operator = Core.Name "operator"+_BinaryAdditiveExpression_right = Core.Name "right"+data AdditiveOperator =+  AdditiveOperatorPlus |+  AdditiveOperatorMinus+  deriving (Eq, Ord, Read, Show)+_AdditiveOperator = Core.Name "hydra.csharp.syntax.AdditiveOperator"+_AdditiveOperator_plus = Core.Name "plus"+_AdditiveOperator_minus = Core.Name "minus"+data ShiftExpression =+  ShiftExpressionSimple AdditiveExpression |+  ShiftExpressionBinary BinaryShiftExpression+  deriving (Eq, Ord, Read, Show)+_ShiftExpression = Core.Name "hydra.csharp.syntax.ShiftExpression"+_ShiftExpression_simple = Core.Name "simple"+_ShiftExpression_binary = Core.Name "binary"+data BinaryShiftExpression =+  BinaryShiftExpression {+    binaryShiftExpressionLeft :: ShiftExpression,+    binaryShiftExpressionOperator :: ShiftOperator,+    binaryShiftExpressionRight :: AdditiveExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryShiftExpression = Core.Name "hydra.csharp.syntax.BinaryShiftExpression"+_BinaryShiftExpression_left = Core.Name "left"+_BinaryShiftExpression_operator = Core.Name "operator"+_BinaryShiftExpression_right = Core.Name "right"+data ShiftOperator =+  ShiftOperatorLeft |+  ShiftOperatorRight+  deriving (Eq, Ord, Read, Show)+_ShiftOperator = Core.Name "hydra.csharp.syntax.ShiftOperator"+_ShiftOperator_left = Core.Name "left"+_ShiftOperator_right = Core.Name "right"+data RelationalExpression =+  RelationalExpressionSimple ShiftExpression |+  RelationalExpressionBinary BinaryRelationalExpression |+  RelationalExpressionIsType IsTypeExpression |+  RelationalExpressionIsPattern IsPatternExpression |+  RelationalExpressionAsType AsTypeExpression+  deriving (Eq, Ord, Read, Show)+_RelationalExpression = Core.Name "hydra.csharp.syntax.RelationalExpression"+_RelationalExpression_simple = Core.Name "simple"+_RelationalExpression_binary = Core.Name "binary"+_RelationalExpression_isType = Core.Name "isType"+_RelationalExpression_isPattern = Core.Name "isPattern"+_RelationalExpression_asType = Core.Name "asType"+data BinaryRelationalExpression =+  BinaryRelationalExpression {+    binaryRelationalExpressionLeft :: RelationalExpression,+    binaryRelationalExpressionOperator :: RelationalOperator,+    binaryRelationalExpressionRight :: ShiftExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryRelationalExpression = Core.Name "hydra.csharp.syntax.BinaryRelationalExpression"+_BinaryRelationalExpression_left = Core.Name "left"+_BinaryRelationalExpression_operator = Core.Name "operator"+_BinaryRelationalExpression_right = Core.Name "right"+data RelationalOperator =+  RelationalOperatorLessThan |+  RelationalOperatorGreaterThan |+  RelationalOperatorLessThanOrEqual |+  RelationalOperatorGreaterThanOrEqual+  deriving (Eq, Ord, Read, Show)+_RelationalOperator = Core.Name "hydra.csharp.syntax.RelationalOperator"+_RelationalOperator_lessThan = Core.Name "lessThan"+_RelationalOperator_greaterThan = Core.Name "greaterThan"+_RelationalOperator_lessThanOrEqual = Core.Name "lessThanOrEqual"+_RelationalOperator_greaterThanOrEqual = Core.Name "greaterThanOrEqual"+data IsTypeExpression =+  IsTypeExpression {+    isTypeExpressionExpression :: RelationalExpression,+    isTypeExpressionType :: Type}+  deriving (Eq, Ord, Read, Show)+_IsTypeExpression = Core.Name "hydra.csharp.syntax.IsTypeExpression"+_IsTypeExpression_expression = Core.Name "expression"+_IsTypeExpression_type = Core.Name "type"+data IsPatternExpression =+  IsPatternExpression {+    isPatternExpressionExpression :: RelationalExpression,+    isPatternExpressionPattern :: Pattern}+  deriving (Eq, Ord, Read, Show)+_IsPatternExpression = Core.Name "hydra.csharp.syntax.IsPatternExpression"+_IsPatternExpression_expression = Core.Name "expression"+_IsPatternExpression_pattern = Core.Name "pattern"+data AsTypeExpression =+  AsTypeExpression {+    asTypeExpressionExpression :: RelationalExpression,+    asTypeExpressionType :: Type}+  deriving (Eq, Ord, Read, Show)+_AsTypeExpression = Core.Name "hydra.csharp.syntax.AsTypeExpression"+_AsTypeExpression_expression = Core.Name "expression"+_AsTypeExpression_type = Core.Name "type"+data EqualityExpression =+  EqualityExpressionSimple RelationalExpression |+  EqualityExpressionBinary BinaryEqualityExpression+  deriving (Eq, Ord, Read, Show)+_EqualityExpression = Core.Name "hydra.csharp.syntax.EqualityExpression"+_EqualityExpression_simple = Core.Name "simple"+_EqualityExpression_binary = Core.Name "binary"+data BinaryEqualityExpression =+  BinaryEqualityExpression {+    binaryEqualityExpressionLeft :: EqualityExpression,+    binaryEqualityExpressionOperator :: EqualityOperator,+    binaryEqualityExpressionRight :: RelationalExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryEqualityExpression = Core.Name "hydra.csharp.syntax.BinaryEqualityExpression"+_BinaryEqualityExpression_left = Core.Name "left"+_BinaryEqualityExpression_operator = Core.Name "operator"+_BinaryEqualityExpression_right = Core.Name "right"+data EqualityOperator =+  EqualityOperatorEqual |+  EqualityOperatorNotEqual+  deriving (Eq, Ord, Read, Show)+_EqualityOperator = Core.Name "hydra.csharp.syntax.EqualityOperator"+_EqualityOperator_equal = Core.Name "equal"+_EqualityOperator_notEqual = Core.Name "notEqual"+data AndExpression =+  AndExpressionSimple EqualityExpression |+  AndExpressionBinary BinaryAndExpression+  deriving (Eq, Ord, Read, Show)+_AndExpression = Core.Name "hydra.csharp.syntax.AndExpression"+_AndExpression_simple = Core.Name "simple"+_AndExpression_binary = Core.Name "binary"+data BinaryAndExpression =+  BinaryAndExpression {+    binaryAndExpressionLeft :: AndExpression,+    binaryAndExpressionRight :: EqualityExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryAndExpression = Core.Name "hydra.csharp.syntax.BinaryAndExpression"+_BinaryAndExpression_left = Core.Name "left"+_BinaryAndExpression_right = Core.Name "right"+data ExclusiveOrExpression =+  ExclusiveOrExpressionSimple AndExpression |+  ExclusiveOrExpressionBinary BinaryExclusiveOrExpression+  deriving (Eq, Ord, Read, Show)+_ExclusiveOrExpression = Core.Name "hydra.csharp.syntax.ExclusiveOrExpression"+_ExclusiveOrExpression_simple = Core.Name "simple"+_ExclusiveOrExpression_binary = Core.Name "binary"+data BinaryExclusiveOrExpression =+  BinaryExclusiveOrExpression {+    binaryExclusiveOrExpressionLeft :: ExclusiveOrExpression,+    binaryExclusiveOrExpressionRight :: AndExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryExclusiveOrExpression = Core.Name "hydra.csharp.syntax.BinaryExclusiveOrExpression"+_BinaryExclusiveOrExpression_left = Core.Name "left"+_BinaryExclusiveOrExpression_right = Core.Name "right"+data InclusiveOrExpression =+  InclusiveOrExpressionSimple ExclusiveOrExpression |+  InclusiveOrExpressionBinary BinaryInclusiveOrExpression+  deriving (Eq, Ord, Read, Show)+_InclusiveOrExpression = Core.Name "hydra.csharp.syntax.InclusiveOrExpression"+_InclusiveOrExpression_simple = Core.Name "simple"+_InclusiveOrExpression_binary = Core.Name "binary"+data BinaryInclusiveOrExpression =+  BinaryInclusiveOrExpression {+    binaryInclusiveOrExpressionLeft :: InclusiveOrExpression,+    binaryInclusiveOrExpressionRight :: ExclusiveOrExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryInclusiveOrExpression = Core.Name "hydra.csharp.syntax.BinaryInclusiveOrExpression"+_BinaryInclusiveOrExpression_left = Core.Name "left"+_BinaryInclusiveOrExpression_right = Core.Name "right"+data ConditionalAndExpression =+  ConditionalAndExpressionSimple InclusiveOrExpression |+  ConditionalAndExpressionBinary BinaryConditionalAndExpression+  deriving (Eq, Ord, Read, Show)+_ConditionalAndExpression = Core.Name "hydra.csharp.syntax.ConditionalAndExpression"+_ConditionalAndExpression_simple = Core.Name "simple"+_ConditionalAndExpression_binary = Core.Name "binary"+data BinaryConditionalAndExpression =+  BinaryConditionalAndExpression {+    binaryConditionalAndExpressionLeft :: ConditionalAndExpression,+    binaryConditionalAndExpressionRight :: InclusiveOrExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryConditionalAndExpression = Core.Name "hydra.csharp.syntax.BinaryConditionalAndExpression"+_BinaryConditionalAndExpression_left = Core.Name "left"+_BinaryConditionalAndExpression_right = Core.Name "right"+data ConditionalOrExpression =+  ConditionalOrExpressionSimple ConditionalAndExpression |+  ConditionalOrExpressionBinary BinaryConditionalOrExpression+  deriving (Eq, Ord, Read, Show)+_ConditionalOrExpression = Core.Name "hydra.csharp.syntax.ConditionalOrExpression"+_ConditionalOrExpression_simple = Core.Name "simple"+_ConditionalOrExpression_binary = Core.Name "binary"+data BinaryConditionalOrExpression =+  BinaryConditionalOrExpression {+    binaryConditionalOrExpressionLeft :: ConditionalOrExpression,+    binaryConditionalOrExpressionRight :: ConditionalAndExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryConditionalOrExpression = Core.Name "hydra.csharp.syntax.BinaryConditionalOrExpression"+_BinaryConditionalOrExpression_left = Core.Name "left"+_BinaryConditionalOrExpression_right = Core.Name "right"+data NullCoalescingExpression =+  NullCoalescingExpressionSimple ConditionalOrExpression |+  NullCoalescingExpressionBinary BinaryNullCoalescingExpression |+  NullCoalescingExpressionThrow NullCoalescingExpression+  deriving (Eq, Ord, Read, Show)+_NullCoalescingExpression = Core.Name "hydra.csharp.syntax.NullCoalescingExpression"+_NullCoalescingExpression_simple = Core.Name "simple"+_NullCoalescingExpression_binary = Core.Name "binary"+_NullCoalescingExpression_throw = Core.Name "throw"+data BinaryNullCoalescingExpression =+  BinaryNullCoalescingExpression {+    binaryNullCoalescingExpressionLeft :: ConditionalOrExpression,+    binaryNullCoalescingExpressionRight :: NullCoalescingExpression}+  deriving (Eq, Ord, Read, Show)+_BinaryNullCoalescingExpression = Core.Name "hydra.csharp.syntax.BinaryNullCoalescingExpression"+_BinaryNullCoalescingExpression_left = Core.Name "left"+_BinaryNullCoalescingExpression_right = Core.Name "right"+data DeclarationExpression =+  DeclarationExpression {+    declarationExpressionType :: LocalVariableType,+    declarationExpressionIdentifier :: Identifier}+  deriving (Eq, Ord, Read, Show)+_DeclarationExpression = Core.Name "hydra.csharp.syntax.DeclarationExpression"+_DeclarationExpression_type = Core.Name "type"+_DeclarationExpression_identifier = Core.Name "identifier"+data LocalVariableType =+  LocalVariableTypeType Type |+  LocalVariableTypeVar+  deriving (Eq, Ord, Read, Show)+_LocalVariableType = Core.Name "hydra.csharp.syntax.LocalVariableType"+_LocalVariableType_type = Core.Name "type"+_LocalVariableType_var = Core.Name "var"+data ConditionalExpression =+  ConditionalExpressionSimple NullCoalescingExpression |+  ConditionalExpressionSimpleConditional SimpleConditionalExpression |+  ConditionalExpressionRefConditional RefConditionalExpression+  deriving (Eq, Ord, Read, Show)+_ConditionalExpression = Core.Name "hydra.csharp.syntax.ConditionalExpression"+_ConditionalExpression_simple = Core.Name "simple"+_ConditionalExpression_simpleConditional = Core.Name "simpleConditional"+_ConditionalExpression_refConditional = Core.Name "refConditional"+data SimpleConditionalExpression =+  SimpleConditionalExpression {+    simpleConditionalExpressionCondition :: NullCoalescingExpression,+    simpleConditionalExpressionTrue :: Expression,+    simpleConditionalExpressionFalse :: Expression}+  deriving (Eq, Ord, Read, Show)+_SimpleConditionalExpression = Core.Name "hydra.csharp.syntax.SimpleConditionalExpression"+_SimpleConditionalExpression_condition = Core.Name "condition"+_SimpleConditionalExpression_true = Core.Name "true"+_SimpleConditionalExpression_false = Core.Name "false"+data RefConditionalExpression =+  RefConditionalExpression {+    refConditionalExpressionCondition :: NullCoalescingExpression,+    refConditionalExpressionTrue :: VariableReference,+    refConditionalExpressionFalse :: VariableReference}+  deriving (Eq, Ord, Read, Show)+_RefConditionalExpression = Core.Name "hydra.csharp.syntax.RefConditionalExpression"+_RefConditionalExpression_condition = Core.Name "condition"+_RefConditionalExpression_true = Core.Name "true"+_RefConditionalExpression_false = Core.Name "false"+data LambdaExpression =+  LambdaExpression {+    lambdaExpressionAsync :: Bool,+    lambdaExpressionSignature :: AnonymousFunctionSignature,+    lambdaExpressionBody :: AnonymousFunctionBody}+  deriving (Eq, Ord, Read, Show)+_LambdaExpression = Core.Name "hydra.csharp.syntax.LambdaExpression"+_LambdaExpression_async = Core.Name "async"+_LambdaExpression_signature = Core.Name "signature"+_LambdaExpression_body = Core.Name "body"+data AnonymousMethodExpression =+  AnonymousMethodExpression {+    anonymousMethodExpressionAsync :: Bool,+    anonymousMethodExpressionSignature :: [ExplicitAnonymousFunctionParameter],+    anonymousMethodExpressionBody :: Block}+  deriving (Eq, Ord, Read, Show)+_AnonymousMethodExpression = Core.Name "hydra.csharp.syntax.AnonymousMethodExpression"+_AnonymousMethodExpression_async = Core.Name "async"+_AnonymousMethodExpression_signature = Core.Name "signature"+_AnonymousMethodExpression_body = Core.Name "body"+data AnonymousFunctionSignature =+  AnonymousFunctionSignatureExplicit [ExplicitAnonymousFunctionParameter] |+  AnonymousFunctionSignatureImplicit [Identifier]+  deriving (Eq, Ord, Read, Show)+_AnonymousFunctionSignature = Core.Name "hydra.csharp.syntax.AnonymousFunctionSignature"+_AnonymousFunctionSignature_explicit = Core.Name "explicit"+_AnonymousFunctionSignature_implicit = Core.Name "implicit"+data ExplicitAnonymousFunctionParameter =+  ExplicitAnonymousFunctionParameter {+    explicitAnonymousFunctionParameterModifier :: (Maybe AnonymousFunctionParameterModifier),+    explicitAnonymousFunctionParameterType :: Type,+    explicitAnonymousFunctionParameterIdentifier :: Identifier}+  deriving (Eq, Ord, Read, Show)+_ExplicitAnonymousFunctionParameter = Core.Name "hydra.csharp.syntax.ExplicitAnonymousFunctionParameter"+_ExplicitAnonymousFunctionParameter_modifier = Core.Name "modifier"+_ExplicitAnonymousFunctionParameter_type = Core.Name "type"+_ExplicitAnonymousFunctionParameter_identifier = Core.Name "identifier"+data AnonymousFunctionParameterModifier =+  AnonymousFunctionParameterModifierRef |+  AnonymousFunctionParameterModifierOut |+  AnonymousFunctionParameterModifierIn+  deriving (Eq, Ord, Read, Show)+_AnonymousFunctionParameterModifier = Core.Name "hydra.csharp.syntax.AnonymousFunctionParameterModifier"+_AnonymousFunctionParameterModifier_ref = Core.Name "ref"+_AnonymousFunctionParameterModifier_out = Core.Name "out"+_AnonymousFunctionParameterModifier_in = Core.Name "in"+data AnonymousFunctionBody =+  AnonymousFunctionBodyNullConditionalInvocation NullConditionalInvocationExpression |+  AnonymousFunctionBodyExpression Expression |+  AnonymousFunctionBodyRef VariableReference |+  AnonymousFunctionBodyBlock Block+  deriving (Eq, Ord, Read, Show)+_AnonymousFunctionBody = Core.Name "hydra.csharp.syntax.AnonymousFunctionBody"+_AnonymousFunctionBody_nullConditionalInvocation = Core.Name "nullConditionalInvocation"+_AnonymousFunctionBody_expression = Core.Name "expression"+_AnonymousFunctionBody_ref = Core.Name "ref"+_AnonymousFunctionBody_block = Core.Name "block"+data QueryExpression =+  QueryExpression {+    queryExpressionFrom :: FromClause,+    queryExpressionBody :: QueryBody}+  deriving (Eq, Ord, Read, Show)+_QueryExpression = Core.Name "hydra.csharp.syntax.QueryExpression"+_QueryExpression_from = Core.Name "from"+_QueryExpression_body = Core.Name "body"+data FromClause =+  FromClause {+    fromClauseType :: (Maybe Type),+    fromClauseIdentifier :: Identifier,+    fromClauseIn :: Expression}+  deriving (Eq, Ord, Read, Show)+_FromClause = Core.Name "hydra.csharp.syntax.FromClause"+_FromClause_type = Core.Name "type"+_FromClause_identifier = Core.Name "identifier"+_FromClause_in = Core.Name "in"+data QueryBody =+  QueryBody {+    queryBodyClauses :: [QueryBodyClause],+    queryBodySelectOrGroup :: SelectOrGroupClause,+    queryBodyContinuation :: (Maybe QueryContinuation)}+  deriving (Eq, Ord, Read, Show)+_QueryBody = Core.Name "hydra.csharp.syntax.QueryBody"+_QueryBody_clauses = Core.Name "clauses"+_QueryBody_selectOrGroup = Core.Name "selectOrGroup"+_QueryBody_continuation = Core.Name "continuation"+data QueryBodyClause =+  QueryBodyClauseFrom FromClause |+  QueryBodyClauseLet LetClause |+  QueryBodyClauseWhere BooleanExpression |+  QueryBodyClauseJoin JoinClause |+  QueryBodyClauseOrderby [Ordering]+  deriving (Eq, Ord, Read, Show)+_QueryBodyClause = Core.Name "hydra.csharp.syntax.QueryBodyClause"+_QueryBodyClause_from = Core.Name "from"+_QueryBodyClause_let = Core.Name "let"+_QueryBodyClause_where = Core.Name "where"+_QueryBodyClause_join = Core.Name "join"+_QueryBodyClause_orderby = Core.Name "orderby"+data LetClause =+  LetClause {+    letClauseLeft :: Identifier,+    letClauseRight :: Expression}+  deriving (Eq, Ord, Read, Show)+_LetClause = Core.Name "hydra.csharp.syntax.LetClause"+_LetClause_left = Core.Name "left"+_LetClause_right = Core.Name "right"+data JoinClause =+  JoinClause {+    joinClauseType :: (Maybe Type),+    joinClauseIdentifier :: Identifier,+    joinClauseIn :: Expression,+    joinClauseOn :: Expression,+    joinClauseEquals :: Expression,+    joinClauseInto :: (Maybe Identifier)}+  deriving (Eq, Ord, Read, Show)+_JoinClause = Core.Name "hydra.csharp.syntax.JoinClause"+_JoinClause_type = Core.Name "type"+_JoinClause_identifier = Core.Name "identifier"+_JoinClause_in = Core.Name "in"+_JoinClause_on = Core.Name "on"+_JoinClause_equals = Core.Name "equals"+_JoinClause_into = Core.Name "into"+data Ordering =+  Ordering {+    orderingExpression :: Expression,+    orderingDirection :: (Maybe OrderingDirection)}+  deriving (Eq, Ord, Read, Show)+_Ordering = Core.Name "hydra.csharp.syntax.Ordering"+_Ordering_expression = Core.Name "expression"+_Ordering_direction = Core.Name "direction"+data OrderingDirection =+  OrderingDirectionAscending |+  OrderingDirectionDescending+  deriving (Eq, Ord, Read, Show)+_OrderingDirection = Core.Name "hydra.csharp.syntax.OrderingDirection"+_OrderingDirection_ascending = Core.Name "ascending"+_OrderingDirection_descending = Core.Name "descending"+data SelectOrGroupClause =+  SelectOrGroupClauseSelect Expression |+  SelectOrGroupClauseGroup GroupClause+  deriving (Eq, Ord, Read, Show)+_SelectOrGroupClause = Core.Name "hydra.csharp.syntax.SelectOrGroupClause"+_SelectOrGroupClause_select = Core.Name "select"+_SelectOrGroupClause_group = Core.Name "group"+data GroupClause =+  GroupClause {+    groupClauseGrouped :: Expression,+    groupClauseBy :: Expression}+  deriving (Eq, Ord, Read, Show)+_GroupClause = Core.Name "hydra.csharp.syntax.GroupClause"+_GroupClause_grouped = Core.Name "grouped"+_GroupClause_by = Core.Name "by"+data QueryContinuation =+  QueryContinuation {+    queryContinuationInto :: Identifier,+    queryContinuationBody :: QueryBody}+  deriving (Eq, Ord, Read, Show)+_QueryContinuation = Core.Name "hydra.csharp.syntax.QueryContinuation"+_QueryContinuation_into = Core.Name "into"+_QueryContinuation_body = Core.Name "body"+data Assignment =+  Assignment {+    assignmentLeft :: UnaryExpression,+    assignmentOperator :: AssignmentOperator,+    assignmentRight :: Expression}+  deriving (Eq, Ord, Read, Show)+_Assignment = Core.Name "hydra.csharp.syntax.Assignment"+_Assignment_left = Core.Name "left"+_Assignment_operator = Core.Name "operator"+_Assignment_right = Core.Name "right"+data AssignmentOperator =+  AssignmentOperatorSimple Bool |+  AssignmentOperatorPlusEquals |+  AssignmentOperatorMinusEquals |+  AssignmentOperatorTimesEquals |+  AssignmentOperatorDivideEquals |+  AssignmentOperatorModEquals |+  AssignmentOperatorAndEquals |+  AssignmentOperatorOrEquals |+  AssignmentOperatorXorEquals |+  AssignmentOperatorLeftShiftEquals |+  AssignmentOperatorRightShiftEquals+  deriving (Eq, Ord, Read, Show)+_AssignmentOperator = Core.Name "hydra.csharp.syntax.AssignmentOperator"+_AssignmentOperator_simple = Core.Name "simple"+_AssignmentOperator_plusEquals = Core.Name "plusEquals"+_AssignmentOperator_minusEquals = Core.Name "minusEquals"+_AssignmentOperator_timesEquals = Core.Name "timesEquals"+_AssignmentOperator_divideEquals = Core.Name "divideEquals"+_AssignmentOperator_modEquals = Core.Name "modEquals"+_AssignmentOperator_andEquals = Core.Name "andEquals"+_AssignmentOperator_orEquals = Core.Name "orEquals"+_AssignmentOperator_xorEquals = Core.Name "xorEquals"+_AssignmentOperator_leftShiftEquals = Core.Name "leftShiftEquals"+_AssignmentOperator_rightShiftEquals = Core.Name "rightShiftEquals"+data Expression =+  ExpressionNonAssignment NonAssignmentExpression |+  ExpressionAssignment Assignment+  deriving (Eq, Ord, Read, Show)+_Expression = Core.Name "hydra.csharp.syntax.Expression"+_Expression_nonAssignment = Core.Name "nonAssignment"+_Expression_assignment = Core.Name "assignment"+data NonAssignmentExpression =+  NonAssignmentExpressionDeclaration DeclarationExpression |+  NonAssignmentExpressionConditional ConditionalExpression |+  NonAssignmentExpressionLambda LambdaExpression |+  NonAssignmentExpressionQuery QueryExpression+  deriving (Eq, Ord, Read, Show)+_NonAssignmentExpression = Core.Name "hydra.csharp.syntax.NonAssignmentExpression"+_NonAssignmentExpression_declaration = Core.Name "declaration"+_NonAssignmentExpression_conditional = Core.Name "conditional"+_NonAssignmentExpression_lambda = Core.Name "lambda"+_NonAssignmentExpression_query = Core.Name "query"+newtype ConstantExpression =+  ConstantExpression {+    unConstantExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_ConstantExpression = Core.Name "hydra.csharp.syntax.ConstantExpression"+newtype BooleanExpression =+  BooleanExpression {+    unBooleanExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_BooleanExpression = Core.Name "hydra.csharp.syntax.BooleanExpression"+data Statement =+  StatementLabeled LabeledStatement |+  StatementDeclaration DeclarationStatement |+  StatementEmbedded EmbeddedStatement+  deriving (Eq, Ord, Read, Show)+_Statement = Core.Name "hydra.csharp.syntax.Statement"+_Statement_labeled = Core.Name "labeled"+_Statement_declaration = Core.Name "declaration"+_Statement_embedded = Core.Name "embedded"+data EmbeddedStatement =+  EmbeddedStatementBlock Block |+  EmbeddedStatementEmpty |+  EmbeddedStatementExpression StatementExpression |+  EmbeddedStatementSelection SelectionStatement |+  EmbeddedStatementIteration IterationStatement |+  EmbeddedStatementJump JumpStatement |+  EmbeddedStatementTry TryStatement |+  EmbeddedStatementChecked Block |+  EmbeddedStatementUnchecked Block |+  EmbeddedStatementLock LockStatement |+  EmbeddedStatementUsing UsingStatement |+  EmbeddedStatementYield YieldStatement |+  EmbeddedStatementUnsafe Block |+  EmbeddedStatementFixed FixedStatement+  deriving (Eq, Ord, Read, Show)+_EmbeddedStatement = Core.Name "hydra.csharp.syntax.EmbeddedStatement"+_EmbeddedStatement_block = Core.Name "block"+_EmbeddedStatement_empty = Core.Name "empty"+_EmbeddedStatement_expression = Core.Name "expression"+_EmbeddedStatement_selection = Core.Name "selection"+_EmbeddedStatement_iteration = Core.Name "iteration"+_EmbeddedStatement_jump = Core.Name "jump"+_EmbeddedStatement_try = Core.Name "try"+_EmbeddedStatement_checked = Core.Name "checked"+_EmbeddedStatement_unchecked = Core.Name "unchecked"+_EmbeddedStatement_lock = Core.Name "lock"+_EmbeddedStatement_using = Core.Name "using"+_EmbeddedStatement_yield = Core.Name "yield"+_EmbeddedStatement_unsafe = Core.Name "unsafe"+_EmbeddedStatement_fixed = Core.Name "fixed"+newtype Block =+  Block {+    unBlock :: [Statement]}+  deriving (Eq, Ord, Read, Show)+_Block = Core.Name "hydra.csharp.syntax.Block"+data LabeledStatement =+  LabeledStatement {+    labeledStatementLabel :: Identifier,+    labeledStatementStatement :: Statement}+  deriving (Eq, Ord, Read, Show)+_LabeledStatement = Core.Name "hydra.csharp.syntax.LabeledStatement"+_LabeledStatement_label = Core.Name "label"+_LabeledStatement_statement = Core.Name "statement"+data DeclarationStatement =+  DeclarationStatementVariable LocalVariableDeclaration |+  DeclarationStatementConstant LocalConstantDeclaration |+  DeclarationStatementFunction LocalFunctionDeclaration+  deriving (Eq, Ord, Read, Show)+_DeclarationStatement = Core.Name "hydra.csharp.syntax.DeclarationStatement"+_DeclarationStatement_variable = Core.Name "variable"+_DeclarationStatement_constant = Core.Name "constant"+_DeclarationStatement_function = Core.Name "function"+data LocalVariableDeclaration =+  LocalVariableDeclarationImplicitlyTyped ImplicitlyTypedLocalVariableDeclaration |+  LocalVariableDeclarationExplicitlyTyped ExplicitlyTypedLocalVariableDeclaration |+  LocalVariableDeclarationRef RefLocalVariableDeclaration+  deriving (Eq, Ord, Read, Show)+_LocalVariableDeclaration = Core.Name "hydra.csharp.syntax.LocalVariableDeclaration"+_LocalVariableDeclaration_implicitlyTyped = Core.Name "implicitlyTyped"+_LocalVariableDeclaration_explicitlyTyped = Core.Name "explicitlyTyped"+_LocalVariableDeclaration_ref = Core.Name "ref"+data ImplicitlyTypedLocalVariableDeclaration =+  ImplicitlyTypedLocalVariableDeclarationVar ImplicitlyTypedLocalVariableDeclarator |+  ImplicitlyTypedLocalVariableDeclarationRefVar RefVarImplicitlyTypedLocalVariableDeclaration+  deriving (Eq, Ord, Read, Show)+_ImplicitlyTypedLocalVariableDeclaration = Core.Name "hydra.csharp.syntax.ImplicitlyTypedLocalVariableDeclaration"+_ImplicitlyTypedLocalVariableDeclaration_var = Core.Name "var"+_ImplicitlyTypedLocalVariableDeclaration_refVar = Core.Name "refVar"+data RefVarImplicitlyTypedLocalVariableDeclaration =+  RefVarImplicitlyTypedLocalVariableDeclaration {+    refVarImplicitlyTypedLocalVariableDeclarationRefKind :: RefKind,+    refVarImplicitlyTypedLocalVariableDeclarationDeclarator :: RefLocalVariableDeclarator}+  deriving (Eq, Ord, Read, Show)+_RefVarImplicitlyTypedLocalVariableDeclaration =+    Core.Name "hydra.csharp.syntax.RefVarImplicitlyTypedLocalVariableDeclaration"+_RefVarImplicitlyTypedLocalVariableDeclaration_refKind = Core.Name "refKind"+_RefVarImplicitlyTypedLocalVariableDeclaration_declarator = Core.Name "declarator"+data ImplicitlyTypedLocalVariableDeclarator =+  ImplicitlyTypedLocalVariableDeclarator {+    implicitlyTypedLocalVariableDeclaratorIdentifier :: Identifier,+    implicitlyTypedLocalVariableDeclaratorExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_ImplicitlyTypedLocalVariableDeclarator = Core.Name "hydra.csharp.syntax.ImplicitlyTypedLocalVariableDeclarator"+_ImplicitlyTypedLocalVariableDeclarator_identifier = Core.Name "identifier"+_ImplicitlyTypedLocalVariableDeclarator_expression = Core.Name "expression"+data ExplicitlyTypedLocalVariableDeclaration =+  ExplicitlyTypedLocalVariableDeclaration {+    explicitlyTypedLocalVariableDeclarationType :: Type,+    explicitlyTypedLocalVariableDeclarationDeclarators :: [ExplicitlyTypedLocalVariableDeclarator]}+  deriving (Eq, Ord, Read, Show)+_ExplicitlyTypedLocalVariableDeclaration = Core.Name "hydra.csharp.syntax.ExplicitlyTypedLocalVariableDeclaration"+_ExplicitlyTypedLocalVariableDeclaration_type = Core.Name "type"+_ExplicitlyTypedLocalVariableDeclaration_declarators = Core.Name "declarators"+data ExplicitlyTypedLocalVariableDeclarator =+  ExplicitlyTypedLocalVariableDeclarator {+    explicitlyTypedLocalVariableDeclaratorIdentifier :: Identifier,+    explicitlyTypedLocalVariableDeclaratorInitializer :: (Maybe LocalVariableInitializer)}+  deriving (Eq, Ord, Read, Show)+_ExplicitlyTypedLocalVariableDeclarator = Core.Name "hydra.csharp.syntax.ExplicitlyTypedLocalVariableDeclarator"+_ExplicitlyTypedLocalVariableDeclarator_identifier = Core.Name "identifier"+_ExplicitlyTypedLocalVariableDeclarator_initializer = Core.Name "initializer"+data LocalVariableInitializer =+  LocalVariableInitializerExpression Expression |+  LocalVariableInitializerInitializer ArrayInitializer+  deriving (Eq, Ord, Read, Show)+_LocalVariableInitializer = Core.Name "hydra.csharp.syntax.LocalVariableInitializer"+_LocalVariableInitializer_expression = Core.Name "expression"+_LocalVariableInitializer_initializer = Core.Name "initializer"+data RefLocalVariableDeclaration =+  RefLocalVariableDeclaration {+    refLocalVariableDeclarationRefKind :: RefKind,+    refLocalVariableDeclarationType :: Type,+    refLocalVariableDeclarationDeclarators :: [RefLocalVariableDeclarator]}+  deriving (Eq, Ord, Read, Show)+_RefLocalVariableDeclaration = Core.Name "hydra.csharp.syntax.RefLocalVariableDeclaration"+_RefLocalVariableDeclaration_refKind = Core.Name "refKind"+_RefLocalVariableDeclaration_type = Core.Name "type"+_RefLocalVariableDeclaration_declarators = Core.Name "declarators"+data RefLocalVariableDeclarator =+  RefLocalVariableDeclarator {+    refLocalVariableDeclaratorLeft :: Identifier,+    refLocalVariableDeclaratorRight :: VariableReference}+  deriving (Eq, Ord, Read, Show)+_RefLocalVariableDeclarator = Core.Name "hydra.csharp.syntax.RefLocalVariableDeclarator"+_RefLocalVariableDeclarator_left = Core.Name "left"+_RefLocalVariableDeclarator_right = Core.Name "right"+data LocalConstantDeclaration =+  LocalConstantDeclaration {+    localConstantDeclarationType :: Type,+    localConstantDeclarationDeclarators :: [ConstantDeclarator]}+  deriving (Eq, Ord, Read, Show)+_LocalConstantDeclaration = Core.Name "hydra.csharp.syntax.LocalConstantDeclaration"+_LocalConstantDeclaration_type = Core.Name "type"+_LocalConstantDeclaration_declarators = Core.Name "declarators"+data ConstantDeclarator =+  ConstantDeclarator {+    constantDeclaratorIdentifier :: Identifier,+    constantDeclaratorExpression :: ConstantExpression}+  deriving (Eq, Ord, Read, Show)+_ConstantDeclarator = Core.Name "hydra.csharp.syntax.ConstantDeclarator"+_ConstantDeclarator_identifier = Core.Name "identifier"+_ConstantDeclarator_expression = Core.Name "expression"+data LocalFunctionDeclaration =+  LocalFunctionDeclarationStandard StandardLocalFunctionDeclaration |+  LocalFunctionDeclarationRef RefLocalFunctionDeclaration+  deriving (Eq, Ord, Read, Show)+_LocalFunctionDeclaration = Core.Name "hydra.csharp.syntax.LocalFunctionDeclaration"+_LocalFunctionDeclaration_standard = Core.Name "standard"+_LocalFunctionDeclaration_ref = Core.Name "ref"+data StandardLocalFunctionDeclaration =+  StandardLocalFunctionDeclaration {+    standardLocalFunctionDeclarationModifiers :: [LocalFunctionModifier],+    standardLocalFunctionDeclarationReturnType :: ReturnType,+    standardLocalFunctionDeclarationHeader :: LocalFunctionHeader,+    standardLocalFunctionDeclarationBody :: LocalFunctionBody}+  deriving (Eq, Ord, Read, Show)+_StandardLocalFunctionDeclaration = Core.Name "hydra.csharp.syntax.StandardLocalFunctionDeclaration"+_StandardLocalFunctionDeclaration_modifiers = Core.Name "modifiers"+_StandardLocalFunctionDeclaration_returnType = Core.Name "returnType"+_StandardLocalFunctionDeclaration_header = Core.Name "header"+_StandardLocalFunctionDeclaration_body = Core.Name "body"+data RefLocalFunctionDeclaration =+  RefLocalFunctionDeclaration {+    refLocalFunctionDeclarationModifiers :: [RefLocalFunctionModifier],+    refLocalFunctionDeclarationRefKind :: RefKind,+    refLocalFunctionDeclarationReturnType :: Type,+    refLocalFunctionDeclarationHeader :: LocalFunctionHeader,+    refLocalFunctionDeclarationBody :: RefLocalFunctionBody}+  deriving (Eq, Ord, Read, Show)+_RefLocalFunctionDeclaration = Core.Name "hydra.csharp.syntax.RefLocalFunctionDeclaration"+_RefLocalFunctionDeclaration_modifiers = Core.Name "modifiers"+_RefLocalFunctionDeclaration_refKind = Core.Name "refKind"+_RefLocalFunctionDeclaration_returnType = Core.Name "returnType"+_RefLocalFunctionDeclaration_header = Core.Name "header"+_RefLocalFunctionDeclaration_body = Core.Name "body"+data LocalFunctionHeader =+  LocalFunctionHeader {+    localFunctionHeaderIdentifier :: Identifier,+    localFunctionHeaderTypeParameters :: (Maybe TypeParameterList),+    localFunctionHeaderParameters :: FormalParameterList,+    localFunctionHeaderConstraints :: [TypeParameterConstraintsClause]}+  deriving (Eq, Ord, Read, Show)+_LocalFunctionHeader = Core.Name "hydra.csharp.syntax.LocalFunctionHeader"+_LocalFunctionHeader_identifier = Core.Name "identifier"+_LocalFunctionHeader_typeParameters = Core.Name "typeParameters"+_LocalFunctionHeader_parameters = Core.Name "parameters"+_LocalFunctionHeader_constraints = Core.Name "constraints"+data LocalFunctionModifier =+  LocalFunctionModifierRef RefLocalFunctionModifier |+  LocalFunctionModifierAsync+  deriving (Eq, Ord, Read, Show)+_LocalFunctionModifier = Core.Name "hydra.csharp.syntax.LocalFunctionModifier"+_LocalFunctionModifier_ref = Core.Name "ref"+_LocalFunctionModifier_async = Core.Name "async"+data RefLocalFunctionModifier =+  RefLocalFunctionModifierStatic |+  RefLocalFunctionModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_RefLocalFunctionModifier = Core.Name "hydra.csharp.syntax.RefLocalFunctionModifier"+_RefLocalFunctionModifier_static = Core.Name "static"+_RefLocalFunctionModifier_unsafe = Core.Name "unsafe"+data LocalFunctionBody =+  LocalFunctionBodyBlock Block |+  LocalFunctionBodyNullConditionalInvocation NullConditionalInvocationExpression |+  LocalFunctionBodyExpression Expression+  deriving (Eq, Ord, Read, Show)+_LocalFunctionBody = Core.Name "hydra.csharp.syntax.LocalFunctionBody"+_LocalFunctionBody_block = Core.Name "block"+_LocalFunctionBody_nullConditionalInvocation = Core.Name "nullConditionalInvocation"+_LocalFunctionBody_expression = Core.Name "expression"+data RefLocalFunctionBody =+  RefLocalFunctionBodyBlock Block |+  RefLocalFunctionBodyRef VariableReference+  deriving (Eq, Ord, Read, Show)+_RefLocalFunctionBody = Core.Name "hydra.csharp.syntax.RefLocalFunctionBody"+_RefLocalFunctionBody_block = Core.Name "block"+_RefLocalFunctionBody_ref = Core.Name "ref"+data StatementExpression =+  StatementExpressionNullConditionalInvocation NullConditionalInvocationExpression |+  StatementExpressionInvocation InvocationExpression |+  StatementExpressionObjectCreation ObjectCreationExpression |+  StatementExpressionAssignment Assignment |+  StatementExpressionPostIncrement PrimaryExpression |+  StatementExpressionPostDecrement PrimaryExpression |+  StatementExpressionPreIncrement UnaryExpression |+  StatementExpressionPreDecrement UnaryExpression |+  StatementExpressionAwait UnaryExpression+  deriving (Eq, Ord, Read, Show)+_StatementExpression = Core.Name "hydra.csharp.syntax.StatementExpression"+_StatementExpression_nullConditionalInvocation = Core.Name "nullConditionalInvocation"+_StatementExpression_invocation = Core.Name "invocation"+_StatementExpression_objectCreation = Core.Name "objectCreation"+_StatementExpression_assignment = Core.Name "assignment"+_StatementExpression_postIncrement = Core.Name "postIncrement"+_StatementExpression_postDecrement = Core.Name "postDecrement"+_StatementExpression_preIncrement = Core.Name "preIncrement"+_StatementExpression_preDecrement = Core.Name "preDecrement"+_StatementExpression_await = Core.Name "await"+data SelectionStatement =+  SelectionStatementIf IfStatement |+  SelectionStatementSwitch SwitchStatement+  deriving (Eq, Ord, Read, Show)+_SelectionStatement = Core.Name "hydra.csharp.syntax.SelectionStatement"+_SelectionStatement_if = Core.Name "if"+_SelectionStatement_switch = Core.Name "switch"+data IfStatement =+  IfStatement {+    ifStatementCondition :: BooleanExpression,+    ifStatementIfBranch :: EmbeddedStatement,+    ifStatementElseBranch :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_IfStatement = Core.Name "hydra.csharp.syntax.IfStatement"+_IfStatement_condition = Core.Name "condition"+_IfStatement_ifBranch = Core.Name "ifBranch"+_IfStatement_elseBranch = Core.Name "elseBranch"+data SwitchStatement =+  SwitchStatement {+    switchStatementExpression :: Expression,+    switchStatementBranches :: [SwitchSection]}+  deriving (Eq, Ord, Read, Show)+_SwitchStatement = Core.Name "hydra.csharp.syntax.SwitchStatement"+_SwitchStatement_expression = Core.Name "expression"+_SwitchStatement_branches = Core.Name "branches"+data SwitchSection =+  SwitchSection {+    switchSectionLabels :: [SwitchLabel],+    switchSectionStatements :: [Statement]}+  deriving (Eq, Ord, Read, Show)+_SwitchSection = Core.Name "hydra.csharp.syntax.SwitchSection"+_SwitchSection_labels = Core.Name "labels"+_SwitchSection_statements = Core.Name "statements"+data SwitchLabel =+  SwitchLabelBranch SwitchBranch |+  SwitchLabelDefault+  deriving (Eq, Ord, Read, Show)+_SwitchLabel = Core.Name "hydra.csharp.syntax.SwitchLabel"+_SwitchLabel_branch = Core.Name "branch"+_SwitchLabel_default = Core.Name "default"+data SwitchBranch =+  SwitchBranch {+    switchBranchPattern :: Pattern,+    switchBranchGuard :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_SwitchBranch = Core.Name "hydra.csharp.syntax.SwitchBranch"+_SwitchBranch_pattern = Core.Name "pattern"+_SwitchBranch_guard = Core.Name "guard"+data IterationStatement =+  IterationStatementWhile WhileStatement |+  IterationStatementDo DoStatement |+  IterationStatementFor ForStatement |+  IterationStatementForeach ForeachStatement+  deriving (Eq, Ord, Read, Show)+_IterationStatement = Core.Name "hydra.csharp.syntax.IterationStatement"+_IterationStatement_while = Core.Name "while"+_IterationStatement_do = Core.Name "do"+_IterationStatement_for = Core.Name "for"+_IterationStatement_foreach = Core.Name "foreach"+data WhileStatement =+  WhileStatement {+    whileStatementCondition :: BooleanExpression,+    whileStatementBody :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_WhileStatement = Core.Name "hydra.csharp.syntax.WhileStatement"+_WhileStatement_condition = Core.Name "condition"+_WhileStatement_body = Core.Name "body"+data DoStatement =+  DoStatement {+    doStatementBody :: EmbeddedStatement,+    doStatementWhile :: BooleanExpression}+  deriving (Eq, Ord, Read, Show)+_DoStatement = Core.Name "hydra.csharp.syntax.DoStatement"+_DoStatement_body = Core.Name "body"+_DoStatement_while = Core.Name "while"+data ForStatement =+  ForStatement {+    forStatementInitializer :: (Maybe ForInitializer),+    forStatementCondition :: (Maybe BooleanExpression),+    forStatementIterator :: (Maybe StatementExpressionList),+    forStatementBody :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_ForStatement = Core.Name "hydra.csharp.syntax.ForStatement"+_ForStatement_initializer = Core.Name "initializer"+_ForStatement_condition = Core.Name "condition"+_ForStatement_iterator = Core.Name "iterator"+_ForStatement_body = Core.Name "body"+data ForInitializer =+  ForInitializerVariable LocalVariableDeclaration |+  ForInitializerStatements StatementExpressionList+  deriving (Eq, Ord, Read, Show)+_ForInitializer = Core.Name "hydra.csharp.syntax.ForInitializer"+_ForInitializer_variable = Core.Name "variable"+_ForInitializer_statements = Core.Name "statements"+newtype StatementExpressionList =+  StatementExpressionList {+    unStatementExpressionList :: [StatementExpression]}+  deriving (Eq, Ord, Read, Show)+_StatementExpressionList = Core.Name "hydra.csharp.syntax.StatementExpressionList"+data ForeachStatement =+  ForeachStatement {+    foreachStatementKind :: (Maybe RefKind),+    foreachStatementType :: LocalVariableType,+    foreachStatementIdentifier :: Identifier,+    foreachStatementExpression :: Expression,+    foreachStatementBody :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_ForeachStatement = Core.Name "hydra.csharp.syntax.ForeachStatement"+_ForeachStatement_kind = Core.Name "kind"+_ForeachStatement_type = Core.Name "type"+_ForeachStatement_identifier = Core.Name "identifier"+_ForeachStatement_expression = Core.Name "expression"+_ForeachStatement_body = Core.Name "body"+data JumpStatement =+  JumpStatementBreak |+  JumpStatementContinue |+  JumpStatementGoto GotoStatement |+  JumpStatementReturn ReturnStatement |+  JumpStatementThrow (Maybe Expression)+  deriving (Eq, Ord, Read, Show)+_JumpStatement = Core.Name "hydra.csharp.syntax.JumpStatement"+_JumpStatement_break = Core.Name "break"+_JumpStatement_continue = Core.Name "continue"+_JumpStatement_goto = Core.Name "goto"+_JumpStatement_return = Core.Name "return"+_JumpStatement_throw = Core.Name "throw"+data GotoStatement =+  GotoStatementIdentifier Identifier |+  GotoStatementCase ConstantExpression |+  GotoStatementDefault+  deriving (Eq, Ord, Read, Show)+_GotoStatement = Core.Name "hydra.csharp.syntax.GotoStatement"+_GotoStatement_identifier = Core.Name "identifier"+_GotoStatement_case = Core.Name "case"+_GotoStatement_default = Core.Name "default"+data ReturnStatement =+  ReturnStatementSimple |+  ReturnStatementValue Expression |+  ReturnStatementRef VariableReference+  deriving (Eq, Ord, Read, Show)+_ReturnStatement = Core.Name "hydra.csharp.syntax.ReturnStatement"+_ReturnStatement_simple = Core.Name "simple"+_ReturnStatement_value = Core.Name "value"+_ReturnStatement_ref = Core.Name "ref"+data TryStatement =+  TryStatement {+    tryStatementBody :: Block,+    tryStatementCatches :: CatchClauses,+    tryStatementFinally :: (Maybe Block)}+  deriving (Eq, Ord, Read, Show)+_TryStatement = Core.Name "hydra.csharp.syntax.TryStatement"+_TryStatement_body = Core.Name "body"+_TryStatement_catches = Core.Name "catches"+_TryStatement_finally = Core.Name "finally"+data CatchClauses =+  CatchClausesSpecific [SpecificCatchClause] |+  CatchClausesGeneral Block+  deriving (Eq, Ord, Read, Show)+_CatchClauses = Core.Name "hydra.csharp.syntax.CatchClauses"+_CatchClauses_specific = Core.Name "specific"+_CatchClauses_general = Core.Name "general"+data SpecificCatchClause =+  SpecificCatchClause {+    specificCatchClauseSpecifier :: (Maybe ExceptionSpecifier),+    specificCatchClauseFilter :: (Maybe BooleanExpression),+    specificCatchClauseBody :: Block}+  deriving (Eq, Ord, Read, Show)+_SpecificCatchClause = Core.Name "hydra.csharp.syntax.SpecificCatchClause"+_SpecificCatchClause_specifier = Core.Name "specifier"+_SpecificCatchClause_filter = Core.Name "filter"+_SpecificCatchClause_body = Core.Name "body"+data ExceptionSpecifier =+  ExceptionSpecifier {+    exceptionSpecifierType :: Type,+    exceptionSpecifierIdentifier :: (Maybe Identifier)}+  deriving (Eq, Ord, Read, Show)+_ExceptionSpecifier = Core.Name "hydra.csharp.syntax.ExceptionSpecifier"+_ExceptionSpecifier_type = Core.Name "type"+_ExceptionSpecifier_identifier = Core.Name "identifier"+data LockStatement =+  LockStatement {+    lockStatementExpression :: Expression,+    lockStatementBody :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_LockStatement = Core.Name "hydra.csharp.syntax.LockStatement"+_LockStatement_expression = Core.Name "expression"+_LockStatement_body = Core.Name "body"+data UsingStatement =+  UsingStatement {+    usingStatementAcquisition :: ResourceAcquisition,+    usingStatementBody :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_UsingStatement = Core.Name "hydra.csharp.syntax.UsingStatement"+_UsingStatement_acquisition = Core.Name "acquisition"+_UsingStatement_body = Core.Name "body"+data ResourceAcquisition =+  ResourceAcquisitionLocal LocalVariableDeclaration |+  ResourceAcquisitionExpression Expression+  deriving (Eq, Ord, Read, Show)+_ResourceAcquisition = Core.Name "hydra.csharp.syntax.ResourceAcquisition"+_ResourceAcquisition_local = Core.Name "local"+_ResourceAcquisition_expression = Core.Name "expression"+data YieldStatement =+  YieldStatementReturn Expression |+  YieldStatementBreak+  deriving (Eq, Ord, Read, Show)+_YieldStatement = Core.Name "hydra.csharp.syntax.YieldStatement"+_YieldStatement_return = Core.Name "return"+_YieldStatement_break = Core.Name "break"+data CompilationUnit =+  CompilationUnit {+    compilationUnitExterns :: [ExternAliasDirective],+    compilationUnitUsings :: [UsingDirective],+    compilationUnitAttributes :: [GlobalAttributeSection],+    compilationUnitMembers :: [NamespaceMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_CompilationUnit = Core.Name "hydra.csharp.syntax.CompilationUnit"+_CompilationUnit_externs = Core.Name "externs"+_CompilationUnit_usings = Core.Name "usings"+_CompilationUnit_attributes = Core.Name "attributes"+_CompilationUnit_members = Core.Name "members"+data NamespaceDeclaration =+  NamespaceDeclaration {+    namespaceDeclarationName :: QualifiedIdentifier,+    namespaceDeclarationBody :: NamespaceBody}+  deriving (Eq, Ord, Read, Show)+_NamespaceDeclaration = Core.Name "hydra.csharp.syntax.NamespaceDeclaration"+_NamespaceDeclaration_name = Core.Name "name"+_NamespaceDeclaration_body = Core.Name "body"+newtype QualifiedIdentifier =+  QualifiedIdentifier {+    unQualifiedIdentifier :: [Identifier]}+  deriving (Eq, Ord, Read, Show)+_QualifiedIdentifier = Core.Name "hydra.csharp.syntax.QualifiedIdentifier"+data NamespaceBody =+  NamespaceBody {+    namespaceBodyExterns :: [ExternAliasDirective],+    namespaceBodyUsings :: [UsingDirective],+    namespaceBodyMembers :: [NamespaceMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_NamespaceBody = Core.Name "hydra.csharp.syntax.NamespaceBody"+_NamespaceBody_externs = Core.Name "externs"+_NamespaceBody_usings = Core.Name "usings"+_NamespaceBody_members = Core.Name "members"+newtype ExternAliasDirective =+  ExternAliasDirective {+    unExternAliasDirective :: Identifier}+  deriving (Eq, Ord, Read, Show)+_ExternAliasDirective = Core.Name "hydra.csharp.syntax.ExternAliasDirective"+data UsingDirective =+  UsingDirectiveAlias UsingAliasDirective |+  UsingDirectiveNamespace NamespaceName |+  UsingDirectiveStatic TypeName+  deriving (Eq, Ord, Read, Show)+_UsingDirective = Core.Name "hydra.csharp.syntax.UsingDirective"+_UsingDirective_alias = Core.Name "alias"+_UsingDirective_namespace = Core.Name "namespace"+_UsingDirective_static = Core.Name "static"+data UsingAliasDirective =+  UsingAliasDirective {+    usingAliasDirectiveAlias :: Identifier,+    usingAliasDirectiveName :: NamespaceOrTypeName}+  deriving (Eq, Ord, Read, Show)+_UsingAliasDirective = Core.Name "hydra.csharp.syntax.UsingAliasDirective"+_UsingAliasDirective_alias = Core.Name "alias"+_UsingAliasDirective_name = Core.Name "name"+data NamespaceMemberDeclaration =+  NamespaceMemberDeclarationNamespace NamespaceDeclaration |+  NamespaceMemberDeclarationType TypeDeclaration+  deriving (Eq, Ord, Read, Show)+_NamespaceMemberDeclaration = Core.Name "hydra.csharp.syntax.NamespaceMemberDeclaration"+_NamespaceMemberDeclaration_namespace = Core.Name "namespace"+_NamespaceMemberDeclaration_type = Core.Name "type"+data TypeDeclaration =+  TypeDeclarationClass ClassDeclaration |+  TypeDeclarationStruct StructDeclaration |+  TypeDeclarationInterface InterfaceDeclaration |+  TypeDeclarationEnum EnumDeclaration |+  TypeDeclarationDelegate DelegateDeclaration+  deriving (Eq, Ord, Read, Show)+_TypeDeclaration = Core.Name "hydra.csharp.syntax.TypeDeclaration"+_TypeDeclaration_class = Core.Name "class"+_TypeDeclaration_struct = Core.Name "struct"+_TypeDeclaration_interface = Core.Name "interface"+_TypeDeclaration_enum = Core.Name "enum"+_TypeDeclaration_delegate = Core.Name "delegate"+data QualifiedAliasMember =+  QualifiedAliasMember {+    qualifiedAliasMemberAlias :: Identifier,+    qualifiedAliasMemberMember :: Identifier,+    qualifiedAliasMemberArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_QualifiedAliasMember = Core.Name "hydra.csharp.syntax.QualifiedAliasMember"+_QualifiedAliasMember_alias = Core.Name "alias"+_QualifiedAliasMember_member = Core.Name "member"+_QualifiedAliasMember_arguments = Core.Name "arguments"+data ClassDeclaration =+  ClassDeclaration {+    classDeclarationAttributes :: [AttributeSection],+    classDeclarationModifiers :: [ClassModifier],+    classDeclarationPartial :: Bool,+    classDeclarationName :: Identifier,+    classDeclarationParameters :: (Maybe TypeParameterList),+    classDeclarationBase :: (Maybe ClassBase),+    classDeclarationConstraints :: [TypeParameterConstraintsClause],+    classDeclarationBody :: ClassBody}+  deriving (Eq, Ord, Read, Show)+_ClassDeclaration = Core.Name "hydra.csharp.syntax.ClassDeclaration"+_ClassDeclaration_attributes = Core.Name "attributes"+_ClassDeclaration_modifiers = Core.Name "modifiers"+_ClassDeclaration_partial = Core.Name "partial"+_ClassDeclaration_name = Core.Name "name"+_ClassDeclaration_parameters = Core.Name "parameters"+_ClassDeclaration_base = Core.Name "base"+_ClassDeclaration_constraints = Core.Name "constraints"+_ClassDeclaration_body = Core.Name "body"+data ClassModifier =+  ClassModifierNew |+  ClassModifierPublic |+  ClassModifierProtected |+  ClassModifierInternal |+  ClassModifierPrivate |+  ClassModifierAbstract |+  ClassModifierSealed |+  ClassModifierStatic |+  ClassModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_ClassModifier = Core.Name "hydra.csharp.syntax.ClassModifier"+_ClassModifier_new = Core.Name "new"+_ClassModifier_public = Core.Name "public"+_ClassModifier_protected = Core.Name "protected"+_ClassModifier_internal = Core.Name "internal"+_ClassModifier_private = Core.Name "private"+_ClassModifier_abstract = Core.Name "abstract"+_ClassModifier_sealed = Core.Name "sealed"+_ClassModifier_static = Core.Name "static"+_ClassModifier_unsafe = Core.Name "unsafe"+newtype TypeParameterList =+  TypeParameterList {+    unTypeParameterList :: [TypeParameterPart]}+  deriving (Eq, Ord, Read, Show)+_TypeParameterList = Core.Name "hydra.csharp.syntax.TypeParameterList"+data TypeParameterPart =+  TypeParameterPart {+    typeParameterPartAttributes :: (Maybe Attributes),+    typeParameterPartName :: TypeParameter}+  deriving (Eq, Ord, Read, Show)+_TypeParameterPart = Core.Name "hydra.csharp.syntax.TypeParameterPart"+_TypeParameterPart_attributes = Core.Name "attributes"+_TypeParameterPart_name = Core.Name "name"+data ClassBase =+  ClassBaseClass (Maybe ClassType) |+  ClassBaseInterfaces [InterfaceType]+  deriving (Eq, Ord, Read, Show)+_ClassBase = Core.Name "hydra.csharp.syntax.ClassBase"+_ClassBase_class = Core.Name "class"+_ClassBase_interfaces = Core.Name "interfaces"+data TypeParameterConstraintsClause =+  TypeParameterConstraintsClause {+    typeParameterConstraintsClauseParameter :: TypeParameter,+    typeParameterConstraintsClauseConstraints :: [TypeParameterConstraints]}+  deriving (Eq, Ord, Read, Show)+_TypeParameterConstraintsClause = Core.Name "hydra.csharp.syntax.TypeParameterConstraintsClause"+_TypeParameterConstraintsClause_parameter = Core.Name "parameter"+_TypeParameterConstraintsClause_constraints = Core.Name "constraints"+data TypeParameterConstraints =+  TypeParameterConstraints {+    typeParameterConstraintsPrimary :: (Maybe PrimaryConstraint),+    typeParameterConstraintsSecondary :: (Maybe SecondaryConstraints),+    typeParameterConstraintsConstructor :: Bool}+  deriving (Eq, Ord, Read, Show)+_TypeParameterConstraints = Core.Name "hydra.csharp.syntax.TypeParameterConstraints"+_TypeParameterConstraints_primary = Core.Name "primary"+_TypeParameterConstraints_secondary = Core.Name "secondary"+_TypeParameterConstraints_constructor = Core.Name "constructor"+data PrimaryConstraint =+  PrimaryConstraintClassType ClassType |+  PrimaryConstraintClass |+  PrimaryConstraintStruct |+  PrimaryConstraintUnmanaged+  deriving (Eq, Ord, Read, Show)+_PrimaryConstraint = Core.Name "hydra.csharp.syntax.PrimaryConstraint"+_PrimaryConstraint_classType = Core.Name "classType"+_PrimaryConstraint_class = Core.Name "class"+_PrimaryConstraint_struct = Core.Name "struct"+_PrimaryConstraint_unmanaged = Core.Name "unmanaged"+newtype SecondaryConstraints =+  SecondaryConstraints {+    unSecondaryConstraints :: [SecondaryConstraint]}+  deriving (Eq, Ord, Read, Show)+_SecondaryConstraints = Core.Name "hydra.csharp.syntax.SecondaryConstraints"+data SecondaryConstraint =+  SecondaryConstraintInterface InterfaceType |+  SecondaryConstraintParameter TypeParameter+  deriving (Eq, Ord, Read, Show)+_SecondaryConstraint = Core.Name "hydra.csharp.syntax.SecondaryConstraint"+_SecondaryConstraint_interface = Core.Name "interface"+_SecondaryConstraint_parameter = Core.Name "parameter"+newtype ClassBody =+  ClassBody {+    unClassBody :: [ClassMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_ClassBody = Core.Name "hydra.csharp.syntax.ClassBody"+data ClassMemberDeclaration =+  ClassMemberDeclarationConstant ConstantDeclaration |+  ClassMemberDeclarationField FieldDeclaration |+  ClassMemberDeclarationMethod MethodDeclaration |+  ClassMemberDeclarationProperty PropertyDeclaration |+  ClassMemberDeclarationEvent EventDeclaration |+  ClassMemberDeclarationIndexer IndexerDeclaration |+  ClassMemberDeclarationOperator OperatorDeclaration |+  ClassMemberDeclarationConstructor ConstructorDeclaration |+  ClassMemberDeclarationFinalizer FinalizerDeclaration |+  ClassMemberDeclarationStaticConstructor StaticConstructorDeclaration |+  ClassMemberDeclarationType TypeDeclaration+  deriving (Eq, Ord, Read, Show)+_ClassMemberDeclaration = Core.Name "hydra.csharp.syntax.ClassMemberDeclaration"+_ClassMemberDeclaration_constant = Core.Name "constant"+_ClassMemberDeclaration_field = Core.Name "field"+_ClassMemberDeclaration_method = Core.Name "method"+_ClassMemberDeclaration_property = Core.Name "property"+_ClassMemberDeclaration_event = Core.Name "event"+_ClassMemberDeclaration_indexer = Core.Name "indexer"+_ClassMemberDeclaration_operator = Core.Name "operator"+_ClassMemberDeclaration_constructor = Core.Name "constructor"+_ClassMemberDeclaration_finalizer = Core.Name "finalizer"+_ClassMemberDeclaration_staticConstructor = Core.Name "staticConstructor"+_ClassMemberDeclaration_type = Core.Name "type"+data ConstantDeclaration =+  ConstantDeclaration {+    constantDeclarationAttributes :: (Maybe Attributes),+    constantDeclarationModifiers :: [ConstantModifier],+    constantDeclarationType :: Type,+    constantDeclarationDeclarators :: [ConstantDeclarator]}+  deriving (Eq, Ord, Read, Show)+_ConstantDeclaration = Core.Name "hydra.csharp.syntax.ConstantDeclaration"+_ConstantDeclaration_attributes = Core.Name "attributes"+_ConstantDeclaration_modifiers = Core.Name "modifiers"+_ConstantDeclaration_type = Core.Name "type"+_ConstantDeclaration_declarators = Core.Name "declarators"+data ConstantModifier =+  ConstantModifierNew |+  ConstantModifierPublic |+  ConstantModifierProtected |+  ConstantModifierInternal |+  ConstantModifierPrivate+  deriving (Eq, Ord, Read, Show)+_ConstantModifier = Core.Name "hydra.csharp.syntax.ConstantModifier"+_ConstantModifier_new = Core.Name "new"+_ConstantModifier_public = Core.Name "public"+_ConstantModifier_protected = Core.Name "protected"+_ConstantModifier_internal = Core.Name "internal"+_ConstantModifier_private = Core.Name "private"+data FieldDeclaration =+  FieldDeclaration {+    fieldDeclarationAttributes :: (Maybe Attributes),+    fieldDeclarationModifiers :: [FieldModifier],+    fieldDeclarationType :: Type,+    fieldDeclarationDeclarators :: [VariableDeclarator]}+  deriving (Eq, Ord, Read, Show)+_FieldDeclaration = Core.Name "hydra.csharp.syntax.FieldDeclaration"+_FieldDeclaration_attributes = Core.Name "attributes"+_FieldDeclaration_modifiers = Core.Name "modifiers"+_FieldDeclaration_type = Core.Name "type"+_FieldDeclaration_declarators = Core.Name "declarators"+data FieldModifier =+  FieldModifierNew |+  FieldModifierPublic |+  FieldModifierProtected |+  FieldModifierInternal |+  FieldModifierPrivate |+  FieldModifierStatic |+  FieldModifierReadonly |+  FieldModifierVolatile |+  FieldModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_FieldModifier = Core.Name "hydra.csharp.syntax.FieldModifier"+_FieldModifier_new = Core.Name "new"+_FieldModifier_public = Core.Name "public"+_FieldModifier_protected = Core.Name "protected"+_FieldModifier_internal = Core.Name "internal"+_FieldModifier_private = Core.Name "private"+_FieldModifier_static = Core.Name "static"+_FieldModifier_readonly = Core.Name "readonly"+_FieldModifier_volatile = Core.Name "volatile"+_FieldModifier_unsafe = Core.Name "unsafe"+newtype VariableDeclarators =+  VariableDeclarators {+    unVariableDeclarators :: [VariableDeclarator]}+  deriving (Eq, Ord, Read, Show)+_VariableDeclarators = Core.Name "hydra.csharp.syntax.VariableDeclarators"+data VariableDeclarator =+  VariableDeclarator {+    variableDeclaratorIdentifier :: Identifier,+    variableDeclaratorInitializer :: (Maybe VariableInitializer)}+  deriving (Eq, Ord, Read, Show)+_VariableDeclarator = Core.Name "hydra.csharp.syntax.VariableDeclarator"+_VariableDeclarator_identifier = Core.Name "identifier"+_VariableDeclarator_initializer = Core.Name "initializer"+data MethodDeclaration =+  MethodDeclarationStandard StandardMethodDeclaration |+  MethodDeclarationRefReturn RefReturnMethodDeclaration+  deriving (Eq, Ord, Read, Show)+_MethodDeclaration = Core.Name "hydra.csharp.syntax.MethodDeclaration"+_MethodDeclaration_standard = Core.Name "standard"+_MethodDeclaration_refReturn = Core.Name "refReturn"+data StandardMethodDeclaration =+  StandardMethodDeclaration {+    standardMethodDeclarationAttributes :: (Maybe Attributes),+    standardMethodDeclarationModifiers :: [MethodModifier],+    standardMethodDeclarationReturnType :: ReturnType,+    standardMethodDeclarationHeader :: MethodHeader,+    standardMethodDeclarationBody :: MethodBody}+  deriving (Eq, Ord, Read, Show)+_StandardMethodDeclaration = Core.Name "hydra.csharp.syntax.StandardMethodDeclaration"+_StandardMethodDeclaration_attributes = Core.Name "attributes"+_StandardMethodDeclaration_modifiers = Core.Name "modifiers"+_StandardMethodDeclaration_returnType = Core.Name "returnType"+_StandardMethodDeclaration_header = Core.Name "header"+_StandardMethodDeclaration_body = Core.Name "body"+data RefReturnMethodDeclaration =+  RefReturnMethodDeclaration {+    refReturnMethodDeclarationAttributes :: (Maybe Attributes),+    refReturnMethodDeclarationModifiers :: [RefMethodModifier],+    refReturnMethodDeclarationKind :: RefKind,+    refReturnMethodDeclarationReturnType :: ReturnType,+    refReturnMethodDeclarationHeader :: MethodHeader,+    refReturnMethodDeclarationBody :: RefMethodBody}+  deriving (Eq, Ord, Read, Show)+_RefReturnMethodDeclaration = Core.Name "hydra.csharp.syntax.RefReturnMethodDeclaration"+_RefReturnMethodDeclaration_attributes = Core.Name "attributes"+_RefReturnMethodDeclaration_modifiers = Core.Name "modifiers"+_RefReturnMethodDeclaration_kind = Core.Name "kind"+_RefReturnMethodDeclaration_returnType = Core.Name "returnType"+_RefReturnMethodDeclaration_header = Core.Name "header"+_RefReturnMethodDeclaration_body = Core.Name "body"+data MethodModifiers =+  MethodModifiers {+    methodModifiersModifiers :: [MethodModifier],+    methodModifiersPartial :: Bool}+  deriving (Eq, Ord, Read, Show)+_MethodModifiers = Core.Name "hydra.csharp.syntax.MethodModifiers"+_MethodModifiers_modifiers = Core.Name "modifiers"+_MethodModifiers_partial = Core.Name "partial"+data RefKind =+  RefKindRef |+  RefKindRefReadonly+  deriving (Eq, Ord, Read, Show)+_RefKind = Core.Name "hydra.csharp.syntax.RefKind"+_RefKind_ref = Core.Name "ref"+_RefKind_refReadonly = Core.Name "refReadonly"+data MethodHeader =+  MethodHeader {+    methodHeaderName :: MemberName,+    methodHeaderTypeParameters :: (Maybe TypeParameterList),+    methodHeaderParameters :: (Maybe FormalParameterList),+    methodHeaderConstraints :: [TypeParameterConstraintsClause]}+  deriving (Eq, Ord, Read, Show)+_MethodHeader = Core.Name "hydra.csharp.syntax.MethodHeader"+_MethodHeader_name = Core.Name "name"+_MethodHeader_typeParameters = Core.Name "typeParameters"+_MethodHeader_parameters = Core.Name "parameters"+_MethodHeader_constraints = Core.Name "constraints"+data MethodModifier =+  MethodModifierRef RefMethodModifier |+  MethodModifierAsync+  deriving (Eq, Ord, Read, Show)+_MethodModifier = Core.Name "hydra.csharp.syntax.MethodModifier"+_MethodModifier_ref = Core.Name "ref"+_MethodModifier_async = Core.Name "async"+data RefMethodModifier =+  RefMethodModifierNew |+  RefMethodModifierPublic |+  RefMethodModifierProtected |+  RefMethodModifierInternal |+  RefMethodModifierPrivate |+  RefMethodModifierStatic |+  RefMethodModifierVirtual |+  RefMethodModifierSealed |+  RefMethodModifierOverride |+  RefMethodModifierAbstract |+  RefMethodModifierExtern |+  RefMethodModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_RefMethodModifier = Core.Name "hydra.csharp.syntax.RefMethodModifier"+_RefMethodModifier_new = Core.Name "new"+_RefMethodModifier_public = Core.Name "public"+_RefMethodModifier_protected = Core.Name "protected"+_RefMethodModifier_internal = Core.Name "internal"+_RefMethodModifier_private = Core.Name "private"+_RefMethodModifier_static = Core.Name "static"+_RefMethodModifier_virtual = Core.Name "virtual"+_RefMethodModifier_sealed = Core.Name "sealed"+_RefMethodModifier_override = Core.Name "override"+_RefMethodModifier_abstract = Core.Name "abstract"+_RefMethodModifier_extern = Core.Name "extern"+_RefMethodModifier_unsafe = Core.Name "unsafe"+data ReturnType =+  ReturnTypeRef Type |+  ReturnTypeVoid+  deriving (Eq, Ord, Read, Show)+_ReturnType = Core.Name "hydra.csharp.syntax.ReturnType"+_ReturnType_ref = Core.Name "ref"+_ReturnType_void = Core.Name "void"+data MemberName =+  MemberName {+    memberNameInterfaceType :: (Maybe TypeName),+    memberNameIdentifier :: Identifier}+  deriving (Eq, Ord, Read, Show)+_MemberName = Core.Name "hydra.csharp.syntax.MemberName"+_MemberName_interfaceType = Core.Name "interfaceType"+_MemberName_identifier = Core.Name "identifier"+data MethodBody =+  MethodBodyBlock Block |+  MethodBodyNullConditionalInvocation NullConditionalInvocationExpression |+  MethodBodyExpression Expression |+  MethodBodyEmpty+  deriving (Eq, Ord, Read, Show)+_MethodBody = Core.Name "hydra.csharp.syntax.MethodBody"+_MethodBody_block = Core.Name "block"+_MethodBody_nullConditionalInvocation = Core.Name "nullConditionalInvocation"+_MethodBody_expression = Core.Name "expression"+_MethodBody_empty = Core.Name "empty"+data RefMethodBody =+  RefMethodBodyBlock Block |+  RefMethodBodyRef VariableReference |+  RefMethodBodyEmpty+  deriving (Eq, Ord, Read, Show)+_RefMethodBody = Core.Name "hydra.csharp.syntax.RefMethodBody"+_RefMethodBody_block = Core.Name "block"+_RefMethodBody_ref = Core.Name "ref"+_RefMethodBody_empty = Core.Name "empty"+data FormalParameterList =+  FormalParameterList {+    formalParameterListFixed :: [FixedParameter],+    formalParameterListArray :: (Maybe ParameterArray)}+  deriving (Eq, Ord, Read, Show)+_FormalParameterList = Core.Name "hydra.csharp.syntax.FormalParameterList"+_FormalParameterList_fixed = Core.Name "fixed"+_FormalParameterList_array = Core.Name "array"+data FixedParameter =+  FixedParameter {+    fixedParameterAttributes :: (Maybe Attributes),+    fixedParameterModifier :: (Maybe ParameterModifier),+    fixedParameterType :: Type,+    fixedParameterIdentifier :: Identifier,+    fixedParameterDefaultArgument :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_FixedParameter = Core.Name "hydra.csharp.syntax.FixedParameter"+_FixedParameter_attributes = Core.Name "attributes"+_FixedParameter_modifier = Core.Name "modifier"+_FixedParameter_type = Core.Name "type"+_FixedParameter_identifier = Core.Name "identifier"+_FixedParameter_defaultArgument = Core.Name "defaultArgument"+data ParameterModifier =+  ParameterModifierMode ParameterModeModifier |+  ParameterModifierThis+  deriving (Eq, Ord, Read, Show)+_ParameterModifier = Core.Name "hydra.csharp.syntax.ParameterModifier"+_ParameterModifier_mode = Core.Name "mode"+_ParameterModifier_this = Core.Name "this"+data ParameterModeModifier =+  ParameterModeModifierRef |+  ParameterModeModifierOut |+  ParameterModeModifierIn+  deriving (Eq, Ord, Read, Show)+_ParameterModeModifier = Core.Name "hydra.csharp.syntax.ParameterModeModifier"+_ParameterModeModifier_ref = Core.Name "ref"+_ParameterModeModifier_out = Core.Name "out"+_ParameterModeModifier_in = Core.Name "in"+data ParameterArray =+  ParameterArray {+    parameterArrayAttributes :: (Maybe Attributes),+    parameterArrayType :: ArrayType,+    parameterArrayIdentifier :: Identifier}+  deriving (Eq, Ord, Read, Show)+_ParameterArray = Core.Name "hydra.csharp.syntax.ParameterArray"+_ParameterArray_attributes = Core.Name "attributes"+_ParameterArray_type = Core.Name "type"+_ParameterArray_identifier = Core.Name "identifier"+data PropertyDeclaration =+  PropertyDeclarationStandard StandardPropertyDeclaration |+  PropertyDeclarationRefReturn RefReturnPropertyDeclaration+  deriving (Eq, Ord, Read, Show)+_PropertyDeclaration = Core.Name "hydra.csharp.syntax.PropertyDeclaration"+_PropertyDeclaration_standard = Core.Name "standard"+_PropertyDeclaration_refReturn = Core.Name "refReturn"+data StandardPropertyDeclaration =+  StandardPropertyDeclaration {+    standardPropertyDeclarationAttributes :: (Maybe Attributes),+    standardPropertyDeclarationModifiers :: [PropertyModifier],+    standardPropertyDeclarationType :: Type,+    standardPropertyDeclarationName :: MemberName,+    standardPropertyDeclarationBody :: PropertyBody}+  deriving (Eq, Ord, Read, Show)+_StandardPropertyDeclaration = Core.Name "hydra.csharp.syntax.StandardPropertyDeclaration"+_StandardPropertyDeclaration_attributes = Core.Name "attributes"+_StandardPropertyDeclaration_modifiers = Core.Name "modifiers"+_StandardPropertyDeclaration_type = Core.Name "type"+_StandardPropertyDeclaration_name = Core.Name "name"+_StandardPropertyDeclaration_body = Core.Name "body"+data RefReturnPropertyDeclaration =+  RefReturnPropertyDeclaration {+    refReturnPropertyDeclarationAttributes :: (Maybe Attributes),+    refReturnPropertyDeclarationModifiers :: [PropertyModifier],+    refReturnPropertyDeclarationRefKind :: RefKind,+    refReturnPropertyDeclarationType :: Type,+    refReturnPropertyDeclarationName :: MemberName,+    refReturnPropertyDeclarationBody :: RefPropertyBody}+  deriving (Eq, Ord, Read, Show)+_RefReturnPropertyDeclaration = Core.Name "hydra.csharp.syntax.RefReturnPropertyDeclaration"+_RefReturnPropertyDeclaration_attributes = Core.Name "attributes"+_RefReturnPropertyDeclaration_modifiers = Core.Name "modifiers"+_RefReturnPropertyDeclaration_refKind = Core.Name "refKind"+_RefReturnPropertyDeclaration_type = Core.Name "type"+_RefReturnPropertyDeclaration_name = Core.Name "name"+_RefReturnPropertyDeclaration_body = Core.Name "body"+data PropertyModifier =+  PropertyModifierNew |+  PropertyModifierPublic |+  PropertyModifierProtected |+  PropertyModifierInternal |+  PropertyModifierPrivate |+  PropertyModifierStatic |+  PropertyModifierVirtual |+  PropertyModifierSealed |+  PropertyModifierOverride |+  PropertyModifierAbstract |+  PropertyModifierExtern |+  PropertyModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_PropertyModifier = Core.Name "hydra.csharp.syntax.PropertyModifier"+_PropertyModifier_new = Core.Name "new"+_PropertyModifier_public = Core.Name "public"+_PropertyModifier_protected = Core.Name "protected"+_PropertyModifier_internal = Core.Name "internal"+_PropertyModifier_private = Core.Name "private"+_PropertyModifier_static = Core.Name "static"+_PropertyModifier_virtual = Core.Name "virtual"+_PropertyModifier_sealed = Core.Name "sealed"+_PropertyModifier_override = Core.Name "override"+_PropertyModifier_abstract = Core.Name "abstract"+_PropertyModifier_extern = Core.Name "extern"+_PropertyModifier_unsafe = Core.Name "unsafe"+data PropertyBody =+  PropertyBodyBlock BlockPropertyBody |+  PropertyBodyExpression Expression+  deriving (Eq, Ord, Read, Show)+_PropertyBody = Core.Name "hydra.csharp.syntax.PropertyBody"+_PropertyBody_block = Core.Name "block"+_PropertyBody_expression = Core.Name "expression"+data BlockPropertyBody =+  BlockPropertyBody {+    blockPropertyBodyAccessors :: AccessorDeclarations,+    blockPropertyBodyInitializer :: (Maybe VariableInitializer)}+  deriving (Eq, Ord, Read, Show)+_BlockPropertyBody = Core.Name "hydra.csharp.syntax.BlockPropertyBody"+_BlockPropertyBody_accessors = Core.Name "accessors"+_BlockPropertyBody_initializer = Core.Name "initializer"+data RefPropertyBody =+  RefPropertyBodyBlock RefGetAccessorDeclaration |+  RefPropertyBodyRef VariableReference+  deriving (Eq, Ord, Read, Show)+_RefPropertyBody = Core.Name "hydra.csharp.syntax.RefPropertyBody"+_RefPropertyBody_block = Core.Name "block"+_RefPropertyBody_ref = Core.Name "ref"+data AccessorDeclarations =+  AccessorDeclarationsGet (Maybe AccessorDeclaration) |+  AccessorDeclarationsSet (Maybe AccessorDeclaration)+  deriving (Eq, Ord, Read, Show)+_AccessorDeclarations = Core.Name "hydra.csharp.syntax.AccessorDeclarations"+_AccessorDeclarations_get = Core.Name "get"+_AccessorDeclarations_set = Core.Name "set"+data AccessorDeclaration =+  AccessorDeclaration {+    accessorDeclarationAttributes :: (Maybe Attributes),+    accessorDeclarationModifier :: (Maybe AccessorModifier),+    accessorDeclarationBody :: AccessorBody}+  deriving (Eq, Ord, Read, Show)+_AccessorDeclaration = Core.Name "hydra.csharp.syntax.AccessorDeclaration"+_AccessorDeclaration_attributes = Core.Name "attributes"+_AccessorDeclaration_modifier = Core.Name "modifier"+_AccessorDeclaration_body = Core.Name "body"+data AccessorModifier =+  AccessorModifierProtected |+  AccessorModifierInternal |+  AccessorModifierPrivate |+  AccessorModifierProtectedInternal |+  AccessorModifierInternalProtected |+  AccessorModifierProtectedPrivate |+  AccessorModifierPrivateProtected+  deriving (Eq, Ord, Read, Show)+_AccessorModifier = Core.Name "hydra.csharp.syntax.AccessorModifier"+_AccessorModifier_protected = Core.Name "protected"+_AccessorModifier_internal = Core.Name "internal"+_AccessorModifier_private = Core.Name "private"+_AccessorModifier_protectedInternal = Core.Name "protectedInternal"+_AccessorModifier_internalProtected = Core.Name "internalProtected"+_AccessorModifier_protectedPrivate = Core.Name "protectedPrivate"+_AccessorModifier_privateProtected = Core.Name "privateProtected"+data AccessorBody =+  AccessorBodyBlock Block |+  AccessorBodyExpression Expression |+  AccessorBodyEmpty+  deriving (Eq, Ord, Read, Show)+_AccessorBody = Core.Name "hydra.csharp.syntax.AccessorBody"+_AccessorBody_block = Core.Name "block"+_AccessorBody_expression = Core.Name "expression"+_AccessorBody_empty = Core.Name "empty"+data RefGetAccessorDeclaration =+  RefGetAccessorDeclaration {+    refGetAccessorDeclarationAttributes :: (Maybe Attributes),+    refGetAccessorDeclarationModifier :: (Maybe AccessorModifier),+    refGetAccessorDeclarationBody :: RefAccessorBody}+  deriving (Eq, Ord, Read, Show)+_RefGetAccessorDeclaration = Core.Name "hydra.csharp.syntax.RefGetAccessorDeclaration"+_RefGetAccessorDeclaration_attributes = Core.Name "attributes"+_RefGetAccessorDeclaration_modifier = Core.Name "modifier"+_RefGetAccessorDeclaration_body = Core.Name "body"+data RefAccessorBody =+  RefAccessorBodyBlock Block |+  RefAccessorBodyRef VariableReference |+  RefAccessorBodyEmpty+  deriving (Eq, Ord, Read, Show)+_RefAccessorBody = Core.Name "hydra.csharp.syntax.RefAccessorBody"+_RefAccessorBody_block = Core.Name "block"+_RefAccessorBody_ref = Core.Name "ref"+_RefAccessorBody_empty = Core.Name "empty"+data EventDeclaration =+  EventDeclarationStandard StandardEventDeclaration |+  EventDeclarationAccessors AccessorsEventDeclaration+  deriving (Eq, Ord, Read, Show)+_EventDeclaration = Core.Name "hydra.csharp.syntax.EventDeclaration"+_EventDeclaration_standard = Core.Name "standard"+_EventDeclaration_accessors = Core.Name "accessors"+data StandardEventDeclaration =+  StandardEventDeclaration {+    standardEventDeclarationAttributes :: (Maybe Attributes),+    standardEventDeclarationModifiers :: [EventModifier],+    standardEventDeclarationType :: Type,+    standardEventDeclarationDeclarators :: VariableDeclarators}+  deriving (Eq, Ord, Read, Show)+_StandardEventDeclaration = Core.Name "hydra.csharp.syntax.StandardEventDeclaration"+_StandardEventDeclaration_attributes = Core.Name "attributes"+_StandardEventDeclaration_modifiers = Core.Name "modifiers"+_StandardEventDeclaration_type = Core.Name "type"+_StandardEventDeclaration_declarators = Core.Name "declarators"+data AccessorsEventDeclaration =+  AccessorsEventDeclaration {+    accessorsEventDeclarationAttributes :: (Maybe Attributes),+    accessorsEventDeclarationModifiers :: [EventModifier],+    accessorsEventDeclarationType :: Type,+    accessorsEventDeclarationName :: MemberName,+    accessorsEventDeclarationAccessors :: EventAccessorDeclarations}+  deriving (Eq, Ord, Read, Show)+_AccessorsEventDeclaration = Core.Name "hydra.csharp.syntax.AccessorsEventDeclaration"+_AccessorsEventDeclaration_attributes = Core.Name "attributes"+_AccessorsEventDeclaration_modifiers = Core.Name "modifiers"+_AccessorsEventDeclaration_type = Core.Name "type"+_AccessorsEventDeclaration_name = Core.Name "name"+_AccessorsEventDeclaration_accessors = Core.Name "accessors"+data EventModifier =+  EventModifierNew |+  EventModifierPublic |+  EventModifierProtected |+  EventModifierInternal |+  EventModifierPrivate |+  EventModifierStatic |+  EventModifierVirtual |+  EventModifierSealed |+  EventModifierOverride |+  EventModifierAbstract |+  EventModifierExtern |+  EventModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_EventModifier = Core.Name "hydra.csharp.syntax.EventModifier"+_EventModifier_new = Core.Name "new"+_EventModifier_public = Core.Name "public"+_EventModifier_protected = Core.Name "protected"+_EventModifier_internal = Core.Name "internal"+_EventModifier_private = Core.Name "private"+_EventModifier_static = Core.Name "static"+_EventModifier_virtual = Core.Name "virtual"+_EventModifier_sealed = Core.Name "sealed"+_EventModifier_override = Core.Name "override"+_EventModifier_abstract = Core.Name "abstract"+_EventModifier_extern = Core.Name "extern"+_EventModifier_unsafe = Core.Name "unsafe"+data EventAccessorDeclarations =+  EventAccessorDeclarationsAdd AddRemoveAccessorDeclaration |+  EventAccessorDeclarationsRemove AddRemoveAccessorDeclaration+  deriving (Eq, Ord, Read, Show)+_EventAccessorDeclarations = Core.Name "hydra.csharp.syntax.EventAccessorDeclarations"+_EventAccessorDeclarations_add = Core.Name "add"+_EventAccessorDeclarations_remove = Core.Name "remove"+data AddRemoveAccessorDeclaration =+  AddRemoveAccessorDeclaration {+    addRemoveAccessorDeclarationAttributes :: (Maybe Attributes),+    addRemoveAccessorDeclarationBody :: Block}+  deriving (Eq, Ord, Read, Show)+_AddRemoveAccessorDeclaration = Core.Name "hydra.csharp.syntax.AddRemoveAccessorDeclaration"+_AddRemoveAccessorDeclaration_attributes = Core.Name "attributes"+_AddRemoveAccessorDeclaration_body = Core.Name "body"+data IndexerDeclaration =+  IndexerDeclarationStandard StandardIndexerDeclaration |+  IndexerDeclarationRef RefIndexerDeclaration+  deriving (Eq, Ord, Read, Show)+_IndexerDeclaration = Core.Name "hydra.csharp.syntax.IndexerDeclaration"+_IndexerDeclaration_standard = Core.Name "standard"+_IndexerDeclaration_ref = Core.Name "ref"+data StandardIndexerDeclaration =+  StandardIndexerDeclaration {+    standardIndexerDeclarationAttributes :: (Maybe Attributes),+    standardIndexerDeclarationModifiers :: [IndexerModifier],+    standardIndexerDeclarationDeclarator :: IndexerDeclarator,+    standardIndexerDeclarationBody :: IndexerBody}+  deriving (Eq, Ord, Read, Show)+_StandardIndexerDeclaration = Core.Name "hydra.csharp.syntax.StandardIndexerDeclaration"+_StandardIndexerDeclaration_attributes = Core.Name "attributes"+_StandardIndexerDeclaration_modifiers = Core.Name "modifiers"+_StandardIndexerDeclaration_declarator = Core.Name "declarator"+_StandardIndexerDeclaration_body = Core.Name "body"+data RefIndexerDeclaration =+  RefIndexerDeclaration {+    refIndexerDeclarationAttributes :: (Maybe Attributes),+    refIndexerDeclarationModifiers :: [IndexerModifier],+    refIndexerDeclarationRefKind :: RefKind,+    refIndexerDeclarationDeclarator :: IndexerDeclarator,+    refIndexerDeclarationBody :: RefIndexerBody}+  deriving (Eq, Ord, Read, Show)+_RefIndexerDeclaration = Core.Name "hydra.csharp.syntax.RefIndexerDeclaration"+_RefIndexerDeclaration_attributes = Core.Name "attributes"+_RefIndexerDeclaration_modifiers = Core.Name "modifiers"+_RefIndexerDeclaration_refKind = Core.Name "refKind"+_RefIndexerDeclaration_declarator = Core.Name "declarator"+_RefIndexerDeclaration_body = Core.Name "body"+data IndexerModifier =+  IndexerModifierNew |+  IndexerModifierPublic |+  IndexerModifierProtected |+  IndexerModifierInternal |+  IndexerModifierPrivate |+  IndexerModifierVirtual |+  IndexerModifierSealed |+  IndexerModifierOverride |+  IndexerModifierAbstract |+  IndexerModifierExtern |+  IndexerModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_IndexerModifier = Core.Name "hydra.csharp.syntax.IndexerModifier"+_IndexerModifier_new = Core.Name "new"+_IndexerModifier_public = Core.Name "public"+_IndexerModifier_protected = Core.Name "protected"+_IndexerModifier_internal = Core.Name "internal"+_IndexerModifier_private = Core.Name "private"+_IndexerModifier_virtual = Core.Name "virtual"+_IndexerModifier_sealed = Core.Name "sealed"+_IndexerModifier_override = Core.Name "override"+_IndexerModifier_abstract = Core.Name "abstract"+_IndexerModifier_extern = Core.Name "extern"+_IndexerModifier_unsafe = Core.Name "unsafe"+data IndexerDeclarator =+  IndexerDeclarator {+    indexerDeclaratorType :: Type,+    indexerDeclaratorInterface :: (Maybe InterfaceType),+    indexerDeclaratorParameters :: FormalParameterList}+  deriving (Eq, Ord, Read, Show)+_IndexerDeclarator = Core.Name "hydra.csharp.syntax.IndexerDeclarator"+_IndexerDeclarator_type = Core.Name "type"+_IndexerDeclarator_interface = Core.Name "interface"+_IndexerDeclarator_parameters = Core.Name "parameters"+data IndexerBody =+  IndexerBodyBlock AccessorDeclarations |+  IndexerBodyExpression Expression+  deriving (Eq, Ord, Read, Show)+_IndexerBody = Core.Name "hydra.csharp.syntax.IndexerBody"+_IndexerBody_block = Core.Name "block"+_IndexerBody_expression = Core.Name "expression"+data RefIndexerBody =+  RefIndexerBodyBlock RefGetAccessorDeclaration |+  RefIndexerBodyRef VariableReference+  deriving (Eq, Ord, Read, Show)+_RefIndexerBody = Core.Name "hydra.csharp.syntax.RefIndexerBody"+_RefIndexerBody_block = Core.Name "block"+_RefIndexerBody_ref = Core.Name "ref"+data OperatorDeclaration =+  OperatorDeclaration {+    operatorDeclarationAttributes :: (Maybe Attributes),+    operatorDeclarationModifiers :: [OperatorModifier],+    operatorDeclarationDeclarator :: OperatorDeclarator,+    operatorDeclarationBody :: OperatorBody}+  deriving (Eq, Ord, Read, Show)+_OperatorDeclaration = Core.Name "hydra.csharp.syntax.OperatorDeclaration"+_OperatorDeclaration_attributes = Core.Name "attributes"+_OperatorDeclaration_modifiers = Core.Name "modifiers"+_OperatorDeclaration_declarator = Core.Name "declarator"+_OperatorDeclaration_body = Core.Name "body"+data OperatorModifier =+  OperatorModifierPublic |+  OperatorModifierStatic |+  OperatorModifierExtern |+  OperatorModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_OperatorModifier = Core.Name "hydra.csharp.syntax.OperatorModifier"+_OperatorModifier_public = Core.Name "public"+_OperatorModifier_static = Core.Name "static"+_OperatorModifier_extern = Core.Name "extern"+_OperatorModifier_unsafe = Core.Name "unsafe"+data OperatorDeclarator =+  OperatorDeclaratorUnary UnaryOperatorDeclarator |+  OperatorDeclaratorBinary BinaryOperatorDeclarator |+  OperatorDeclaratorConversion ConversionOperatorDeclarator+  deriving (Eq, Ord, Read, Show)+_OperatorDeclarator = Core.Name "hydra.csharp.syntax.OperatorDeclarator"+_OperatorDeclarator_unary = Core.Name "unary"+_OperatorDeclarator_binary = Core.Name "binary"+_OperatorDeclarator_conversion = Core.Name "conversion"+data UnaryOperatorDeclarator =+  UnaryOperatorDeclarator {+    unaryOperatorDeclaratorType :: Type,+    unaryOperatorDeclaratorOperator :: OverloadableUnaryOperator,+    unaryOperatorDeclaratorParameter :: FixedParameter}+  deriving (Eq, Ord, Read, Show)+_UnaryOperatorDeclarator = Core.Name "hydra.csharp.syntax.UnaryOperatorDeclarator"+_UnaryOperatorDeclarator_type = Core.Name "type"+_UnaryOperatorDeclarator_operator = Core.Name "operator"+_UnaryOperatorDeclarator_parameter = Core.Name "parameter"+data OverloadableUnaryOperator =+  OverloadableUnaryOperatorPlus |+  OverloadableUnaryOperatorMinus |+  OverloadableUnaryOperatorNot |+  OverloadableUnaryOperatorComplement |+  OverloadableUnaryOperatorIncrement |+  OverloadableUnaryOperatorDecrement |+  OverloadableUnaryOperatorTrue |+  OverloadableUnaryOperatorFalse+  deriving (Eq, Ord, Read, Show)+_OverloadableUnaryOperator = Core.Name "hydra.csharp.syntax.OverloadableUnaryOperator"+_OverloadableUnaryOperator_plus = Core.Name "plus"+_OverloadableUnaryOperator_minus = Core.Name "minus"+_OverloadableUnaryOperator_not = Core.Name "not"+_OverloadableUnaryOperator_complement = Core.Name "complement"+_OverloadableUnaryOperator_increment = Core.Name "increment"+_OverloadableUnaryOperator_decrement = Core.Name "decrement"+_OverloadableUnaryOperator_true = Core.Name "true"+_OverloadableUnaryOperator_false = Core.Name "false"+data BinaryOperatorDeclarator =+  BinaryOperatorDeclarator {+    binaryOperatorDeclaratorType :: Type,+    binaryOperatorDeclaratorOperator :: OverloadableBinaryOperator,+    binaryOperatorDeclaratorLeft :: FixedParameter,+    binaryOperatorDeclaratorRight :: FixedParameter}+  deriving (Eq, Ord, Read, Show)+_BinaryOperatorDeclarator = Core.Name "hydra.csharp.syntax.BinaryOperatorDeclarator"+_BinaryOperatorDeclarator_type = Core.Name "type"+_BinaryOperatorDeclarator_operator = Core.Name "operator"+_BinaryOperatorDeclarator_left = Core.Name "left"+_BinaryOperatorDeclarator_right = Core.Name "right"+data OverloadableBinaryOperator =+  OverloadableBinaryOperatorAdd |+  OverloadableBinaryOperatorSubtract |+  OverloadableBinaryOperatorMultiply |+  OverloadableBinaryOperatorDivide |+  OverloadableBinaryOperatorModulus |+  OverloadableBinaryOperatorAnd |+  OverloadableBinaryOperatorOr |+  OverloadableBinaryOperatorXor |+  OverloadableBinaryOperatorLeftShift |+  OverloadableBinaryOperatorRightShift |+  OverloadableBinaryOperatorEqual |+  OverloadableBinaryOperatorNotEqual |+  OverloadableBinaryOperatorGreaterThan |+  OverloadableBinaryOperatorLessThan |+  OverloadableBinaryOperatorGreaterThanOrEqual |+  OverloadableBinaryOperatorLessThanOrEqual+  deriving (Eq, Ord, Read, Show)+_OverloadableBinaryOperator = Core.Name "hydra.csharp.syntax.OverloadableBinaryOperator"+_OverloadableBinaryOperator_add = Core.Name "add"+_OverloadableBinaryOperator_subtract = Core.Name "subtract"+_OverloadableBinaryOperator_multiply = Core.Name "multiply"+_OverloadableBinaryOperator_divide = Core.Name "divide"+_OverloadableBinaryOperator_modulus = Core.Name "modulus"+_OverloadableBinaryOperator_and = Core.Name "and"+_OverloadableBinaryOperator_or = Core.Name "or"+_OverloadableBinaryOperator_xor = Core.Name "xor"+_OverloadableBinaryOperator_leftShift = Core.Name "leftShift"+_OverloadableBinaryOperator_rightShift = Core.Name "rightShift"+_OverloadableBinaryOperator_equal = Core.Name "equal"+_OverloadableBinaryOperator_notEqual = Core.Name "notEqual"+_OverloadableBinaryOperator_greaterThan = Core.Name "greaterThan"+_OverloadableBinaryOperator_lessThan = Core.Name "lessThan"+_OverloadableBinaryOperator_greaterThanOrEqual = Core.Name "greaterThanOrEqual"+_OverloadableBinaryOperator_lessThanOrEqual = Core.Name "lessThanOrEqual"+data ConversionOperatorDeclarator =+  ConversionOperatorDeclarator {+    conversionOperatorDeclaratorKind :: ConversionKind,+    conversionOperatorDeclaratorType :: Type,+    conversionOperatorDeclaratorParameter :: FixedParameter}+  deriving (Eq, Ord, Read, Show)+_ConversionOperatorDeclarator = Core.Name "hydra.csharp.syntax.ConversionOperatorDeclarator"+_ConversionOperatorDeclarator_kind = Core.Name "kind"+_ConversionOperatorDeclarator_type = Core.Name "type"+_ConversionOperatorDeclarator_parameter = Core.Name "parameter"+data ConversionKind =+  ConversionKindImplicit |+  ConversionKindExplicit+  deriving (Eq, Ord, Read, Show)+_ConversionKind = Core.Name "hydra.csharp.syntax.ConversionKind"+_ConversionKind_implicit = Core.Name "implicit"+_ConversionKind_explicit = Core.Name "explicit"+data OperatorBody =+  OperatorBodyBlock Block |+  OperatorBodyExpression Expression |+  OperatorBodyEmpty+  deriving (Eq, Ord, Read, Show)+_OperatorBody = Core.Name "hydra.csharp.syntax.OperatorBody"+_OperatorBody_block = Core.Name "block"+_OperatorBody_expression = Core.Name "expression"+_OperatorBody_empty = Core.Name "empty"+data ConstructorDeclaration =+  ConstructorDeclaration {+    constructorDeclarationAttributes :: (Maybe Attributes),+    constructorDeclarationModifiers :: [ConstructorModifier],+    constructorDeclarationDeclarator :: ConstructorDeclarator,+    constructorDeclarationBody :: ConstructorBody}+  deriving (Eq, Ord, Read, Show)+_ConstructorDeclaration = Core.Name "hydra.csharp.syntax.ConstructorDeclaration"+_ConstructorDeclaration_attributes = Core.Name "attributes"+_ConstructorDeclaration_modifiers = Core.Name "modifiers"+_ConstructorDeclaration_declarator = Core.Name "declarator"+_ConstructorDeclaration_body = Core.Name "body"+data ConstructorModifier =+  ConstructorModifierPublic |+  ConstructorModifierProtected |+  ConstructorModifierInternal |+  ConstructorModifierPrivate |+  ConstructorModifierExtern |+  ConstructorModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_ConstructorModifier = Core.Name "hydra.csharp.syntax.ConstructorModifier"+_ConstructorModifier_public = Core.Name "public"+_ConstructorModifier_protected = Core.Name "protected"+_ConstructorModifier_internal = Core.Name "internal"+_ConstructorModifier_private = Core.Name "private"+_ConstructorModifier_extern = Core.Name "extern"+_ConstructorModifier_unsafe = Core.Name "unsafe"+data ConstructorDeclarator =+  ConstructorDeclarator {+    constructorDeclaratorName :: Identifier,+    constructorDeclaratorParameters :: (Maybe FormalParameterList),+    constructorDeclaratorInitializer :: (Maybe ConstructorInitializer)}+  deriving (Eq, Ord, Read, Show)+_ConstructorDeclarator = Core.Name "hydra.csharp.syntax.ConstructorDeclarator"+_ConstructorDeclarator_name = Core.Name "name"+_ConstructorDeclarator_parameters = Core.Name "parameters"+_ConstructorDeclarator_initializer = Core.Name "initializer"+data ConstructorInitializer =+  ConstructorInitializerBase (Maybe ArgumentList) |+  ConstructorInitializerThis (Maybe ArgumentList)+  deriving (Eq, Ord, Read, Show)+_ConstructorInitializer = Core.Name "hydra.csharp.syntax.ConstructorInitializer"+_ConstructorInitializer_base = Core.Name "base"+_ConstructorInitializer_this = Core.Name "this"+data ConstructorBody =+  ConstructorBodyBlock Block |+  ConstructorBodyExpression Expression |+  ConstructorBodyEmpty+  deriving (Eq, Ord, Read, Show)+_ConstructorBody = Core.Name "hydra.csharp.syntax.ConstructorBody"+_ConstructorBody_block = Core.Name "block"+_ConstructorBody_expression = Core.Name "expression"+_ConstructorBody_empty = Core.Name "empty"+data StaticConstructorDeclaration =+  StaticConstructorDeclaration {+    staticConstructorDeclarationAttributes :: (Maybe Attributes),+    staticConstructorDeclarationModifiers :: StaticConstructorModifiers,+    staticConstructorDeclarationName :: Identifier,+    staticConstructorDeclarationBody :: StaticConstructorBody}+  deriving (Eq, Ord, Read, Show)+_StaticConstructorDeclaration = Core.Name "hydra.csharp.syntax.StaticConstructorDeclaration"+_StaticConstructorDeclaration_attributes = Core.Name "attributes"+_StaticConstructorDeclaration_modifiers = Core.Name "modifiers"+_StaticConstructorDeclaration_name = Core.Name "name"+_StaticConstructorDeclaration_body = Core.Name "body"+data StaticConstructorModifiers =+  StaticConstructorModifiers {+    staticConstructorModifiersExtern :: Bool,+    staticConstructorModifiersUnsafe :: Bool}+  deriving (Eq, Ord, Read, Show)+_StaticConstructorModifiers = Core.Name "hydra.csharp.syntax.StaticConstructorModifiers"+_StaticConstructorModifiers_extern = Core.Name "extern"+_StaticConstructorModifiers_unsafe = Core.Name "unsafe"+data StaticConstructorBody =+  StaticConstructorBodyBlock Block |+  StaticConstructorBodyExpression Expression |+  StaticConstructorBodyEmpty+  deriving (Eq, Ord, Read, Show)+_StaticConstructorBody = Core.Name "hydra.csharp.syntax.StaticConstructorBody"+_StaticConstructorBody_block = Core.Name "block"+_StaticConstructorBody_expression = Core.Name "expression"+_StaticConstructorBody_empty = Core.Name "empty"+data FinalizerDeclaration =+  FinalizerDeclaration {+    finalizerDeclarationAttributes :: (Maybe Attributes),+    finalizerDeclarationExtern :: Bool,+    finalizerDeclarationUnsafe :: Bool,+    finalizerDeclarationName :: Identifier,+    finalizerDeclarationBody :: FinalizerBody}+  deriving (Eq, Ord, Read, Show)+_FinalizerDeclaration = Core.Name "hydra.csharp.syntax.FinalizerDeclaration"+_FinalizerDeclaration_attributes = Core.Name "attributes"+_FinalizerDeclaration_extern = Core.Name "extern"+_FinalizerDeclaration_unsafe = Core.Name "unsafe"+_FinalizerDeclaration_name = Core.Name "name"+_FinalizerDeclaration_body = Core.Name "body"+data FinalizerBody =+  FinalizerBodyBlock Block |+  FinalizerBodyExpression Expression |+  FinalizerBodyEmpty+  deriving (Eq, Ord, Read, Show)+_FinalizerBody = Core.Name "hydra.csharp.syntax.FinalizerBody"+_FinalizerBody_block = Core.Name "block"+_FinalizerBody_expression = Core.Name "expression"+_FinalizerBody_empty = Core.Name "empty"+data StructDeclaration =+  StructDeclaration {+    structDeclarationAttributes :: (Maybe Attributes),+    structDeclarationModifiers :: [StructModifier],+    structDeclarationRef :: Bool,+    structDeclarationPartial :: Bool,+    structDeclarationName :: Identifier,+    structDeclarationParameters :: (Maybe TypeParameterList),+    structDeclarationInterfaces :: [InterfaceType],+    structDeclarationConstraints :: [TypeParameterConstraintsClause],+    structDeclarationBody :: [StructMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_StructDeclaration = Core.Name "hydra.csharp.syntax.StructDeclaration"+_StructDeclaration_attributes = Core.Name "attributes"+_StructDeclaration_modifiers = Core.Name "modifiers"+_StructDeclaration_ref = Core.Name "ref"+_StructDeclaration_partial = Core.Name "partial"+_StructDeclaration_name = Core.Name "name"+_StructDeclaration_parameters = Core.Name "parameters"+_StructDeclaration_interfaces = Core.Name "interfaces"+_StructDeclaration_constraints = Core.Name "constraints"+_StructDeclaration_body = Core.Name "body"+data StructModifier =+  StructModifierNew |+  StructModifierPublic |+  StructModifierProtected |+  StructModifierInternal |+  StructModifierPrivate |+  StructModifierReadonly |+  StructModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_StructModifier = Core.Name "hydra.csharp.syntax.StructModifier"+_StructModifier_new = Core.Name "new"+_StructModifier_public = Core.Name "public"+_StructModifier_protected = Core.Name "protected"+_StructModifier_internal = Core.Name "internal"+_StructModifier_private = Core.Name "private"+_StructModifier_readonly = Core.Name "readonly"+_StructModifier_unsafe = Core.Name "unsafe"+data StructMemberDeclaration =+  StructMemberDeclarationConstant ConstantDeclaration |+  StructMemberDeclarationField FieldDeclaration |+  StructMemberDeclarationMethod MethodDeclaration |+  StructMemberDeclarationProperty PropertyDeclaration |+  StructMemberDeclarationEvent EventDeclaration |+  StructMemberDeclarationIndexer IndexerDeclaration |+  StructMemberDeclarationOperator OperatorDeclaration |+  StructMemberDeclarationConstructor ConstructorDeclaration |+  StructMemberDeclarationStaticConstructor StaticConstructorDeclaration |+  StructMemberDeclarationType TypeDeclaration |+  StructMemberDeclarationFixedSizeBuffer FixedSizeBufferDeclaration+  deriving (Eq, Ord, Read, Show)+_StructMemberDeclaration = Core.Name "hydra.csharp.syntax.StructMemberDeclaration"+_StructMemberDeclaration_constant = Core.Name "constant"+_StructMemberDeclaration_field = Core.Name "field"+_StructMemberDeclaration_method = Core.Name "method"+_StructMemberDeclaration_property = Core.Name "property"+_StructMemberDeclaration_event = Core.Name "event"+_StructMemberDeclaration_indexer = Core.Name "indexer"+_StructMemberDeclaration_operator = Core.Name "operator"+_StructMemberDeclaration_constructor = Core.Name "constructor"+_StructMemberDeclaration_staticConstructor = Core.Name "staticConstructor"+_StructMemberDeclaration_type = Core.Name "type"+_StructMemberDeclaration_fixedSizeBuffer = Core.Name "fixedSizeBuffer"+newtype ArrayInitializer =+  ArrayInitializer {+    unArrayInitializer :: [VariableInitializer]}+  deriving (Eq, Ord, Read, Show)+_ArrayInitializer = Core.Name "hydra.csharp.syntax.ArrayInitializer"+data VariableInitializer =+  VariableInitializerExpression Expression |+  VariableInitializerArray ArrayInitializer+  deriving (Eq, Ord, Read, Show)+_VariableInitializer = Core.Name "hydra.csharp.syntax.VariableInitializer"+_VariableInitializer_expression = Core.Name "expression"+_VariableInitializer_array = Core.Name "array"+data InterfaceDeclaration =+  InterfaceDeclaration {+    interfaceDeclarationAttributes :: (Maybe Attributes),+    interfaceDeclarationModifiers :: [InterfaceModifier],+    interfaceDeclarationPartial :: Bool,+    interfaceDeclarationName :: Identifier,+    interfaceDeclarationParameters :: (Maybe VariantTypeParameters),+    interfaceDeclarationBase :: [InterfaceType],+    interfaceDeclarationConstraints :: [TypeParameterConstraintsClause],+    interfaceDeclarationBody :: [InterfaceMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_InterfaceDeclaration = Core.Name "hydra.csharp.syntax.InterfaceDeclaration"+_InterfaceDeclaration_attributes = Core.Name "attributes"+_InterfaceDeclaration_modifiers = Core.Name "modifiers"+_InterfaceDeclaration_partial = Core.Name "partial"+_InterfaceDeclaration_name = Core.Name "name"+_InterfaceDeclaration_parameters = Core.Name "parameters"+_InterfaceDeclaration_base = Core.Name "base"+_InterfaceDeclaration_constraints = Core.Name "constraints"+_InterfaceDeclaration_body = Core.Name "body"+data InterfaceModifier =+  InterfaceModifierNew |+  InterfaceModifierPublic |+  InterfaceModifierProtected |+  InterfaceModifierInternal |+  InterfaceModifierPrivate |+  InterfaceModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_InterfaceModifier = Core.Name "hydra.csharp.syntax.InterfaceModifier"+_InterfaceModifier_new = Core.Name "new"+_InterfaceModifier_public = Core.Name "public"+_InterfaceModifier_protected = Core.Name "protected"+_InterfaceModifier_internal = Core.Name "internal"+_InterfaceModifier_private = Core.Name "private"+_InterfaceModifier_unsafe = Core.Name "unsafe"+newtype VariantTypeParameters =+  VariantTypeParameters {+    unVariantTypeParameters :: [VariantTypeParameter]}+  deriving (Eq, Ord, Read, Show)+_VariantTypeParameters = Core.Name "hydra.csharp.syntax.VariantTypeParameters"+data VariantTypeParameter =+  VariantTypeParameter {+    variantTypeParameterAttributes :: (Maybe Attributes),+    variantTypeParameterVariance :: (Maybe VarianceAnnotation),+    variantTypeParameterParameter :: TypeParameter}+  deriving (Eq, Ord, Read, Show)+_VariantTypeParameter = Core.Name "hydra.csharp.syntax.VariantTypeParameter"+_VariantTypeParameter_attributes = Core.Name "attributes"+_VariantTypeParameter_variance = Core.Name "variance"+_VariantTypeParameter_parameter = Core.Name "parameter"+data VarianceAnnotation =+  VarianceAnnotationIn |+  VarianceAnnotationOut+  deriving (Eq, Ord, Read, Show)+_VarianceAnnotation = Core.Name "hydra.csharp.syntax.VarianceAnnotation"+_VarianceAnnotation_in = Core.Name "in"+_VarianceAnnotation_out = Core.Name "out"+data InterfaceMemberDeclaration =+  InterfaceMemberDeclarationMethod InterfaceMethodDeclaration |+  InterfaceMemberDeclarationProperty InterfacePropertyDeclaration |+  InterfaceMemberDeclarationEvent InterfaceEventDeclaration |+  InterfaceMemberDeclarationIndexer InterfaceIndexerDeclaration+  deriving (Eq, Ord, Read, Show)+_InterfaceMemberDeclaration = Core.Name "hydra.csharp.syntax.InterfaceMemberDeclaration"+_InterfaceMemberDeclaration_method = Core.Name "method"+_InterfaceMemberDeclaration_property = Core.Name "property"+_InterfaceMemberDeclaration_event = Core.Name "event"+_InterfaceMemberDeclaration_indexer = Core.Name "indexer"+data InterfaceMethodDeclaration =+  InterfaceMethodDeclaration {+    interfaceMethodDeclarationAttributes :: (Maybe Attributes),+    interfaceMethodDeclarationNew :: Bool,+    interfaceMethodDeclarationReturnType :: ReturnType,+    interfaceMethodDeclarationRefKind :: (Maybe RefKind),+    interfaceMethodDeclarationHeader :: InterfaceMethodHeader}+  deriving (Eq, Ord, Read, Show)+_InterfaceMethodDeclaration = Core.Name "hydra.csharp.syntax.InterfaceMethodDeclaration"+_InterfaceMethodDeclaration_attributes = Core.Name "attributes"+_InterfaceMethodDeclaration_new = Core.Name "new"+_InterfaceMethodDeclaration_returnType = Core.Name "returnType"+_InterfaceMethodDeclaration_refKind = Core.Name "refKind"+_InterfaceMethodDeclaration_header = Core.Name "header"+data InterfaceMethodHeader =+  InterfaceMethodHeader {+    interfaceMethodHeaderName :: Identifier,+    interfaceMethodHeaderParameters :: (Maybe FormalParameterList),+    interfaceMethodHeaderTypeParameters :: (Maybe TypeParameterList),+    interfaceMethodHeaderConstraints :: [TypeParameterConstraintsClause]}+  deriving (Eq, Ord, Read, Show)+_InterfaceMethodHeader = Core.Name "hydra.csharp.syntax.InterfaceMethodHeader"+_InterfaceMethodHeader_name = Core.Name "name"+_InterfaceMethodHeader_parameters = Core.Name "parameters"+_InterfaceMethodHeader_typeParameters = Core.Name "typeParameters"+_InterfaceMethodHeader_constraints = Core.Name "constraints"+data InterfacePropertyDeclaration =+  InterfacePropertyDeclaration {+    interfacePropertyDeclarationAttributes :: (Maybe Attributes),+    interfacePropertyDeclarationNew :: Bool,+    interfacePropertyDeclarationRefKind :: (Maybe RefKind),+    interfacePropertyDeclarationType :: Type,+    interfacePropertyDeclarationName :: Identifier,+    interfacePropertyDeclarationAccessors :: InterfaceAccessors}+  deriving (Eq, Ord, Read, Show)+_InterfacePropertyDeclaration = Core.Name "hydra.csharp.syntax.InterfacePropertyDeclaration"+_InterfacePropertyDeclaration_attributes = Core.Name "attributes"+_InterfacePropertyDeclaration_new = Core.Name "new"+_InterfacePropertyDeclaration_refKind = Core.Name "refKind"+_InterfacePropertyDeclaration_type = Core.Name "type"+_InterfacePropertyDeclaration_name = Core.Name "name"+_InterfacePropertyDeclaration_accessors = Core.Name "accessors"+data InterfaceAccessors =+  InterfaceAccessors {+    interfaceAccessorsAttributes :: (Maybe Attributes),+    interfaceAccessorsGet :: (Maybe Attributes),+    interfaceAccessorsSet :: (Maybe Attributes)}+  deriving (Eq, Ord, Read, Show)+_InterfaceAccessors = Core.Name "hydra.csharp.syntax.InterfaceAccessors"+_InterfaceAccessors_attributes = Core.Name "attributes"+_InterfaceAccessors_get = Core.Name "get"+_InterfaceAccessors_set = Core.Name "set"+data InterfaceEventDeclaration =+  InterfaceEventDeclaration {+    interfaceEventDeclarationAttributes :: (Maybe Attributes),+    interfaceEventDeclarationNew :: Bool,+    interfaceEventDeclarationType :: Type,+    interfaceEventDeclarationName :: Identifier}+  deriving (Eq, Ord, Read, Show)+_InterfaceEventDeclaration = Core.Name "hydra.csharp.syntax.InterfaceEventDeclaration"+_InterfaceEventDeclaration_attributes = Core.Name "attributes"+_InterfaceEventDeclaration_new = Core.Name "new"+_InterfaceEventDeclaration_type = Core.Name "type"+_InterfaceEventDeclaration_name = Core.Name "name"+data InterfaceIndexerDeclaration =+  InterfaceIndexerDeclaration {+    interfaceIndexerDeclarationAttributes :: (Maybe Attributes),+    interfaceIndexerDeclarationNew :: Bool,+    interfaceIndexerDeclarationRefKind :: (Maybe RefKind),+    interfaceIndexerDeclarationType :: Type,+    interfaceIndexerDeclarationParameters :: FormalParameterList,+    interfaceIndexerDeclarationAccessors :: InterfaceAccessors}+  deriving (Eq, Ord, Read, Show)+_InterfaceIndexerDeclaration = Core.Name "hydra.csharp.syntax.InterfaceIndexerDeclaration"+_InterfaceIndexerDeclaration_attributes = Core.Name "attributes"+_InterfaceIndexerDeclaration_new = Core.Name "new"+_InterfaceIndexerDeclaration_refKind = Core.Name "refKind"+_InterfaceIndexerDeclaration_type = Core.Name "type"+_InterfaceIndexerDeclaration_parameters = Core.Name "parameters"+_InterfaceIndexerDeclaration_accessors = Core.Name "accessors"+data EnumDeclaration =+  EnumDeclaration {+    enumDeclarationAttributes :: (Maybe Attributes),+    enumDeclarationModifiers :: [EnumModifier],+    enumDeclarationName :: Identifier,+    enumDeclarationBase :: (Maybe EnumBase),+    enumDeclarationBody :: (Maybe EnumBody)}+  deriving (Eq, Ord, Read, Show)+_EnumDeclaration = Core.Name "hydra.csharp.syntax.EnumDeclaration"+_EnumDeclaration_attributes = Core.Name "attributes"+_EnumDeclaration_modifiers = Core.Name "modifiers"+_EnumDeclaration_name = Core.Name "name"+_EnumDeclaration_base = Core.Name "base"+_EnumDeclaration_body = Core.Name "body"+data EnumBase =+  EnumBaseType IntegralType |+  EnumBaseName TypeName+  deriving (Eq, Ord, Read, Show)+_EnumBase = Core.Name "hydra.csharp.syntax.EnumBase"+_EnumBase_type = Core.Name "type"+_EnumBase_name = Core.Name "name"+newtype EnumBody =+  EnumBody {+    unEnumBody :: [EnumMemberDeclaration]}+  deriving (Eq, Ord, Read, Show)+_EnumBody = Core.Name "hydra.csharp.syntax.EnumBody"+data EnumModifier =+  EnumModifierNew |+  EnumModifierPublic |+  EnumModifierProtected |+  EnumModifierInternal |+  EnumModifierPrivate+  deriving (Eq, Ord, Read, Show)+_EnumModifier = Core.Name "hydra.csharp.syntax.EnumModifier"+_EnumModifier_new = Core.Name "new"+_EnumModifier_public = Core.Name "public"+_EnumModifier_protected = Core.Name "protected"+_EnumModifier_internal = Core.Name "internal"+_EnumModifier_private = Core.Name "private"+data EnumMemberDeclaration =+  EnumMemberDeclaration {+    enumMemberDeclarationAttributes :: (Maybe Attributes),+    enumMemberDeclarationName :: Identifier,+    enumMemberDeclarationValue :: (Maybe ConstantExpression)}+  deriving (Eq, Ord, Read, Show)+_EnumMemberDeclaration = Core.Name "hydra.csharp.syntax.EnumMemberDeclaration"+_EnumMemberDeclaration_attributes = Core.Name "attributes"+_EnumMemberDeclaration_name = Core.Name "name"+_EnumMemberDeclaration_value = Core.Name "value"+data DelegateDeclaration =+  DelegateDeclaration {+    delegateDeclarationAttributes :: (Maybe Attributes),+    delegateDeclarationModifiers :: [DelegateModifier],+    delegateDeclarationReturnType :: ReturnType,+    delegateDeclarationRefKind :: (Maybe RefKind),+    delegateDeclarationRefReturnType :: (Maybe Type),+    delegateDeclarationHeader :: DelegateHeader}+  deriving (Eq, Ord, Read, Show)+_DelegateDeclaration = Core.Name "hydra.csharp.syntax.DelegateDeclaration"+_DelegateDeclaration_attributes = Core.Name "attributes"+_DelegateDeclaration_modifiers = Core.Name "modifiers"+_DelegateDeclaration_returnType = Core.Name "returnType"+_DelegateDeclaration_refKind = Core.Name "refKind"+_DelegateDeclaration_refReturnType = Core.Name "refReturnType"+_DelegateDeclaration_header = Core.Name "header"+data DelegateHeader =+  DelegateHeader {+    delegateHeaderName :: Identifier,+    delegateHeaderTypeParameters :: (Maybe VariantTypeParameters),+    delegateHeaderParameters :: (Maybe FormalParameterList),+    delegateHeaderConstraints :: [TypeParameterConstraintsClause]}+  deriving (Eq, Ord, Read, Show)+_DelegateHeader = Core.Name "hydra.csharp.syntax.DelegateHeader"+_DelegateHeader_name = Core.Name "name"+_DelegateHeader_typeParameters = Core.Name "typeParameters"+_DelegateHeader_parameters = Core.Name "parameters"+_DelegateHeader_constraints = Core.Name "constraints"+data DelegateModifier =+  DelegateModifierNew |+  DelegateModifierPublic |+  DelegateModifierProtected |+  DelegateModifierInternal |+  DelegateModifierPrivate |+  DelegateModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_DelegateModifier = Core.Name "hydra.csharp.syntax.DelegateModifier"+_DelegateModifier_new = Core.Name "new"+_DelegateModifier_public = Core.Name "public"+_DelegateModifier_protected = Core.Name "protected"+_DelegateModifier_internal = Core.Name "internal"+_DelegateModifier_private = Core.Name "private"+_DelegateModifier_unsafe = Core.Name "unsafe"+data GlobalAttributeSection =+  GlobalAttributeSection {+    globalAttributeSectionTarget :: Identifier,+    globalAttributeSectionAttributes :: AttributeList}+  deriving (Eq, Ord, Read, Show)+_GlobalAttributeSection = Core.Name "hydra.csharp.syntax.GlobalAttributeSection"+_GlobalAttributeSection_target = Core.Name "target"+_GlobalAttributeSection_attributes = Core.Name "attributes"+newtype Attributes =+  Attributes {+    unAttributes :: [AttributeSection]}+  deriving (Eq, Ord, Read, Show)+_Attributes = Core.Name "hydra.csharp.syntax.Attributes"+data AttributeSection =+  AttributeSection {+    attributeSectionTarget :: (Maybe AttributeTarget),+    attributeSectionAttributes :: AttributeList}+  deriving (Eq, Ord, Read, Show)+_AttributeSection = Core.Name "hydra.csharp.syntax.AttributeSection"+_AttributeSection_target = Core.Name "target"+_AttributeSection_attributes = Core.Name "attributes"+data AttributeTarget =+  AttributeTargetIdentifier Identifier |+  AttributeTargetKeyword Keyword+  deriving (Eq, Ord, Read, Show)+_AttributeTarget = Core.Name "hydra.csharp.syntax.AttributeTarget"+_AttributeTarget_identifier = Core.Name "identifier"+_AttributeTarget_keyword = Core.Name "keyword"+newtype AttributeList =+  AttributeList {+    unAttributeList :: [Attribute]}+  deriving (Eq, Ord, Read, Show)+_AttributeList = Core.Name "hydra.csharp.syntax.AttributeList"+data Attribute =+  Attribute {+    attributeName :: AttributeName,+    attributeArguments :: (Maybe AttributeArguments)}+  deriving (Eq, Ord, Read, Show)+_Attribute = Core.Name "hydra.csharp.syntax.Attribute"+_Attribute_name = Core.Name "name"+_Attribute_arguments = Core.Name "arguments"+newtype AttributeName =+  AttributeName {+    unAttributeName :: TypeName}+  deriving (Eq, Ord, Read, Show)+_AttributeName = Core.Name "hydra.csharp.syntax.AttributeName"+data AttributeArguments =+  AttributeArguments {+    attributeArgumentsPositonal :: (Maybe PositionalArgumentList),+    attributeArgumentsNamed :: (Maybe NamedArgumentList)}+  deriving (Eq, Ord, Read, Show)+_AttributeArguments = Core.Name "hydra.csharp.syntax.AttributeArguments"+_AttributeArguments_positonal = Core.Name "positonal"+_AttributeArguments_named = Core.Name "named"+newtype PositionalArgumentList =+  PositionalArgumentList {+    unPositionalArgumentList :: [PositionalArgument]}+  deriving (Eq, Ord, Read, Show)+_PositionalArgumentList = Core.Name "hydra.csharp.syntax.PositionalArgumentList"+data PositionalArgument =+  PositionalArgument {+    positionalArgumentName :: (Maybe Identifier),+    positionalArgumentValue :: AttributeArgumentExpression}+  deriving (Eq, Ord, Read, Show)+_PositionalArgument = Core.Name "hydra.csharp.syntax.PositionalArgument"+_PositionalArgument_name = Core.Name "name"+_PositionalArgument_value = Core.Name "value"+newtype NamedArgumentList =+  NamedArgumentList {+    unNamedArgumentList :: [NamedArgument]}+  deriving (Eq, Ord, Read, Show)+_NamedArgumentList = Core.Name "hydra.csharp.syntax.NamedArgumentList"+data NamedArgument =+  NamedArgument {+    namedArgumentName :: Identifier,+    namedArgumentValue :: AttributeArgumentExpression}+  deriving (Eq, Ord, Read, Show)+_NamedArgument = Core.Name "hydra.csharp.syntax.NamedArgument"+_NamedArgument_name = Core.Name "name"+_NamedArgument_value = Core.Name "value"+newtype AttributeArgumentExpression =+  AttributeArgumentExpression {+    unAttributeArgumentExpression :: NonAssignmentExpression}+  deriving (Eq, Ord, Read, Show)+_AttributeArgumentExpression = Core.Name "hydra.csharp.syntax.AttributeArgumentExpression"+data PointerType =+  PointerTypeValueType (Maybe ValueType) |+  PointerTypePointerDepth Int+  deriving (Eq, Ord, Read, Show)+_PointerType = Core.Name "hydra.csharp.syntax.PointerType"+_PointerType_valueType = Core.Name "valueType"+_PointerType_pointerDepth = Core.Name "pointerDepth"+data PointerMemberAccess =+  PointerMemberAccess {+    pointerMemberAccessPointer :: PrimaryExpression,+    pointerMemberAccessMember :: Identifier,+    pointerMemberAccessTypeArguments :: (Maybe TypeArgumentList)}+  deriving (Eq, Ord, Read, Show)+_PointerMemberAccess = Core.Name "hydra.csharp.syntax.PointerMemberAccess"+_PointerMemberAccess_pointer = Core.Name "pointer"+_PointerMemberAccess_member = Core.Name "member"+_PointerMemberAccess_typeArguments = Core.Name "typeArguments"+data PointerElementAccess =+  PointerElementAccess {+    pointerElementAccessPointer :: PrimaryNoArrayCreationExpression,+    pointerElementAccessIndex :: Expression}+  deriving (Eq, Ord, Read, Show)+_PointerElementAccess = Core.Name "hydra.csharp.syntax.PointerElementAccess"+_PointerElementAccess_pointer = Core.Name "pointer"+_PointerElementAccess_index = Core.Name "index"+data FixedStatement =+  FixedStatement {+    fixedStatementPointerType :: PointerType,+    fixedStatementDeclarators :: [FixedPointerDeclarator],+    fixedStatementStatement :: EmbeddedStatement}+  deriving (Eq, Ord, Read, Show)+_FixedStatement = Core.Name "hydra.csharp.syntax.FixedStatement"+_FixedStatement_pointerType = Core.Name "pointerType"+_FixedStatement_declarators = Core.Name "declarators"+_FixedStatement_statement = Core.Name "statement"+data FixedPointerDeclarator =+  FixedPointerDeclaratorReference VariableReference |+  FixedPointerDeclaratorExpression Expression+  deriving (Eq, Ord, Read, Show)+_FixedPointerDeclarator = Core.Name "hydra.csharp.syntax.FixedPointerDeclarator"+_FixedPointerDeclarator_reference = Core.Name "reference"+_FixedPointerDeclarator_expression = Core.Name "expression"+data FixedSizeBufferDeclaration =+  FixedSizeBufferDeclaration {+    fixedSizeBufferDeclarationAttributes :: (Maybe Attributes),+    fixedSizeBufferDeclarationModifiers :: [FixedSizeBufferModifier],+    fixedSizeBufferDeclarationElementType :: Type,+    fixedSizeBufferDeclarationDeclarators :: [FixedSizeBufferDeclarator]}+  deriving (Eq, Ord, Read, Show)+_FixedSizeBufferDeclaration = Core.Name "hydra.csharp.syntax.FixedSizeBufferDeclaration"+_FixedSizeBufferDeclaration_attributes = Core.Name "attributes"+_FixedSizeBufferDeclaration_modifiers = Core.Name "modifiers"+_FixedSizeBufferDeclaration_elementType = Core.Name "elementType"+_FixedSizeBufferDeclaration_declarators = Core.Name "declarators"+data FixedSizeBufferModifier =+  FixedSizeBufferModifierNew |+  FixedSizeBufferModifierPublic |+  FixedSizeBufferModifierInternal |+  FixedSizeBufferModifierPrivate |+  FixedSizeBufferModifierUnsafe+  deriving (Eq, Ord, Read, Show)+_FixedSizeBufferModifier = Core.Name "hydra.csharp.syntax.FixedSizeBufferModifier"+_FixedSizeBufferModifier_new = Core.Name "new"+_FixedSizeBufferModifier_public = Core.Name "public"+_FixedSizeBufferModifier_internal = Core.Name "internal"+_FixedSizeBufferModifier_private = Core.Name "private"+_FixedSizeBufferModifier_unsafe = Core.Name "unsafe"+data FixedSizeBufferDeclarator =+  FixedSizeBufferDeclarator {+    fixedSizeBufferDeclaratorName :: Identifier,+    fixedSizeBufferDeclaratorSize :: ConstantExpression}+  deriving (Eq, Ord, Read, Show)+_FixedSizeBufferDeclarator = Core.Name "hydra.csharp.syntax.FixedSizeBufferDeclarator"+_FixedSizeBufferDeclarator_name = Core.Name "name"+_FixedSizeBufferDeclarator_size = Core.Name "size"
+ src/main/haskell/Hydra/Datalog/Syntax.hs view
@@ -0,0 +1,110 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A basic Datalog model++module Hydra.Datalog.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+newtype Constant =+  Constant {+    unConstant :: String}+  deriving (Eq, Ord, Read, Show)+_Constant = Core.Name "hydra.datalog.syntax.Constant"+newtype Relation =+  Relation {+    unRelation :: String}+  deriving (Eq, Ord, Read, Show)+_Relation = Core.Name "hydra.datalog.syntax.Relation"+newtype Variable =+  Variable {+    unVariable :: String}+  deriving (Eq, Ord, Read, Show)+_Variable = Core.Name "hydra.datalog.syntax.Variable"+newtype Program =+  Program {+    unProgram :: [Program_Elmt]}+  deriving (Eq, Ord, Read, Show)+_Program = Core.Name "hydra.datalog.syntax.Program"+data Program_Elmt =+  Program_ElmtFact Fact |+  Program_ElmtRule Rule+  deriving (Eq, Ord, Read, Show)+_Program_Elmt = Core.Name "hydra.datalog.syntax.Program_Elmt"+_Program_Elmt_Fact = Core.Name "Fact"+_Program_Elmt_Rule = Core.Name "Rule"+data Fact =+  Fact {+    factRelation :: Relation,+    factConstantList :: ConstantList}+  deriving (Eq, Ord, Read, Show)+_Fact = Core.Name "hydra.datalog.syntax.Fact"+_Fact_Relation = Core.Name "Relation"+_Fact_ConstantList = Core.Name "ConstantList"+data Rule =+  Rule {+    ruleAtom :: Atom,+    ruleAtomList :: AtomList}+  deriving (Eq, Ord, Read, Show)+_Rule = Core.Name "hydra.datalog.syntax.Rule"+_Rule_Atom = Core.Name "Atom"+_Rule_AtomList = Core.Name "AtomList"+data Atom =+  Atom {+    atomRelation :: Relation,+    atomTermList :: TermList}+  deriving (Eq, Ord, Read, Show)+_Atom = Core.Name "hydra.datalog.syntax.Atom"+_Atom_Relation = Core.Name "Relation"+_Atom_TermList = Core.Name "TermList"+data AtomList =+  AtomListSingle Atom |+  AtomListMultiple AtomList_Multiple+  deriving (Eq, Ord, Read, Show)+_AtomList = Core.Name "hydra.datalog.syntax.AtomList"+_AtomList_single = Core.Name "single"+_AtomList_multiple = Core.Name "multiple"+data AtomList_Multiple =+  AtomList_Multiple {+    atomList_MultipleAtom :: Atom,+    atomList_MultipleAtomList :: AtomList}+  deriving (Eq, Ord, Read, Show)+_AtomList_Multiple = Core.Name "hydra.datalog.syntax.AtomList_Multiple"+_AtomList_Multiple_Atom = Core.Name "Atom"+_AtomList_Multiple_AtomList = Core.Name "AtomList"+data Term =+  TermConstant Constant |+  TermVariable Variable+  deriving (Eq, Ord, Read, Show)+_Term = Core.Name "hydra.datalog.syntax.Term"+_Term_Constant = Core.Name "Constant"+_Term_Variable = Core.Name "Variable"+data TermList =+  TermListSingle Term |+  TermListMultiple TermList_Multiple+  deriving (Eq, Ord, Read, Show)+_TermList = Core.Name "hydra.datalog.syntax.TermList"+_TermList_single = Core.Name "single"+_TermList_multiple = Core.Name "multiple"+data TermList_Multiple =+  TermList_Multiple {+    termList_MultipleTerm :: Term,+    termList_MultipleTermList :: TermList}+  deriving (Eq, Ord, Read, Show)+_TermList_Multiple = Core.Name "hydra.datalog.syntax.TermList_Multiple"+_TermList_Multiple_Term = Core.Name "Term"+_TermList_Multiple_TermList = Core.Name "TermList"+data ConstantList =+  ConstantListSingle Constant |+  ConstantListMultiple ConstantList_Multiple+  deriving (Eq, Ord, Read, Show)+_ConstantList = Core.Name "hydra.datalog.syntax.ConstantList"+_ConstantList_single = Core.Name "single"+_ConstantList_multiple = Core.Name "multiple"+data ConstantList_Multiple =+  ConstantList_Multiple {+    constantList_MultipleConstant :: Constant,+    constantList_MultipleConstantList :: ConstantList}+  deriving (Eq, Ord, Read, Show)+_ConstantList_Multiple = Core.Name "hydra.datalog.syntax.ConstantList_Multiple"+_ConstantList_Multiple_Constant = Core.Name "Constant"+_ConstantList_Multiple_ConstantList = Core.Name "ConstantList"
+ src/main/haskell/Hydra/Delta/Parquet.hs view
@@ -0,0 +1,109 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A partial Delta Parquet model, based on DataType and its subclasses as specified in the 3.0.0 Java API: https://docs.delta.io/3.0.0/api/java/kernel/io/delta/kernel/types/DataType.html++module Hydra.Delta.Parquet where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Represent array data type.+data ArrayType =+  ArrayType {+    arrayTypeElementType :: DataType,+    arrayTypeContainsNull :: Bool}+  deriving (Eq, Ord, Read, Show)+_ArrayType = Core.Name "hydra.delta.parquet.ArrayType"+_ArrayType_elementType = Core.Name "elementType"+_ArrayType_containsNull = Core.Name "containsNull"+-- | Base class for all primitive types DataType.+data BasePrimitiveType =+  -- | The data type representing byte[] values.+  BasePrimitiveTypeBinary |+  -- | Data type representing boolean type values.+  BasePrimitiveTypeBoolean |+  -- | The data type representing byte type values.+  BasePrimitiveTypeByte |+  -- | A date type, supporting "0001-01-01" through "9999-12-31". Internally, this is represented as the number of days from 1970-01-01.+  BasePrimitiveTypeDate |+  -- | The data type representing double type values.+  BasePrimitiveTypeDouble |+  -- | The data type representing float type values.+  BasePrimitiveTypeFloat |+  -- | The data type representing integer type values.+  BasePrimitiveTypeInteger |+  -- | The data type representing long type values.+  BasePrimitiveTypeLong |+  -- | The data type representing short type values.+  BasePrimitiveTypeShort |+  -- | The data type representing string type values.+  BasePrimitiveTypeString |+  -- | A timestamp type, supporting [0001-01-01T00:00:00.000000Z, 9999-12-31T23:59:59.999999Z] where the left/right-bound is a date and time of the proleptic Gregorian calendar in UTC+00:00. Internally, this is represented as the number of microseconds since the Unix epoch, 1970-01-01 00:00:00 UTC.+  BasePrimitiveTypeTimestamp+  deriving (Eq, Ord, Read, Show)+_BasePrimitiveType = Core.Name "hydra.delta.parquet.BasePrimitiveType"+_BasePrimitiveType_binary = Core.Name "binary"+_BasePrimitiveType_boolean = Core.Name "boolean"+_BasePrimitiveType_byte = Core.Name "byte"+_BasePrimitiveType_date = Core.Name "date"+_BasePrimitiveType_double = Core.Name "double"+_BasePrimitiveType_float = Core.Name "float"+_BasePrimitiveType_integer = Core.Name "integer"+_BasePrimitiveType_long = Core.Name "long"+_BasePrimitiveType_short = Core.Name "short"+_BasePrimitiveType_string = Core.Name "string"+_BasePrimitiveType_timestamp = Core.Name "timestamp"+data DataType =+  -- | Represent array data type.+  DataTypeArray ArrayType |+  -- | Base class for all primitive types DataType.+  DataTypeBase BasePrimitiveType |+  -- | A decimal data type.+  DataTypeDecimal DecimalType |+  -- | Data type representing a map type.+  DataTypeMap MapType |+  -- | Struct type which contains one or more columns.+  DataTypeStruct StructType+  deriving (Eq, Ord, Read, Show)+_DataType = Core.Name "hydra.delta.parquet.DataType"+_DataType_array = Core.Name "array"+_DataType_base = Core.Name "base"+_DataType_decimal = Core.Name "decimal"+_DataType_map = Core.Name "map"+_DataType_struct = Core.Name "struct"+-- | A decimal data type with fixed precision (the maximum number of digits) and scale (the number of digits on right side of dot). The precision can be up to 38, scale can also be up to 38 (less or equal to precision).+data DecimalType =+  DecimalType {+    decimalTypePrecision :: Int,+    decimalTypeScale :: Int}+  deriving (Eq, Ord, Read, Show)+_DecimalType = Core.Name "hydra.delta.parquet.DecimalType"+_DecimalType_precision = Core.Name "precision"+_DecimalType_scale = Core.Name "scale"+-- | Data type representing a map type.+data MapType =+  MapType {+    mapTypeKeyType :: DataType,+    mapTypeValueType :: DataType,+    mapTypeValueContainsNull :: Bool}+  deriving (Eq, Ord, Read, Show)+_MapType = Core.Name "hydra.delta.parquet.MapType"+_MapType_keyType = Core.Name "keyType"+_MapType_valueType = Core.Name "valueType"+_MapType_valueContainsNull = Core.Name "valueContainsNull"+-- | Represents a subfield of StructType with additional properties and metadata.+data StructField =+  StructField {+    structFieldName :: String,+    structFieldDataType :: DataType,+    structFieldNullable :: Bool}+  deriving (Eq, Ord, Read, Show)+_StructField = Core.Name "hydra.delta.parquet.StructField"+_StructField_name = Core.Name "name"+_StructField_dataType = Core.Name "dataType"+_StructField_nullable = Core.Name "nullable"+-- | Struct type which contains one or more columns.+data StructType =+  StructType {+    structTypeFields :: [StructField]}+  deriving (Eq, Ord, Read, Show)+_StructType = Core.Name "hydra.delta.parquet.StructType"+_StructType_fields = Core.Name "fields"
+ src/main/haskell/Hydra/Geojson/Model.hs view
@@ -0,0 +1,158 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A GeoJSON model based on the specification at https://www.rfc-editor.org/rfc/rfc7946. This model provides some additional structure beyond the JSON encoding described in the specification; For example, it provides MultiPoint not as an object with an array of coordinates which encode points, but as an array of Points. A BoundingBox is not simply an list of numbers, but a list of CoordinateRanges.++module Hydra.Geojson.Model where+import qualified Hydra.Core as Core+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections.  The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point.  The axes order of a bbox follows the axes order of geometries.+newtype BoundingBox =+  BoundingBox {+    unBoundingBox :: [CoordinateRange]}+  deriving (Eq, Ord, Read, Show)+_BoundingBox = Core.Name "hydra.geojson.model.BoundingBox"+data CoordinateRange =+  CoordinateRange {+    coordinateRangeMin :: Double,+    coordinateRangeMax :: Double}+  deriving (Eq, Ord, Read, Show)+_CoordinateRange = Core.Name "hydra.geojson.model.CoordinateRange"+_CoordinateRange_min = Core.Name "min"+_CoordinateRange_max = Core.Name "max"+-- | A Feature object represents a spatially bounded thing.  Every Feature object is a GeoJSON object no matter where it occurs in a GeoJSON text.+data Feature =+  Feature {+    -- | A Feature object has a member with the name "geometry".  The value of the geometry member SHALL be either a Geometry object as defined above or, in the case that the Feature is unlocated, a JSON null value.+    featureGeometry :: (Maybe Geometry),+    -- | A Feature object has a member with the name "properties".  The value of the properties member is an object (any JSON object or a JSON null value).+    featureProperties :: (Maybe (M.Map String Model.Value)),+    -- | If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of the Feature object with the name "id", and the value of this member is either a JSON string or number.+    featureId :: (Maybe Id),+    featureBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_Feature = Core.Name "hydra.geojson.model.Feature"+_Feature_geometry = Core.Name "geometry"+_Feature_properties = Core.Name "properties"+_Feature_id = Core.Name "id"+_Feature_bbox = Core.Name "bbox"+-- | A GeoJSON object with the type "FeatureCollection" is a FeatureCollection object.  A FeatureCollection object has a member with the name "features".  The value of "features" is a JSON array. Each element of the array is a Feature object as defined above.  It is possible for this array to be empty.+data FeatureCollection =+  FeatureCollection {+    featureCollectionFeatures :: [Feature],+    featureCollectionBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_FeatureCollection = Core.Name "hydra.geojson.model.FeatureCollection"+_FeatureCollection_features = Core.Name "features"+_FeatureCollection_bbox = Core.Name "bbox"+-- | A GeoJSON object with type "GeometryCollection" is a Geometry object. A GeometryCollection has a member with the name "geometries".  The value of "geometries" is an array.  Each element of this array is a GeoJSON Geometry object.  It is possible for this array to be empty.+data GeometryCollection =+  GeometryCollection {+    geometryCollectionGeometries :: [Geometry],+    geometryCollectionBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_GeometryCollection = Core.Name "hydra.geojson.model.GeometryCollection"+_GeometryCollection_geometries = Core.Name "geometries"+_GeometryCollection_bbox = Core.Name "bbox"+-- | A Geometry object represents points, curves, and surfaces in coordinate space.  Every Geometry object is a GeoJSON object no matter where it occurs in a GeoJSON text.+data Geometry =+  GeometryPoint Point |+  GeometryMultiPoint MultiPoint |+  GeometryLineString LineString |+  GeometryMultiLineString MultiLineString |+  GeometryPolygon Polygon |+  GeometryMultiPolygon MultiPolygon |+  GeometryGeometryCollection GeometryCollection+  deriving (Eq, Ord, Read, Show)+_Geometry = Core.Name "hydra.geojson.model.Geometry"+_Geometry_point = Core.Name "point"+_Geometry_multiPoint = Core.Name "multiPoint"+_Geometry_lineString = Core.Name "lineString"+_Geometry_multiLineString = Core.Name "multiLineString"+_Geometry_polygon = Core.Name "polygon"+_Geometry_multiPolygon = Core.Name "multiPolygon"+_Geometry_geometryCollection = Core.Name "geometryCollection"+data Id =+  IdNumber Double |+  IdString String+  deriving (Eq, Ord, Read, Show)+_Id = Core.Name "hydra.geojson.model.Id"+_Id_number = Core.Name "number"+_Id_string = Core.Name "string"+-- | For type "LineString", the "coordinates" member is an array of two or more positions.+data LineString =+  LineString {+    lineStringCoordinates :: [Position],+    lineStringBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_LineString = Core.Name "hydra.geojson.model.LineString"+_LineString_coordinates = Core.Name "coordinates"+_LineString_bbox = Core.Name "bbox"+-- | For type "MultiLineString", the "coordinates" member is an array of LineString coordinate arrays.+data MultiLineString =+  MultiLineString {+    multiLineStringCoordinates :: [LineString],+    multiLineStringBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_MultiLineString = Core.Name "hydra.geojson.model.MultiLineString"+_MultiLineString_coordinates = Core.Name "coordinates"+_MultiLineString_bbox = Core.Name "bbox"+-- | For type "MultiPoint", the "coordinates" member is an array of positions.+data MultiPoint =+  MultiPoint {+    multiPointCoordinates :: [Point],+    multiPointBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_MultiPoint = Core.Name "hydra.geojson.model.MultiPoint"+_MultiPoint_coordinates = Core.Name "coordinates"+_MultiPoint_bbox = Core.Name "bbox"+-- | For type "MultiPolygon", the "coordinates" member is an array of Polygon coordinate arrays.+data MultiPolygon =+  MultiPolygon {+    multiPolygonCoordinates :: [Polygon],+    multiPolygonBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_MultiPolygon = Core.Name "hydra.geojson.model.MultiPolygon"+_MultiPolygon_coordinates = Core.Name "coordinates"+_MultiPolygon_bbox = Core.Name "bbox"+-- | A GeoJSON object represents a Geometry, Feature, or collection of Features.+data Object =+  ObjectGeometry Geometry |+  ObjectFeature Feature |+  ObjectFeatureCollection FeatureCollection+  deriving (Eq, Ord, Read, Show)+_Object = Core.Name "hydra.geojson.model.Object"+_Object_geometry = Core.Name "geometry"+_Object_feature = Core.Name "feature"+_Object_featureCollection = Core.Name "featureCollection"+-- | For type "Point", the "coordinates" member is a single position.+data Point =+  Point {+    pointCoordinates :: Position,+    pointBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_Point = Core.Name "hydra.geojson.model.Point"+_Point_coordinates = Core.Name "coordinates"+_Point_bbox = Core.Name "bbox"+-- | For type "Polygon", the "coordinates" member MUST be an array of linear ring coordinate arrays.+-- | For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings.  The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface.+data Polygon =+  Polygon {+    polygonCoordinates :: [Position],+    polygonBbox :: (Maybe BoundingBox)}+  deriving (Eq, Ord, Read, Show)+_Polygon = Core.Name "hydra.geojson.model.Polygon"+_Polygon_coordinates = Core.Name "coordinates"+_Polygon_bbox = Core.Name "bbox"+-- | A position is an array of numbers.  There MUST be two or more elements.  The first two elements are longitude and latitude, or easting and northing, precisely in that order and using decimal numbers.  Altitude or elevation MAY be included as an optional third element.+data Position =+  Position {+    positionLatitude :: Double,+    positionLongitude :: Double,+    positionAltitude :: (Maybe Double)}+  deriving (Eq, Ord, Read, Show)+_Position = Core.Name "hydra.geojson.model.Position"+_Position_latitude = Core.Name "latitude"+_Position_longitude = Core.Name "longitude"+_Position_altitude = Core.Name "altitude"
+ src/main/haskell/Hydra/Graphql/Coder.hs view
@@ -0,0 +1,231 @@+-- Note: this is an automatically generated file. Do not edit.+-- | GraphQL code generator: converts Hydra modules to GraphQL schema definitions++module Hydra.Graphql.Coder where+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.File as File+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Graphql.Language as Language+import qualified Hydra.Graphql.Serde as Serde+import qualified Hydra.Graphql.Syntax as Syntax+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Predicates as Predicates+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Show.Core as ShowCore+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+descriptionFromType :: t0 -> Graph.Graph -> Core.Type -> Either Errors.Error (Maybe Syntax.Description)+descriptionFromType cx g typ =+    Eithers.map (\mval -> Optionals.map (\s -> Syntax.Description (Syntax.StringValue s)) mval) (Annotations.getTypeDescription cx g typ)+encodeEnumFieldName :: Core.Name -> Syntax.EnumValue+encodeEnumFieldName name = Syntax.EnumValue (Syntax.Name (sanitize (Core.unName name)))+encodeEnumFieldType :: t0 -> Graph.Graph -> Core.FieldType -> Either Errors.Error Syntax.EnumValueDefinition+encodeEnumFieldType cx g ft =+    Eithers.bind (descriptionFromType cx g (Core.fieldTypeType ft)) (\desc -> Right (Syntax.EnumValueDefinition {+      Syntax.enumValueDefinitionDescription = desc,+      Syntax.enumValueDefinitionEnumValue = (encodeEnumFieldName (Core.fieldTypeName ft)),+      Syntax.enumValueDefinitionDirectives = Nothing}))+encodeFieldName :: Core.Name -> Syntax.Name+encodeFieldName name = Syntax.Name (sanitize (Core.unName name))+encodeFieldType :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.FieldType -> Either Errors.Error Syntax.FieldDefinition+encodeFieldType cx g prefixes ft =+    Eithers.bind (encodeType cx g prefixes (Core.fieldTypeType ft)) (\gtype -> Eithers.bind (descriptionFromType cx g (Core.fieldTypeType ft)) (\desc -> Right (Syntax.FieldDefinition {+      Syntax.fieldDefinitionDescription = desc,+      Syntax.fieldDefinitionName = (encodeFieldName (Core.fieldTypeName ft)),+      Syntax.fieldDefinitionArgumentsDefinition = Nothing,+      Syntax.fieldDefinitionType = gtype,+      Syntax.fieldDefinitionDirectives = Nothing})))+encodeLiteralType :: t0 -> Core.LiteralType -> Either Errors.Error Syntax.NamedType+encodeLiteralType cx lt =+    case lt of+      Core.LiteralTypeBoolean -> Right (Syntax.NamedType (Syntax.Name "Boolean"))+      Core.LiteralTypeFloat v0 -> case v0 of+        Core.FloatTypeFloat64 -> Right (Syntax.NamedType (Syntax.Name "Float"))+        _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected 64-bit float type, found: " (ShowCore.floatType v0))))+      Core.LiteralTypeInteger v0 -> case v0 of+        Core.IntegerTypeInt32 -> Right (Syntax.NamedType (Syntax.Name "Int"))+        _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected 32-bit signed integer type, found: " (ShowCore.integerType v0))))+      Core.LiteralTypeString -> Right (Syntax.NamedType (Syntax.Name "String"))+      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected GraphQL-compatible literal type, found: " (ShowCore.literalType lt))))+encodeNamedType :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.Name -> Core.Type -> Either Errors.Error Syntax.TypeDefinition+encodeNamedType cx g prefixes name typ =+    case (Strip.deannotateType typ) of+      Core.TypeRecord v0 -> Eithers.bind (Eithers.mapList (\f -> encodeFieldType cx g prefixes f) v0) (\gfields -> Eithers.bind (descriptionFromType cx g typ) (\desc -> Right (Syntax.TypeDefinitionObject (Syntax.ObjectTypeDefinition {+        Syntax.objectTypeDefinitionDescription = desc,+        Syntax.objectTypeDefinitionName = (encodeTypeName prefixes name),+        Syntax.objectTypeDefinitionImplementsInterfaces = Nothing,+        Syntax.objectTypeDefinitionDirectives = Nothing,+        Syntax.objectTypeDefinitionFieldsDefinition = (Just (Syntax.FieldsDefinition gfields))}))))+      Core.TypeUnion v0 -> Logic.ifElse (Predicates.isEnumRowType v0) (Eithers.bind (Eithers.mapList (\f -> encodeEnumFieldType cx g f) v0) (\values -> Eithers.bind (descriptionFromType cx g typ) (\desc -> Right (Syntax.TypeDefinitionEnum (Syntax.EnumTypeDefinition {+        Syntax.enumTypeDefinitionDescription = desc,+        Syntax.enumTypeDefinitionName = (encodeTypeName prefixes name),+        Syntax.enumTypeDefinitionDirectives = Nothing,+        Syntax.enumTypeDefinitionEnumValuesDefinition = (Just (Syntax.EnumValuesDefinition values))}))))) (Eithers.bind (Eithers.mapList (\f -> encodeUnionFieldType cx g prefixes f) v0) (\gfields -> Eithers.bind (descriptionFromType cx g typ) (\desc -> Right (Syntax.TypeDefinitionObject (Syntax.ObjectTypeDefinition {+        Syntax.objectTypeDefinitionDescription = desc,+        Syntax.objectTypeDefinitionName = (encodeTypeName prefixes name),+        Syntax.objectTypeDefinitionImplementsInterfaces = Nothing,+        Syntax.objectTypeDefinitionDirectives = Nothing,+        Syntax.objectTypeDefinitionFieldsDefinition = (Just (Syntax.FieldsDefinition gfields))})))))+      Core.TypeEither v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "left"),+          Core.fieldTypeType = (Core.TypeOptional (Core.eitherTypeLeft v0))},+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "right"),+          Core.fieldTypeType = (Core.TypeOptional (Core.eitherTypeRight v0))}])+      Core.TypePair v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "first"),+          Core.fieldTypeType = (Core.pairTypeFirst v0)},+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "second"),+          Core.fieldTypeType = (Core.pairTypeSecond v0)}])+      Core.TypeList v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.TypeList v0)}])+      Core.TypeSet v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.TypeList v0)}])+      Core.TypeMap v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "key"),+          Core.fieldTypeType = (Core.mapTypeKeys v0)},+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.mapTypeValues v0)}])+      Core.TypeLiteral v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.TypeLiteral v0)}])+      Core.TypeVariable v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.TypeVariable v0)}])+      Core.TypeWrap v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = v0}])+      Core.TypeUnit -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "value"),+          Core.fieldTypeType = (Core.TypeLiteral Core.LiteralTypeBoolean)}])+      Core.TypeForall v0 -> encodeNamedType cx g prefixes name (Core.forallTypeBody v0)+      Core.TypeApplication v0 -> encodeNamedType cx g prefixes name (Core.applicationTypeFunction v0)+      Core.TypeFunction v0 -> encodeNamedType cx g prefixes name (Core.TypeRecord [+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "domain"),+          Core.fieldTypeType = (Core.functionTypeDomain v0)},+        Core.FieldType {+          Core.fieldTypeName = (Core.Name "codomain"),+          Core.fieldTypeType = (Core.functionTypeCodomain v0)}])+      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected record or union type, found: " (ShowCore.type_ typ))))+encodeType :: t0 -> t1 -> M.Map Packaging.ModuleName String -> Core.Type -> Either Errors.Error Syntax.Type+encodeType cx g prefixes typ =+    case (Strip.deannotateType typ) of+      Core.TypeOptional v0 -> case (Strip.deannotateType v0) of+        Core.TypeList v1 -> Eithers.map (\gt -> Syntax.TypeList (Syntax.ListType gt)) (encodeType cx g prefixes v1)+        Core.TypeSet v1 -> Eithers.map (\gt -> Syntax.TypeList (Syntax.ListType gt)) (encodeType cx g prefixes v1)+        Core.TypeMap v1 -> Eithers.map (\gt -> Syntax.TypeList (Syntax.ListType gt)) (encodeType cx g prefixes (Core.mapTypeValues v1))+        Core.TypeLiteral v1 -> Eithers.map (\nt -> Syntax.TypeNamed nt) (encodeLiteralType cx v1)+        Core.TypePair _ -> Right (Syntax.TypeNamed (Syntax.NamedType (encodeTypeName prefixes (Core.Name "hydra.util.Pair"))))+        Core.TypeEither _ -> Right (Syntax.TypeNamed (Syntax.NamedType (encodeTypeName prefixes (Core.Name "hydra.util.Either"))))+        Core.TypeRecord _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous record type"))+        Core.TypeUnion _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous union type"))+        Core.TypeWrap v1 -> encodeType cx g prefixes (Core.TypeOptional v1)+        Core.TypeVariable v1 -> Right (Syntax.TypeNamed (Syntax.NamedType (encodeTypeName prefixes v1)))+        Core.TypeForall v1 -> encodeType cx g prefixes (Core.TypeOptional (Core.forallTypeBody v1))+        Core.TypeApplication v1 -> encodeType cx g prefixes (Core.TypeOptional (Core.applicationTypeFunction v1))+        Core.TypeFunction _ -> Right (Syntax.TypeNamed (Syntax.NamedType (Syntax.Name "String")))+        Core.TypeUnit -> Right (Syntax.TypeNamed (Syntax.NamedType (Syntax.Name "Boolean")))+        _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected GraphQL-compatible type, found: " (ShowCore.type_ v0))))+      Core.TypeList v0 -> Eithers.map (\gt -> Syntax.TypeNonNull (Syntax.NonNullTypeList (Syntax.ListType gt))) (encodeType cx g prefixes v0)+      Core.TypeSet v0 -> Eithers.map (\gt -> Syntax.TypeNonNull (Syntax.NonNullTypeList (Syntax.ListType gt))) (encodeType cx g prefixes v0)+      Core.TypeMap v0 -> Eithers.map (\gt -> Syntax.TypeNonNull (Syntax.NonNullTypeList (Syntax.ListType gt))) (encodeType cx g prefixes (Core.mapTypeValues v0))+      Core.TypeLiteral v0 -> Eithers.map (\nt -> Syntax.TypeNonNull (Syntax.NonNullTypeNamed nt)) (encodeLiteralType cx v0)+      Core.TypePair _ -> Right (Syntax.TypeNonNull (Syntax.NonNullTypeNamed (Syntax.NamedType (encodeTypeName prefixes (Core.Name "hydra.util.Pair")))))+      Core.TypeEither _ -> Right (Syntax.TypeNonNull (Syntax.NonNullTypeNamed (Syntax.NamedType (encodeTypeName prefixes (Core.Name "hydra.util.Either")))))+      Core.TypeRecord _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous record type"))+      Core.TypeUnion _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous union type"))+      Core.TypeVariable v0 -> Right (Syntax.TypeNonNull (Syntax.NonNullTypeNamed (Syntax.NamedType (encodeTypeName prefixes v0))))+      Core.TypeWrap v0 -> encodeType cx g prefixes v0+      Core.TypeForall v0 -> encodeType cx g prefixes (Core.forallTypeBody v0)+      Core.TypeApplication v0 -> encodeType cx g prefixes (Core.applicationTypeFunction v0)+      Core.TypeFunction _ -> Right (Syntax.TypeNonNull (Syntax.NonNullTypeNamed (Syntax.NamedType (Syntax.Name "String"))))+      Core.TypeUnit -> Right (Syntax.TypeNonNull (Syntax.NonNullTypeNamed (Syntax.NamedType (Syntax.Name "Boolean"))))+      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected GraphQL-compatible type, found: " (ShowCore.type_ typ))))+encodeTypeDefinition :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Packaging.TypeDefinition -> Either Errors.Error Syntax.TypeDefinition+encodeTypeDefinition cx g prefixes tdef =+    encodeNamedType cx g prefixes (Packaging.typeDefinitionName tdef) (Core.typeSchemeBody (Packaging.typeDefinitionBody tdef))+encodeTypeName :: M.Map Packaging.ModuleName String -> Core.Name -> Syntax.Name+encodeTypeName prefixes name =++      let qualName = Names.qualifyName name+          local = Util.qualifiedNameLocal qualName+          mns = Util.qualifiedNameModuleName qualName+          prefix = Optionals.cases mns "" (\ns_ -> Optionals.cases (Maps.lookup ns_ prefixes) "" (\p -> p))+      in (Syntax.Name (Strings.cat2 prefix (sanitize local)))+encodeUnionFieldType :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.FieldType -> Either Errors.Error Syntax.FieldDefinition+encodeUnionFieldType cx g prefixes ft =++      let innerType = Core.fieldTypeType ft+          isUnit = Predicates.isUnitType (Strip.deannotateType innerType)+          effectiveType = Logic.ifElse isUnit (Core.TypeOptional (Core.TypeLiteral Core.LiteralTypeBoolean)) (Core.TypeOptional innerType)+      in (Eithers.bind (encodeType cx g prefixes effectiveType) (\gtype -> Eithers.bind (descriptionFromType cx g innerType) (\desc -> Right (Syntax.FieldDefinition {+        Syntax.fieldDefinitionDescription = desc,+        Syntax.fieldDefinitionName = (encodeFieldName (Core.fieldTypeName ft)),+        Syntax.fieldDefinitionArgumentsDefinition = Nothing,+        Syntax.fieldDefinitionType = gtype,+        Syntax.fieldDefinitionDirectives = Nothing}))))+moduleToGraphql :: Packaging.Module -> [Packaging.Definition] -> t0 -> Graph.Graph -> Either Errors.Error (M.Map String String)+moduleToGraphql mod defs cx g =++      let partitioned = Environment.partitionDefinitions defs+          typeDefs = Pairs.first partitioned+          prefixes =+                  (\modNs -> \tdefs ->+                    let namespaces = Lists.nub (Optionals.cat (Lists.map (\td -> Names.moduleNameOf (Packaging.typeDefinitionName td)) tdefs))+                    in (Maps.fromList (Lists.map (\ns_ -> (+                      ns_,+                      (Logic.ifElse (Equality.equal ns_ modNs) "" (Strings.cat2 (Formatting.sanitizeWithUnderscores Sets.empty (Packaging.unModuleName ns_)) "_")))) namespaces))) (Packaging.moduleName mod) typeDefs+          filePath = Names.moduleNameToFilePath Util.CaseConventionCamel (File.FileExtension "graphql") (Packaging.moduleName mod)+      in (Eithers.bind (Eithers.mapList (\td -> encodeTypeDefinition cx g prefixes td) typeDefs) (\gtdefs -> Right (Maps.fromList (Lists.pure (+        filePath,+        (Serialization.printExpr (Serialization.parenthesize (Serde.documentToExpr (Syntax.Document (Lists.map (\gtdef -> Syntax.DefinitionTypeSystem (Syntax.TypeSystemDefinitionOrExtensionDefinition (Syntax.TypeSystemDefinitionType gtdef))) gtdefs))))))))))+sanitize :: String -> String+sanitize s = Formatting.sanitizeWithUnderscores Language.graphqlReservedWords s
+ src/main/haskell/Hydra/Graphql/Language.hs view
@@ -0,0 +1,91 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints and reserved words for GraphQL++module Hydra.Graphql.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | Language constraints for GraphQL+graphqlLanguage :: Coders.Language+graphqlLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.graphql"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes = Sets.fromList [+      Core.FloatTypeFloat64]+    integerTypes = Sets.fromList [+      Core.IntegerTypeInt32]+    termVariants =+        Sets.fromList [+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantOptional,+          Variants.TermVariantRecord,+          Variants.TermVariantInject]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantApplication,+          Variants.TypeVariantEither,+          Variants.TypeVariantForall,+          Variants.TypeVariantFunction,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantPair,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnit,+          Variants.TypeVariantWrap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantRecord,+          Variants.TypeVariantUnion,+          Variants.TypeVariantVariable]+    typePredicate =+        \typ -> case (Strip.deannotateType typ) of+          Core.TypeOptional v0 -> case (Strip.deannotateType v0) of+            Core.TypeOptional _ -> False+            _ -> True+          _ -> True+-- | A set of reserved words in GraphQL+graphqlReservedWords :: S.Set String+graphqlReservedWords =+    Sets.fromList [+      "true",+      "false"]
+ src/main/haskell/Hydra/Graphql/Serde.hs view
@@ -0,0 +1,160 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Serialization functions for converting GraphQL AST to abstract expressions++module Hydra.Graphql.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Graphql.Syntax as Syntax+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Convert a GraphQL definition to an expression+definitionToExpr :: Syntax.Definition -> Ast.Expr+definitionToExpr def =+    case def of+      Syntax.DefinitionExecutable _ -> Serialization.cst "Unsupported: executable definition"+      Syntax.DefinitionTypeSystem v0 -> typeSystemDefinitionOrExtensionToExpr v0+-- | Convert a GraphQL description to a triple-quoted comment+descriptionToExpr :: Syntax.Description -> Ast.Expr+descriptionToExpr desc =++      let delim = Serialization.cst "\"\"\""+          text = Syntax.unStringValue (Syntax.unDescription desc)+      in (Serialization.newlineSep [+        delim,+        (Serialization.cst text),+        delim])+-- | Convert a GraphQL document to an expression+documentToExpr :: Syntax.Document -> Ast.Expr+documentToExpr d = Serialization.doubleNewlineSep (Lists.map definitionToExpr (Syntax.unDocument d))+-- | Convert a GraphQL enum type definition to an expression+enumTypeDefinitionToExpr :: Syntax.EnumTypeDefinition -> Ast.Expr+enumTypeDefinitionToExpr def =++      let desc = Syntax.enumTypeDefinitionDescription def+          name = Syntax.enumTypeDefinitionName def+          values = Syntax.enumTypeDefinitionEnumValuesDefinition def+          valuesExpr = Optionals.cases values [] (\vs -> Lists.map enumValueDefinitionToExpr (Syntax.unEnumValuesDefinition vs))+      in (withDescription desc (Serialization.spaceSep [+        Serialization.cst "enum",+        (nameToExpr name),+        (Serialization.curlyBracesList Nothing Serialization.fullBlockStyle valuesExpr)]))+-- | Convert a GraphQL enum value definition to an expression+enumValueDefinitionToExpr :: Syntax.EnumValueDefinition -> Ast.Expr+enumValueDefinitionToExpr def =++      let desc = Syntax.enumValueDefinitionDescription def+          ev = Syntax.enumValueDefinitionEnumValue def+      in (withDescription desc (enumValueToExpr ev))+-- | Convert a GraphQL enum value to an expression+enumValueToExpr :: Syntax.EnumValue -> Ast.Expr+enumValueToExpr ev = nameToExpr (Syntax.unEnumValue ev)+-- | Convert a GraphQL field definition to an expression+fieldDefinitionToExpr :: Syntax.FieldDefinition -> Ast.Expr+fieldDefinitionToExpr def =++      let desc = Syntax.fieldDefinitionDescription def+          name = Syntax.fieldDefinitionName def+          typ = Syntax.fieldDefinitionType def+          namePart =+                  Serialization.noSep [+                    nameToExpr name,+                    (Serialization.cst ":")]+          typePart = typeToExpr typ+      in (withDescription desc (Serialization.spaceSep [+        namePart,+        typePart]))+-- | Convert a GraphQL list type to an expression+listTypeToExpr :: Syntax.ListType -> Ast.Expr+listTypeToExpr lt =+    Serialization.noSep [+      Serialization.cst "[",+      (typeToExpr (Syntax.unListType lt)),+      (Serialization.cst "]")]+-- | Convert a GraphQL name to an expression+nameToExpr :: Syntax.Name -> Ast.Expr+nameToExpr n = Serialization.cst (Syntax.unName n)+-- | Convert a GraphQL named type to an expression+namedTypeToExpr :: Syntax.NamedType -> Ast.Expr+namedTypeToExpr nt = nameToExpr (Syntax.unNamedType nt)+-- | Convert a GraphQL non-null type to an expression+nonNullTypeToExpr :: Syntax.NonNullType -> Ast.Expr+nonNullTypeToExpr nnt =++      let typeExpr =+              case nnt of+                Syntax.NonNullTypeNamed v0 -> namedTypeToExpr v0+                Syntax.NonNullTypeList v0 -> listTypeToExpr v0+      in (Serialization.noSep [+        typeExpr,+        (Serialization.cst "!")])+-- | Convert a GraphQL object type definition to an expression+objectTypeDefinitionToExpr :: Syntax.ObjectTypeDefinition -> Ast.Expr+objectTypeDefinitionToExpr def =++      let desc = Syntax.objectTypeDefinitionDescription def+          name = Syntax.objectTypeDefinitionName def+          fields = Syntax.objectTypeDefinitionFieldsDefinition def+          fieldsExpr = Optionals.cases fields [] (\fs -> Lists.map fieldDefinitionToExpr (Syntax.unFieldsDefinition fs))+      in (withDescription desc (Serialization.spaceSep [+        Serialization.cst "type",+        (nameToExpr name),+        (Serialization.curlyBracesList Nothing Serialization.fullBlockStyle fieldsExpr)]))+-- | Convert a GraphQL type definition to an expression+typeDefinitionToExpr :: Syntax.TypeDefinition -> Ast.Expr+typeDefinitionToExpr def =+    case def of+      Syntax.TypeDefinitionScalar _ -> Serialization.cst "Unsupported: scalar type definition"+      Syntax.TypeDefinitionObject v0 -> objectTypeDefinitionToExpr v0+      Syntax.TypeDefinitionInterface _ -> Serialization.cst "Unsupported: interface type definition"+      Syntax.TypeDefinitionUnion _ -> Serialization.cst "Unsupported: union type definition"+      Syntax.TypeDefinitionEnum v0 -> enumTypeDefinitionToExpr v0+      Syntax.TypeDefinitionInputObject _ -> Serialization.cst "Unsupported: input object type definition"+-- | Convert a GraphQL type system definition or extension to an expression+typeSystemDefinitionOrExtensionToExpr :: Syntax.TypeSystemDefinitionOrExtension -> Ast.Expr+typeSystemDefinitionOrExtensionToExpr de =+    case de of+      Syntax.TypeSystemDefinitionOrExtensionDefinition v0 -> typeSystemDefinitionToExpr v0+      Syntax.TypeSystemDefinitionOrExtensionExtension _ -> Serialization.cst "Unsupported: type system extension"+-- | Convert a GraphQL type system definition to an expression+typeSystemDefinitionToExpr :: Syntax.TypeSystemDefinition -> Ast.Expr+typeSystemDefinitionToExpr def =+    case def of+      Syntax.TypeSystemDefinitionSchema _ -> Serialization.cst "Unsupported: schema definition"+      Syntax.TypeSystemDefinitionType v0 -> typeDefinitionToExpr v0+      Syntax.TypeSystemDefinitionDirective _ -> Serialization.cst "Unsupported: directive definition"+-- | Convert a GraphQL type to an expression+typeToExpr :: Syntax.Type -> Ast.Expr+typeToExpr typ =+    case typ of+      Syntax.TypeNamed v0 -> namedTypeToExpr v0+      Syntax.TypeList v0 -> listTypeToExpr v0+      Syntax.TypeNonNull v0 -> nonNullTypeToExpr v0+-- | Prepend an optional description to an expression+withDescription :: Maybe Syntax.Description -> Ast.Expr -> Ast.Expr+withDescription mdesc expr =+    Serialization.newlineSep (Optionals.cat [+      Optionals.map descriptionToExpr mdesc,+      (Optionals.pure expr)])
+ src/main/haskell/Hydra/Graphql/Syntax.hs view
@@ -0,0 +1,865 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A GraphQL model. Based on the (extended) BNF at:+-- |   https://spec.graphql.org/draft/#sec-Appendix-Grammar-Summary++module Hydra.Graphql.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+newtype Name =+  Name {+    unName :: String}+  deriving (Eq, Ord, Read, Show)+_Name = Core.Name "hydra.graphql.syntax.Name"+newtype IntValue =+  IntValue {+    unIntValue :: String}+  deriving (Eq, Ord, Read, Show)+_IntValue = Core.Name "hydra.graphql.syntax.IntValue"+newtype FloatValue =+  FloatValue {+    unFloatValue :: String}+  deriving (Eq, Ord, Read, Show)+_FloatValue = Core.Name "hydra.graphql.syntax.FloatValue"+newtype StringValue =+  StringValue {+    unStringValue :: String}+  deriving (Eq, Ord, Read, Show)+_StringValue = Core.Name "hydra.graphql.syntax.StringValue"+newtype Document =+  Document {+    unDocument :: [Definition]}+  deriving (Eq, Ord, Read, Show)+_Document = Core.Name "hydra.graphql.syntax.Document"+data Definition =+  DefinitionExecutable ExecutableDefinition |+  DefinitionTypeSystem TypeSystemDefinitionOrExtension+  deriving (Eq, Ord, Read, Show)+_Definition = Core.Name "hydra.graphql.syntax.Definition"+_Definition_executable = Core.Name "executable"+_Definition_typeSystem = Core.Name "typeSystem"+newtype ExecutableDocument =+  ExecutableDocument {+    unExecutableDocument :: [ExecutableDefinition]}+  deriving (Eq, Ord, Read, Show)+_ExecutableDocument = Core.Name "hydra.graphql.syntax.ExecutableDocument"+data ExecutableDefinition =+  ExecutableDefinitionOperation OperationDefinition |+  ExecutableDefinitionFragment FragmentDefinition+  deriving (Eq, Ord, Read, Show)+_ExecutableDefinition = Core.Name "hydra.graphql.syntax.ExecutableDefinition"+_ExecutableDefinition_operation = Core.Name "operation"+_ExecutableDefinition_fragment = Core.Name "fragment"+data OperationDefinition =+  OperationDefinitionSequence OperationDefinition_Sequence |+  OperationDefinitionSelectionSet SelectionSet+  deriving (Eq, Ord, Read, Show)+_OperationDefinition = Core.Name "hydra.graphql.syntax.OperationDefinition"+_OperationDefinition_sequence = Core.Name "sequence"+_OperationDefinition_SelectionSet = Core.Name "SelectionSet"+data OperationDefinition_Sequence =+  OperationDefinition_Sequence {+    operationDefinition_SequenceOperationType :: OperationType,+    operationDefinition_SequenceName :: (Maybe Name),+    operationDefinition_SequenceVariablesDefinition :: (Maybe VariablesDefinition),+    operationDefinition_SequenceDirectives :: (Maybe Directives),+    operationDefinition_SequenceSelectionSet :: SelectionSet}+  deriving (Eq, Ord, Read, Show)+_OperationDefinition_Sequence = Core.Name "hydra.graphql.syntax.OperationDefinition_Sequence"+_OperationDefinition_Sequence_OperationType = Core.Name "OperationType"+_OperationDefinition_Sequence_Name = Core.Name "Name"+_OperationDefinition_Sequence_VariablesDefinition = Core.Name "VariablesDefinition"+_OperationDefinition_Sequence_Directives = Core.Name "Directives"+_OperationDefinition_Sequence_SelectionSet = Core.Name "SelectionSet"+data OperationType =+  OperationTypeQuery |+  OperationTypeMutation |+  OperationTypeSubscription+  deriving (Eq, Ord, Read, Show)+_OperationType = Core.Name "hydra.graphql.syntax.OperationType"+_OperationType_Query = Core.Name "Query"+_OperationType_Mutation = Core.Name "Mutation"+_OperationType_Subscription = Core.Name "Subscription"+newtype SelectionSet =+  SelectionSet {+    unSelectionSet :: [Selection]}+  deriving (Eq, Ord, Read, Show)+_SelectionSet = Core.Name "hydra.graphql.syntax.SelectionSet"+data Selection =+  SelectionField Field |+  SelectionFragmentSpread FragmentSpread |+  SelectionInlineFragment InlineFragment+  deriving (Eq, Ord, Read, Show)+_Selection = Core.Name "hydra.graphql.syntax.Selection"+_Selection_Field = Core.Name "Field"+_Selection_FragmentSpread = Core.Name "FragmentSpread"+_Selection_InlineFragment = Core.Name "InlineFragment"+data Field =+  Field {+    fieldAlias :: (Maybe Alias),+    fieldName :: Name,+    fieldArguments :: (Maybe Arguments),+    fieldDirectives :: (Maybe Directives),+    fieldSelectionSet :: (Maybe SelectionSet)}+  deriving (Eq, Ord, Read, Show)+_Field = Core.Name "hydra.graphql.syntax.Field"+_Field_Alias = Core.Name "Alias"+_Field_Name = Core.Name "Name"+_Field_Arguments = Core.Name "Arguments"+_Field_Directives = Core.Name "Directives"+_Field_SelectionSet = Core.Name "SelectionSet"+data Alias =+  AliasName Name |+  AliasColon+  deriving (Eq, Ord, Read, Show)+_Alias = Core.Name "hydra.graphql.syntax.Alias"+_Alias_Name = Core.Name "Name"+_Alias_Colon = Core.Name "Colon"+newtype Arguments =+  Arguments {+    unArguments :: [Argument]}+  deriving (Eq, Ord, Read, Show)+_Arguments = Core.Name "hydra.graphql.syntax.Arguments"+data Argument =+  Argument {+    argumentName :: Name,+    argumentValue :: Value}+  deriving (Eq, Ord, Read, Show)+_Argument = Core.Name "hydra.graphql.syntax.Argument"+_Argument_Name = Core.Name "Name"+_Argument_Value = Core.Name "Value"+data FragmentSpread =+  FragmentSpread {+    fragmentSpreadFragmentName :: FragmentName,+    fragmentSpreadDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_FragmentSpread = Core.Name "hydra.graphql.syntax.FragmentSpread"+_FragmentSpread_FragmentName = Core.Name "FragmentName"+_FragmentSpread_Directives = Core.Name "Directives"+data InlineFragment =+  InlineFragment {+    inlineFragmentTypeCondition :: (Maybe TypeCondition),+    inlineFragmentDirectives :: (Maybe Directives),+    inlineFragmentSelectionSet :: SelectionSet}+  deriving (Eq, Ord, Read, Show)+_InlineFragment = Core.Name "hydra.graphql.syntax.InlineFragment"+_InlineFragment_TypeCondition = Core.Name "TypeCondition"+_InlineFragment_Directives = Core.Name "Directives"+_InlineFragment_SelectionSet = Core.Name "SelectionSet"+data FragmentDefinition =+  FragmentDefinition {+    fragmentDefinitionFragmentName :: FragmentName,+    fragmentDefinitionTypeCondition :: TypeCondition,+    fragmentDefinitionDirectives :: (Maybe Directives),+    fragmentDefinitionSelectionSet :: SelectionSet}+  deriving (Eq, Ord, Read, Show)+_FragmentDefinition = Core.Name "hydra.graphql.syntax.FragmentDefinition"+_FragmentDefinition_FragmentName = Core.Name "FragmentName"+_FragmentDefinition_TypeCondition = Core.Name "TypeCondition"+_FragmentDefinition_Directives = Core.Name "Directives"+_FragmentDefinition_SelectionSet = Core.Name "SelectionSet"+newtype FragmentName =+  FragmentName {+    unFragmentName :: Name}+  deriving (Eq, Ord, Read, Show)+_FragmentName = Core.Name "hydra.graphql.syntax.FragmentName"+data TypeCondition =+  TypeConditionOn |+  TypeConditionNamedType NamedType+  deriving (Eq, Ord, Read, Show)+_TypeCondition = Core.Name "hydra.graphql.syntax.TypeCondition"+_TypeCondition_On = Core.Name "On"+_TypeCondition_NamedType = Core.Name "NamedType"+data Value =+  ValueVariable Variable |+  ValueInt IntValue |+  ValueFloat FloatValue |+  ValueString StringValue |+  ValueBoolean BooleanValue |+  ValueNull NullValue |+  ValueEnum EnumValue |+  ValueList ListValue |+  ValueObject ObjectValue+  deriving (Eq, Ord, Read, Show)+_Value = Core.Name "hydra.graphql.syntax.Value"+_Value_Variable = Core.Name "Variable"+_Value_int = Core.Name "int"+_Value_float = Core.Name "float"+_Value_string = Core.Name "string"+_Value_boolean = Core.Name "boolean"+_Value_null = Core.Name "null"+_Value_enum = Core.Name "enum"+_Value_list = Core.Name "list"+_Value_object = Core.Name "object"+data BooleanValue =+  BooleanValueTrue |+  BooleanValueFalse+  deriving (Eq, Ord, Read, Show)+_BooleanValue = Core.Name "hydra.graphql.syntax.BooleanValue"+_BooleanValue_True = Core.Name "True"+_BooleanValue_False = Core.Name "False"+newtype NullValue =+  NullValue {+    unNullValue :: ()}+  deriving (Eq, Ord, Read, Show)+_NullValue = Core.Name "hydra.graphql.syntax.NullValue"+newtype EnumValue =+  EnumValue {+    unEnumValue :: Name}+  deriving (Eq, Ord, Read, Show)+_EnumValue = Core.Name "hydra.graphql.syntax.EnumValue"+data ListValue =+  ListValueSequence ListValue_Sequence |+  ListValueSequence2 [Value]+  deriving (Eq, Ord, Read, Show)+_ListValue = Core.Name "hydra.graphql.syntax.ListValue"+_ListValue_sequence = Core.Name "sequence"+_ListValue_sequence2 = Core.Name "sequence2"+data ListValue_Sequence =+  ListValue_Sequence {}+  deriving (Eq, Ord, Read, Show)+_ListValue_Sequence = Core.Name "hydra.graphql.syntax.ListValue_Sequence"+data ObjectValue =+  ObjectValueSequence ObjectValue_Sequence |+  ObjectValueSequence2 [ObjectField]+  deriving (Eq, Ord, Read, Show)+_ObjectValue = Core.Name "hydra.graphql.syntax.ObjectValue"+_ObjectValue_sequence = Core.Name "sequence"+_ObjectValue_sequence2 = Core.Name "sequence2"+data ObjectValue_Sequence =+  ObjectValue_Sequence {}+  deriving (Eq, Ord, Read, Show)+_ObjectValue_Sequence = Core.Name "hydra.graphql.syntax.ObjectValue_Sequence"+data ObjectField =+  ObjectField {+    objectFieldName :: Name,+    objectFieldValue :: Value}+  deriving (Eq, Ord, Read, Show)+_ObjectField = Core.Name "hydra.graphql.syntax.ObjectField"+_ObjectField_Name = Core.Name "Name"+_ObjectField_Value = Core.Name "Value"+data VariablesDefinition =+  VariablesDefinition {+    variablesDefinitionVariable :: Variable,+    variablesDefinitionType :: Type,+    variablesDefinitionDefaultValue :: (Maybe DefaultValue),+    variablesDefinitionDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_VariablesDefinition = Core.Name "hydra.graphql.syntax.VariablesDefinition"+_VariablesDefinition_Variable = Core.Name "Variable"+_VariablesDefinition_Type = Core.Name "Type"+_VariablesDefinition_DefaultValue = Core.Name "DefaultValue"+_VariablesDefinition_Directives = Core.Name "Directives"+newtype Variable =+  Variable {+    unVariable :: Name}+  deriving (Eq, Ord, Read, Show)+_Variable = Core.Name "hydra.graphql.syntax.Variable"+newtype DefaultValue =+  DefaultValue {+    unDefaultValue :: Value}+  deriving (Eq, Ord, Read, Show)+_DefaultValue = Core.Name "hydra.graphql.syntax.DefaultValue"+data Type =+  TypeNamed NamedType |+  TypeList ListType |+  TypeNonNull NonNullType+  deriving (Eq, Ord, Read, Show)+_Type = Core.Name "hydra.graphql.syntax.Type"+_Type_named = Core.Name "named"+_Type_list = Core.Name "list"+_Type_nonNull = Core.Name "nonNull"+newtype NamedType =+  NamedType {+    unNamedType :: Name}+  deriving (Eq, Ord, Read, Show)+_NamedType = Core.Name "hydra.graphql.syntax.NamedType"+newtype ListType =+  ListType {+    unListType :: Type}+  deriving (Eq, Ord, Read, Show)+_ListType = Core.Name "hydra.graphql.syntax.ListType"+data NonNullType =+  NonNullTypeNamed NamedType |+  NonNullTypeList ListType+  deriving (Eq, Ord, Read, Show)+_NonNullType = Core.Name "hydra.graphql.syntax.NonNullType"+_NonNullType_named = Core.Name "named"+_NonNullType_list = Core.Name "list"+newtype Directives =+  Directives {+    unDirectives :: [Directive]}+  deriving (Eq, Ord, Read, Show)+_Directives = Core.Name "hydra.graphql.syntax.Directives"+data Directive =+  Directive {+    directiveName :: Name,+    directiveArguments :: (Maybe Arguments)}+  deriving (Eq, Ord, Read, Show)+_Directive = Core.Name "hydra.graphql.syntax.Directive"+_Directive_Name = Core.Name "Name"+_Directive_Arguments = Core.Name "Arguments"+newtype TypeSystemDocment =+  TypeSystemDocment {+    unTypeSystemDocment :: [TypeSystemDefinition]}+  deriving (Eq, Ord, Read, Show)+_TypeSystemDocment = Core.Name "hydra.graphql.syntax.TypeSystemDocment"+data TypeSystemDefinition =+  TypeSystemDefinitionSchema SchemaDefinition |+  TypeSystemDefinitionType TypeDefinition |+  TypeSystemDefinitionDirective DirectiveDefinition+  deriving (Eq, Ord, Read, Show)+_TypeSystemDefinition = Core.Name "hydra.graphql.syntax.TypeSystemDefinition"+_TypeSystemDefinition_schema = Core.Name "schema"+_TypeSystemDefinition_type = Core.Name "type"+_TypeSystemDefinition_directive = Core.Name "directive"+newtype TypeSystemExtensionDocument =+  TypeSystemExtensionDocument {+    unTypeSystemExtensionDocument :: [TypeSystemDefinitionOrExtension]}+  deriving (Eq, Ord, Read, Show)+_TypeSystemExtensionDocument = Core.Name "hydra.graphql.syntax.TypeSystemExtensionDocument"+data TypeSystemDefinitionOrExtension =+  TypeSystemDefinitionOrExtensionDefinition TypeSystemDefinition |+  TypeSystemDefinitionOrExtensionExtension TypeSystemExtension+  deriving (Eq, Ord, Read, Show)+_TypeSystemDefinitionOrExtension = Core.Name "hydra.graphql.syntax.TypeSystemDefinitionOrExtension"+_TypeSystemDefinitionOrExtension_definition = Core.Name "definition"+_TypeSystemDefinitionOrExtension_extension = Core.Name "extension"+data TypeSystemExtension =+  TypeSystemExtensionSchema SchemaExtension |+  TypeSystemExtensionType TypeExtension+  deriving (Eq, Ord, Read, Show)+_TypeSystemExtension = Core.Name "hydra.graphql.syntax.TypeSystemExtension"+_TypeSystemExtension_schema = Core.Name "schema"+_TypeSystemExtension_type = Core.Name "type"+data SchemaDefinition =+  SchemaDefinition {+    schemaDefinitionDescription :: (Maybe Description),+    schemaDefinitionDirectives :: (Maybe Directives),+    schemaDefinitionRootOperationTypeDefinition :: RootOperationTypeDefinition}+  deriving (Eq, Ord, Read, Show)+_SchemaDefinition = Core.Name "hydra.graphql.syntax.SchemaDefinition"+_SchemaDefinition_Description = Core.Name "Description"+_SchemaDefinition_Directives = Core.Name "Directives"+_SchemaDefinition_RootOperationTypeDefinition = Core.Name "RootOperationTypeDefinition"+data SchemaExtension =+  SchemaExtensionSequence SchemaExtension_Sequence |+  SchemaExtensionSequence2 Directives+  deriving (Eq, Ord, Read, Show)+_SchemaExtension = Core.Name "hydra.graphql.syntax.SchemaExtension"+_SchemaExtension_sequence = Core.Name "sequence"+_SchemaExtension_sequence2 = Core.Name "sequence2"+data SchemaExtension_Sequence =+  SchemaExtension_Sequence {+    schemaExtension_SequenceDirectives :: (Maybe Directives),+    schemaExtension_SequenceRootOperationTypeDefinition :: RootOperationTypeDefinition}+  deriving (Eq, Ord, Read, Show)+_SchemaExtension_Sequence = Core.Name "hydra.graphql.syntax.SchemaExtension_Sequence"+_SchemaExtension_Sequence_Directives = Core.Name "Directives"+_SchemaExtension_Sequence_RootOperationTypeDefinition = Core.Name "RootOperationTypeDefinition"+data RootOperationTypeDefinition =+  RootOperationTypeDefinition {+    rootOperationTypeDefinitionOperationType :: OperationType,+    rootOperationTypeDefinitionNamedType :: NamedType}+  deriving (Eq, Ord, Read, Show)+_RootOperationTypeDefinition = Core.Name "hydra.graphql.syntax.RootOperationTypeDefinition"+_RootOperationTypeDefinition_OperationType = Core.Name "OperationType"+_RootOperationTypeDefinition_NamedType = Core.Name "NamedType"+newtype Description =+  Description {+    unDescription :: StringValue}+  deriving (Eq, Ord, Read, Show)+_Description = Core.Name "hydra.graphql.syntax.Description"+data TypeDefinition =+  TypeDefinitionScalar ScalarTypeDefinition |+  TypeDefinitionObject ObjectTypeDefinition |+  TypeDefinitionInterface InterfaceTypeDefinition |+  TypeDefinitionUnion UnionTypeDefinition |+  TypeDefinitionEnum EnumTypeDefinition |+  TypeDefinitionInputObject InputObjectTypeDefinition+  deriving (Eq, Ord, Read, Show)+_TypeDefinition = Core.Name "hydra.graphql.syntax.TypeDefinition"+_TypeDefinition_scalar = Core.Name "scalar"+_TypeDefinition_object = Core.Name "object"+_TypeDefinition_interface = Core.Name "interface"+_TypeDefinition_union = Core.Name "union"+_TypeDefinition_enum = Core.Name "enum"+_TypeDefinition_inputObject = Core.Name "inputObject"+data TypeExtension =+  TypeExtensionScalar ScalarTypeExtension |+  TypeExtensionObject ObjectTypeExtension |+  TypeExtensionInterface InterfaceTypeExtension |+  TypeExtensionUnion UnionTypeExtension |+  TypeExtensionEnum EnumTypeExtension |+  TypeExtensionInputObject InputObjectTypeExtension+  deriving (Eq, Ord, Read, Show)+_TypeExtension = Core.Name "hydra.graphql.syntax.TypeExtension"+_TypeExtension_scalar = Core.Name "scalar"+_TypeExtension_object = Core.Name "object"+_TypeExtension_interface = Core.Name "interface"+_TypeExtension_union = Core.Name "union"+_TypeExtension_enum = Core.Name "enum"+_TypeExtension_inputObject = Core.Name "inputObject"+data ScalarTypeDefinition =+  ScalarTypeDefinition {+    scalarTypeDefinitionDescription :: (Maybe Description),+    scalarTypeDefinitionName :: Name,+    scalarTypeDefinitionDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_ScalarTypeDefinition = Core.Name "hydra.graphql.syntax.ScalarTypeDefinition"+_ScalarTypeDefinition_Description = Core.Name "Description"+_ScalarTypeDefinition_Name = Core.Name "Name"+_ScalarTypeDefinition_Directives = Core.Name "Directives"+data ScalarTypeExtension =+  ScalarTypeExtension {+    scalarTypeExtensionName :: Name,+    scalarTypeExtensionDirectives :: Directives}+  deriving (Eq, Ord, Read, Show)+_ScalarTypeExtension = Core.Name "hydra.graphql.syntax.ScalarTypeExtension"+_ScalarTypeExtension_Name = Core.Name "Name"+_ScalarTypeExtension_Directives = Core.Name "Directives"+data ObjectTypeDefinition =+  ObjectTypeDefinition {+    objectTypeDefinitionDescription :: (Maybe Description),+    objectTypeDefinitionName :: Name,+    objectTypeDefinitionImplementsInterfaces :: (Maybe ImplementsInterfaces),+    objectTypeDefinitionDirectives :: (Maybe Directives),+    objectTypeDefinitionFieldsDefinition :: (Maybe FieldsDefinition)}+  deriving (Eq, Ord, Read, Show)+_ObjectTypeDefinition = Core.Name "hydra.graphql.syntax.ObjectTypeDefinition"+_ObjectTypeDefinition_Description = Core.Name "Description"+_ObjectTypeDefinition_Name = Core.Name "Name"+_ObjectTypeDefinition_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_ObjectTypeDefinition_Directives = Core.Name "Directives"+_ObjectTypeDefinition_FieldsDefinition = Core.Name "FieldsDefinition"+data ObjectTypeExtension =+  ObjectTypeExtensionSequence ObjectTypeExtension_Sequence |+  ObjectTypeExtensionSequence2 ObjectTypeExtension_Sequence2 |+  ObjectTypeExtensionSequence3 ObjectTypeExtension_Sequence3+  deriving (Eq, Ord, Read, Show)+_ObjectTypeExtension = Core.Name "hydra.graphql.syntax.ObjectTypeExtension"+_ObjectTypeExtension_sequence = Core.Name "sequence"+_ObjectTypeExtension_sequence2 = Core.Name "sequence2"+_ObjectTypeExtension_sequence3 = Core.Name "sequence3"+data ObjectTypeExtension_Sequence =+  ObjectTypeExtension_Sequence {+    objectTypeExtension_SequenceName :: Name,+    objectTypeExtension_SequenceImplementsInterfaces :: (Maybe ImplementsInterfaces),+    objectTypeExtension_SequenceDirectives :: (Maybe Directives),+    objectTypeExtension_SequenceFieldsDefinition :: FieldsDefinition}+  deriving (Eq, Ord, Read, Show)+_ObjectTypeExtension_Sequence = Core.Name "hydra.graphql.syntax.ObjectTypeExtension_Sequence"+_ObjectTypeExtension_Sequence_Name = Core.Name "Name"+_ObjectTypeExtension_Sequence_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_ObjectTypeExtension_Sequence_Directives = Core.Name "Directives"+_ObjectTypeExtension_Sequence_FieldsDefinition = Core.Name "FieldsDefinition"+data ObjectTypeExtension_Sequence2 =+  ObjectTypeExtension_Sequence2 {+    objectTypeExtension_Sequence2Name :: Name,+    objectTypeExtension_Sequence2ImplementsInterfaces :: (Maybe ImplementsInterfaces),+    objectTypeExtension_Sequence2Directives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_ObjectTypeExtension_Sequence2 = Core.Name "hydra.graphql.syntax.ObjectTypeExtension_Sequence2"+_ObjectTypeExtension_Sequence2_Name = Core.Name "Name"+_ObjectTypeExtension_Sequence2_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_ObjectTypeExtension_Sequence2_Directives = Core.Name "Directives"+data ObjectTypeExtension_Sequence3 =+  ObjectTypeExtension_Sequence3 {+    objectTypeExtension_Sequence3Name :: Name,+    objectTypeExtension_Sequence3ImplementsInterfaces :: ImplementsInterfaces}+  deriving (Eq, Ord, Read, Show)+_ObjectTypeExtension_Sequence3 = Core.Name "hydra.graphql.syntax.ObjectTypeExtension_Sequence3"+_ObjectTypeExtension_Sequence3_Name = Core.Name "Name"+_ObjectTypeExtension_Sequence3_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+data ImplementsInterfaces =+  ImplementsInterfacesSequence ImplementsInterfaces_Sequence |+  ImplementsInterfacesSequence2 ImplementsInterfaces_Sequence2+  deriving (Eq, Ord, Read, Show)+_ImplementsInterfaces = Core.Name "hydra.graphql.syntax.ImplementsInterfaces"+_ImplementsInterfaces_sequence = Core.Name "sequence"+_ImplementsInterfaces_sequence2 = Core.Name "sequence2"+data ImplementsInterfaces_Sequence =+  ImplementsInterfaces_Sequence {+    implementsInterfaces_SequenceImplementsInterfaces :: ImplementsInterfaces,+    implementsInterfaces_SequenceNamedType :: NamedType}+  deriving (Eq, Ord, Read, Show)+_ImplementsInterfaces_Sequence = Core.Name "hydra.graphql.syntax.ImplementsInterfaces_Sequence"+_ImplementsInterfaces_Sequence_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_ImplementsInterfaces_Sequence_NamedType = Core.Name "NamedType"+data ImplementsInterfaces_Sequence2 =+  ImplementsInterfaces_Sequence2 {+    implementsInterfaces_Sequence2Amp :: (Maybe ()),+    implementsInterfaces_Sequence2NamedType :: NamedType}+  deriving (Eq, Ord, Read, Show)+_ImplementsInterfaces_Sequence2 = Core.Name "hydra.graphql.syntax.ImplementsInterfaces_Sequence2"+_ImplementsInterfaces_Sequence2_Amp = Core.Name "Amp"+_ImplementsInterfaces_Sequence2_NamedType = Core.Name "NamedType"+newtype FieldsDefinition =+  FieldsDefinition {+    unFieldsDefinition :: [FieldDefinition]}+  deriving (Eq, Ord, Read, Show)+_FieldsDefinition = Core.Name "hydra.graphql.syntax.FieldsDefinition"+data FieldDefinition =+  FieldDefinition {+    fieldDefinitionDescription :: (Maybe Description),+    fieldDefinitionName :: Name,+    fieldDefinitionArgumentsDefinition :: (Maybe ArgumentsDefinition),+    fieldDefinitionType :: Type,+    fieldDefinitionDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_FieldDefinition = Core.Name "hydra.graphql.syntax.FieldDefinition"+_FieldDefinition_Description = Core.Name "Description"+_FieldDefinition_Name = Core.Name "Name"+_FieldDefinition_ArgumentsDefinition = Core.Name "ArgumentsDefinition"+_FieldDefinition_Type = Core.Name "Type"+_FieldDefinition_Directives = Core.Name "Directives"+newtype ArgumentsDefinition =+  ArgumentsDefinition {+    unArgumentsDefinition :: [InputValueDefinition]}+  deriving (Eq, Ord, Read, Show)+_ArgumentsDefinition = Core.Name "hydra.graphql.syntax.ArgumentsDefinition"+data InputValueDefinition =+  InputValueDefinition {+    inputValueDefinitionDescription :: (Maybe Description),+    inputValueDefinitionName :: Name,+    inputValueDefinitionType :: Type,+    inputValueDefinitionDefaultValue :: (Maybe DefaultValue),+    inputValueDefinitionDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_InputValueDefinition = Core.Name "hydra.graphql.syntax.InputValueDefinition"+_InputValueDefinition_Description = Core.Name "Description"+_InputValueDefinition_Name = Core.Name "Name"+_InputValueDefinition_Type = Core.Name "Type"+_InputValueDefinition_DefaultValue = Core.Name "DefaultValue"+_InputValueDefinition_Directives = Core.Name "Directives"+data InterfaceTypeDefinition =+  InterfaceTypeDefinitionSequence InterfaceTypeDefinition_Sequence |+  InterfaceTypeDefinitionSequence2 InterfaceTypeDefinition_Sequence2+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeDefinition = Core.Name "hydra.graphql.syntax.InterfaceTypeDefinition"+_InterfaceTypeDefinition_sequence = Core.Name "sequence"+_InterfaceTypeDefinition_sequence2 = Core.Name "sequence2"+data InterfaceTypeDefinition_Sequence =+  InterfaceTypeDefinition_Sequence {+    interfaceTypeDefinition_SequenceDescription :: (Maybe Description),+    interfaceTypeDefinition_SequenceName :: Name,+    interfaceTypeDefinition_SequenceImplementsInterfaces :: (Maybe ImplementsInterfaces),+    interfaceTypeDefinition_SequenceDirectives :: (Maybe Directives),+    interfaceTypeDefinition_SequenceFieldsDefinition :: FieldsDefinition}+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeDefinition_Sequence = Core.Name "hydra.graphql.syntax.InterfaceTypeDefinition_Sequence"+_InterfaceTypeDefinition_Sequence_Description = Core.Name "Description"+_InterfaceTypeDefinition_Sequence_Name = Core.Name "Name"+_InterfaceTypeDefinition_Sequence_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_InterfaceTypeDefinition_Sequence_Directives = Core.Name "Directives"+_InterfaceTypeDefinition_Sequence_FieldsDefinition = Core.Name "FieldsDefinition"+data InterfaceTypeDefinition_Sequence2 =+  InterfaceTypeDefinition_Sequence2 {+    interfaceTypeDefinition_Sequence2Description :: (Maybe Description),+    interfaceTypeDefinition_Sequence2Name :: Name,+    interfaceTypeDefinition_Sequence2ImplementsInterfaces :: ImplementsInterfaces,+    interfaceTypeDefinition_Sequence2Directives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeDefinition_Sequence2 = Core.Name "hydra.graphql.syntax.InterfaceTypeDefinition_Sequence2"+_InterfaceTypeDefinition_Sequence2_Description = Core.Name "Description"+_InterfaceTypeDefinition_Sequence2_Name = Core.Name "Name"+_InterfaceTypeDefinition_Sequence2_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_InterfaceTypeDefinition_Sequence2_Directives = Core.Name "Directives"+data InterfaceTypeExtension =+  InterfaceTypeExtensionSequence InterfaceTypeExtension_Sequence |+  InterfaceTypeExtensionSequence2 InterfaceTypeExtension_Sequence2 |+  InterfaceTypeExtensionSequence3 InterfaceTypeExtension_Sequence3+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeExtension = Core.Name "hydra.graphql.syntax.InterfaceTypeExtension"+_InterfaceTypeExtension_sequence = Core.Name "sequence"+_InterfaceTypeExtension_sequence2 = Core.Name "sequence2"+_InterfaceTypeExtension_sequence3 = Core.Name "sequence3"+data InterfaceTypeExtension_Sequence =+  InterfaceTypeExtension_Sequence {+    interfaceTypeExtension_SequenceName :: Name,+    interfaceTypeExtension_SequenceImplementsInterfaces :: (Maybe ImplementsInterfaces),+    interfaceTypeExtension_SequenceDirectives :: (Maybe Directives),+    interfaceTypeExtension_SequenceFieldsDefinition :: FieldsDefinition}+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeExtension_Sequence = Core.Name "hydra.graphql.syntax.InterfaceTypeExtension_Sequence"+_InterfaceTypeExtension_Sequence_Name = Core.Name "Name"+_InterfaceTypeExtension_Sequence_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_InterfaceTypeExtension_Sequence_Directives = Core.Name "Directives"+_InterfaceTypeExtension_Sequence_FieldsDefinition = Core.Name "FieldsDefinition"+data InterfaceTypeExtension_Sequence2 =+  InterfaceTypeExtension_Sequence2 {+    interfaceTypeExtension_Sequence2Name :: Name,+    interfaceTypeExtension_Sequence2ImplementsInterfaces :: (Maybe ImplementsInterfaces),+    interfaceTypeExtension_Sequence2Directives :: Directives}+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeExtension_Sequence2 = Core.Name "hydra.graphql.syntax.InterfaceTypeExtension_Sequence2"+_InterfaceTypeExtension_Sequence2_Name = Core.Name "Name"+_InterfaceTypeExtension_Sequence2_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+_InterfaceTypeExtension_Sequence2_Directives = Core.Name "Directives"+data InterfaceTypeExtension_Sequence3 =+  InterfaceTypeExtension_Sequence3 {+    interfaceTypeExtension_Sequence3Name :: Name,+    interfaceTypeExtension_Sequence3ImplementsInterfaces :: ImplementsInterfaces}+  deriving (Eq, Ord, Read, Show)+_InterfaceTypeExtension_Sequence3 = Core.Name "hydra.graphql.syntax.InterfaceTypeExtension_Sequence3"+_InterfaceTypeExtension_Sequence3_Name = Core.Name "Name"+_InterfaceTypeExtension_Sequence3_ImplementsInterfaces = Core.Name "ImplementsInterfaces"+data UnionTypeDefinition =+  UnionTypeDefinition {+    unionTypeDefinitionDescription :: (Maybe Description),+    unionTypeDefinitionName :: Name,+    unionTypeDefinitionDirectives :: (Maybe Directives),+    unionTypeDefinitionUnionMemberTypes :: (Maybe UnionMemberTypes)}+  deriving (Eq, Ord, Read, Show)+_UnionTypeDefinition = Core.Name "hydra.graphql.syntax.UnionTypeDefinition"+_UnionTypeDefinition_Description = Core.Name "Description"+_UnionTypeDefinition_Name = Core.Name "Name"+_UnionTypeDefinition_Directives = Core.Name "Directives"+_UnionTypeDefinition_UnionMemberTypes = Core.Name "UnionMemberTypes"+data UnionMemberTypes =+  UnionMemberTypesSequence UnionMemberTypes_Sequence |+  UnionMemberTypesSequence2 UnionMemberTypes_Sequence2+  deriving (Eq, Ord, Read, Show)+_UnionMemberTypes = Core.Name "hydra.graphql.syntax.UnionMemberTypes"+_UnionMemberTypes_sequence = Core.Name "sequence"+_UnionMemberTypes_sequence2 = Core.Name "sequence2"+data UnionMemberTypes_Sequence =+  UnionMemberTypes_Sequence {+    unionMemberTypes_SequenceUnionMemberTypes :: UnionMemberTypes,+    unionMemberTypes_SequenceNamedType :: NamedType}+  deriving (Eq, Ord, Read, Show)+_UnionMemberTypes_Sequence = Core.Name "hydra.graphql.syntax.UnionMemberTypes_Sequence"+_UnionMemberTypes_Sequence_UnionMemberTypes = Core.Name "UnionMemberTypes"+_UnionMemberTypes_Sequence_NamedType = Core.Name "NamedType"+data UnionMemberTypes_Sequence2 =+  UnionMemberTypes_Sequence2 {+    unionMemberTypes_Sequence2Or :: (Maybe ()),+    unionMemberTypes_Sequence2NamedType :: NamedType}+  deriving (Eq, Ord, Read, Show)+_UnionMemberTypes_Sequence2 = Core.Name "hydra.graphql.syntax.UnionMemberTypes_Sequence2"+_UnionMemberTypes_Sequence2_Or = Core.Name "Or"+_UnionMemberTypes_Sequence2_NamedType = Core.Name "NamedType"+data UnionTypeExtension =+  UnionTypeExtensionSequence UnionTypeExtension_Sequence |+  UnionTypeExtensionSequence2 UnionTypeExtension_Sequence2+  deriving (Eq, Ord, Read, Show)+_UnionTypeExtension = Core.Name "hydra.graphql.syntax.UnionTypeExtension"+_UnionTypeExtension_sequence = Core.Name "sequence"+_UnionTypeExtension_sequence2 = Core.Name "sequence2"+data UnionTypeExtension_Sequence =+  UnionTypeExtension_Sequence {+    unionTypeExtension_SequenceName :: Name,+    unionTypeExtension_SequenceDirectives :: (Maybe Directives),+    unionTypeExtension_SequenceUnionMemberTypes :: UnionMemberTypes}+  deriving (Eq, Ord, Read, Show)+_UnionTypeExtension_Sequence = Core.Name "hydra.graphql.syntax.UnionTypeExtension_Sequence"+_UnionTypeExtension_Sequence_Name = Core.Name "Name"+_UnionTypeExtension_Sequence_Directives = Core.Name "Directives"+_UnionTypeExtension_Sequence_UnionMemberTypes = Core.Name "UnionMemberTypes"+data UnionTypeExtension_Sequence2 =+  UnionTypeExtension_Sequence2 {+    unionTypeExtension_Sequence2Name :: Name,+    unionTypeExtension_Sequence2Directives :: Directives}+  deriving (Eq, Ord, Read, Show)+_UnionTypeExtension_Sequence2 = Core.Name "hydra.graphql.syntax.UnionTypeExtension_Sequence2"+_UnionTypeExtension_Sequence2_Name = Core.Name "Name"+_UnionTypeExtension_Sequence2_Directives = Core.Name "Directives"+data EnumTypeDefinition =+  EnumTypeDefinition {+    enumTypeDefinitionDescription :: (Maybe Description),+    enumTypeDefinitionName :: Name,+    enumTypeDefinitionDirectives :: (Maybe Directives),+    enumTypeDefinitionEnumValuesDefinition :: (Maybe EnumValuesDefinition)}+  deriving (Eq, Ord, Read, Show)+_EnumTypeDefinition = Core.Name "hydra.graphql.syntax.EnumTypeDefinition"+_EnumTypeDefinition_Description = Core.Name "Description"+_EnumTypeDefinition_Name = Core.Name "Name"+_EnumTypeDefinition_Directives = Core.Name "Directives"+_EnumTypeDefinition_EnumValuesDefinition = Core.Name "EnumValuesDefinition"+newtype EnumValuesDefinition =+  EnumValuesDefinition {+    unEnumValuesDefinition :: [EnumValueDefinition]}+  deriving (Eq, Ord, Read, Show)+_EnumValuesDefinition = Core.Name "hydra.graphql.syntax.EnumValuesDefinition"+data EnumValueDefinition =+  EnumValueDefinition {+    enumValueDefinitionDescription :: (Maybe Description),+    enumValueDefinitionEnumValue :: EnumValue,+    enumValueDefinitionDirectives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_EnumValueDefinition = Core.Name "hydra.graphql.syntax.EnumValueDefinition"+_EnumValueDefinition_Description = Core.Name "Description"+_EnumValueDefinition_EnumValue = Core.Name "EnumValue"+_EnumValueDefinition_Directives = Core.Name "Directives"+data EnumTypeExtension =+  EnumTypeExtensionSequence EnumTypeExtension_Sequence |+  EnumTypeExtensionSequence2 EnumTypeExtension_Sequence2+  deriving (Eq, Ord, Read, Show)+_EnumTypeExtension = Core.Name "hydra.graphql.syntax.EnumTypeExtension"+_EnumTypeExtension_sequence = Core.Name "sequence"+_EnumTypeExtension_sequence2 = Core.Name "sequence2"+data EnumTypeExtension_Sequence =+  EnumTypeExtension_Sequence {+    enumTypeExtension_SequenceName :: Name,+    enumTypeExtension_SequenceDirectives :: (Maybe Directives),+    enumTypeExtension_SequenceEnumValuesDefinition :: EnumValuesDefinition}+  deriving (Eq, Ord, Read, Show)+_EnumTypeExtension_Sequence = Core.Name "hydra.graphql.syntax.EnumTypeExtension_Sequence"+_EnumTypeExtension_Sequence_Name = Core.Name "Name"+_EnumTypeExtension_Sequence_Directives = Core.Name "Directives"+_EnumTypeExtension_Sequence_EnumValuesDefinition = Core.Name "EnumValuesDefinition"+data EnumTypeExtension_Sequence2 =+  EnumTypeExtension_Sequence2 {+    enumTypeExtension_Sequence2Name :: Name,+    enumTypeExtension_Sequence2Directives :: Directives}+  deriving (Eq, Ord, Read, Show)+_EnumTypeExtension_Sequence2 = Core.Name "hydra.graphql.syntax.EnumTypeExtension_Sequence2"+_EnumTypeExtension_Sequence2_Name = Core.Name "Name"+_EnumTypeExtension_Sequence2_Directives = Core.Name "Directives"+data InputObjectTypeDefinition =+  InputObjectTypeDefinitionSequence InputObjectTypeDefinition_Sequence |+  InputObjectTypeDefinitionSequence2 InputObjectTypeDefinition_Sequence2+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeDefinition = Core.Name "hydra.graphql.syntax.InputObjectTypeDefinition"+_InputObjectTypeDefinition_sequence = Core.Name "sequence"+_InputObjectTypeDefinition_sequence2 = Core.Name "sequence2"+data InputObjectTypeDefinition_Sequence =+  InputObjectTypeDefinition_Sequence {+    inputObjectTypeDefinition_SequenceDescription :: (Maybe Description),+    inputObjectTypeDefinition_SequenceName :: Name,+    inputObjectTypeDefinition_SequenceDirectives :: (Maybe Directives),+    inputObjectTypeDefinition_SequenceInputFieldsDefinition :: InputFieldsDefinition}+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeDefinition_Sequence = Core.Name "hydra.graphql.syntax.InputObjectTypeDefinition_Sequence"+_InputObjectTypeDefinition_Sequence_Description = Core.Name "Description"+_InputObjectTypeDefinition_Sequence_Name = Core.Name "Name"+_InputObjectTypeDefinition_Sequence_Directives = Core.Name "Directives"+_InputObjectTypeDefinition_Sequence_InputFieldsDefinition = Core.Name "InputFieldsDefinition"+data InputObjectTypeDefinition_Sequence2 =+  InputObjectTypeDefinition_Sequence2 {+    inputObjectTypeDefinition_Sequence2Description :: (Maybe Description),+    inputObjectTypeDefinition_Sequence2Name :: Name,+    inputObjectTypeDefinition_Sequence2Directives :: (Maybe Directives)}+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeDefinition_Sequence2 = Core.Name "hydra.graphql.syntax.InputObjectTypeDefinition_Sequence2"+_InputObjectTypeDefinition_Sequence2_Description = Core.Name "Description"+_InputObjectTypeDefinition_Sequence2_Name = Core.Name "Name"+_InputObjectTypeDefinition_Sequence2_Directives = Core.Name "Directives"+newtype InputFieldsDefinition =+  InputFieldsDefinition {+    unInputFieldsDefinition :: [InputValueDefinition]}+  deriving (Eq, Ord, Read, Show)+_InputFieldsDefinition = Core.Name "hydra.graphql.syntax.InputFieldsDefinition"+data InputObjectTypeExtension =+  InputObjectTypeExtensionSequence InputObjectTypeExtension_Sequence |+  InputObjectTypeExtensionSequence2 InputObjectTypeExtension_Sequence2+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeExtension = Core.Name "hydra.graphql.syntax.InputObjectTypeExtension"+_InputObjectTypeExtension_sequence = Core.Name "sequence"+_InputObjectTypeExtension_sequence2 = Core.Name "sequence2"+data InputObjectTypeExtension_Sequence =+  InputObjectTypeExtension_Sequence {+    inputObjectTypeExtension_SequenceName :: Name,+    inputObjectTypeExtension_SequenceDirectives :: (Maybe Directives),+    inputObjectTypeExtension_SequenceInputFieldsDefinition :: InputFieldsDefinition}+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeExtension_Sequence = Core.Name "hydra.graphql.syntax.InputObjectTypeExtension_Sequence"+_InputObjectTypeExtension_Sequence_Name = Core.Name "Name"+_InputObjectTypeExtension_Sequence_Directives = Core.Name "Directives"+_InputObjectTypeExtension_Sequence_InputFieldsDefinition = Core.Name "InputFieldsDefinition"+data InputObjectTypeExtension_Sequence2 =+  InputObjectTypeExtension_Sequence2 {+    inputObjectTypeExtension_Sequence2Name :: Name,+    inputObjectTypeExtension_Sequence2Directives :: Directives}+  deriving (Eq, Ord, Read, Show)+_InputObjectTypeExtension_Sequence2 = Core.Name "hydra.graphql.syntax.InputObjectTypeExtension_Sequence2"+_InputObjectTypeExtension_Sequence2_Name = Core.Name "Name"+_InputObjectTypeExtension_Sequence2_Directives = Core.Name "Directives"+data DirectiveDefinition =+  DirectiveDefinition {+    directiveDefinitionDescription :: (Maybe Description),+    directiveDefinitionName :: Name,+    directiveDefinitionArgumentsDefinition :: (Maybe ArgumentsDefinition),+    directiveDefinitionRepeatable :: (Maybe ()),+    directiveDefinitionDirectiveLocations :: DirectiveLocations}+  deriving (Eq, Ord, Read, Show)+_DirectiveDefinition = Core.Name "hydra.graphql.syntax.DirectiveDefinition"+_DirectiveDefinition_Description = Core.Name "Description"+_DirectiveDefinition_Name = Core.Name "Name"+_DirectiveDefinition_ArgumentsDefinition = Core.Name "ArgumentsDefinition"+_DirectiveDefinition_Repeatable = Core.Name "Repeatable"+_DirectiveDefinition_DirectiveLocations = Core.Name "DirectiveLocations"+data DirectiveLocations =+  DirectiveLocationsSequence DirectiveLocations_Sequence |+  DirectiveLocationsSequence2 DirectiveLocations_Sequence2+  deriving (Eq, Ord, Read, Show)+_DirectiveLocations = Core.Name "hydra.graphql.syntax.DirectiveLocations"+_DirectiveLocations_sequence = Core.Name "sequence"+_DirectiveLocations_sequence2 = Core.Name "sequence2"+data DirectiveLocations_Sequence =+  DirectiveLocations_Sequence {+    directiveLocations_SequenceDirectiveLocations :: DirectiveLocations,+    directiveLocations_SequenceDirectiveLocation :: DirectiveLocation}+  deriving (Eq, Ord, Read, Show)+_DirectiveLocations_Sequence = Core.Name "hydra.graphql.syntax.DirectiveLocations_Sequence"+_DirectiveLocations_Sequence_DirectiveLocations = Core.Name "DirectiveLocations"+_DirectiveLocations_Sequence_DirectiveLocation = Core.Name "DirectiveLocation"+data DirectiveLocations_Sequence2 =+  DirectiveLocations_Sequence2 {+    directiveLocations_Sequence2Or :: (Maybe ()),+    directiveLocations_Sequence2DirectiveLocation :: DirectiveLocation}+  deriving (Eq, Ord, Read, Show)+_DirectiveLocations_Sequence2 = Core.Name "hydra.graphql.syntax.DirectiveLocations_Sequence2"+_DirectiveLocations_Sequence2_Or = Core.Name "Or"+_DirectiveLocations_Sequence2_DirectiveLocation = Core.Name "DirectiveLocation"+data DirectiveLocation =+  DirectiveLocationExecutable ExecutableDirectiveLocation |+  DirectiveLocationTypeSystem TypeSystemDirectiveLocation+  deriving (Eq, Ord, Read, Show)+_DirectiveLocation = Core.Name "hydra.graphql.syntax.DirectiveLocation"+_DirectiveLocation_executable = Core.Name "executable"+_DirectiveLocation_typeSystem = Core.Name "typeSystem"+data ExecutableDirectiveLocation =+  ExecutableDirectiveLocationQUERY |+  ExecutableDirectiveLocationMUTATION |+  ExecutableDirectiveLocationSUBSCRIPTION |+  ExecutableDirectiveLocationFIELD |+  ExecutableDirectiveLocationFRAGMENT_DEFINITION |+  ExecutableDirectiveLocationFRAGMENT_SPREAD |+  ExecutableDirectiveLocationINLINE_FRAGMENT |+  ExecutableDirectiveLocationVARIABLE_DEFINITION+  deriving (Eq, Ord, Read, Show)+_ExecutableDirectiveLocation = Core.Name "hydra.graphql.syntax.ExecutableDirectiveLocation"+_ExecutableDirectiveLocation_QUERY = Core.Name "QUERY"+_ExecutableDirectiveLocation_MUTATION = Core.Name "MUTATION"+_ExecutableDirectiveLocation_SUBSCRIPTION = Core.Name "SUBSCRIPTION"+_ExecutableDirectiveLocation_FIELD = Core.Name "FIELD"+_ExecutableDirectiveLocation_FRAGMENT_DEFINITION = Core.Name "FRAGMENT_DEFINITION"+_ExecutableDirectiveLocation_FRAGMENT_SPREAD = Core.Name "FRAGMENT_SPREAD"+_ExecutableDirectiveLocation_INLINE_FRAGMENT = Core.Name "INLINE_FRAGMENT"+_ExecutableDirectiveLocation_VARIABLE_DEFINITION = Core.Name "VARIABLE_DEFINITION"+data TypeSystemDirectiveLocation =+  TypeSystemDirectiveLocationSCHEMA |+  TypeSystemDirectiveLocationSCALAR |+  TypeSystemDirectiveLocationOBJECT |+  TypeSystemDirectiveLocationFIELD_DEFINITION |+  TypeSystemDirectiveLocationARGUMENT_DEFINITION |+  TypeSystemDirectiveLocationINTERFACE |+  TypeSystemDirectiveLocationUNION |+  TypeSystemDirectiveLocationENUM |+  TypeSystemDirectiveLocationENUM_VALUE |+  TypeSystemDirectiveLocationINPUT_OBJECT |+  TypeSystemDirectiveLocationINPUT_FIELD_DEFINITION+  deriving (Eq, Ord, Read, Show)+_TypeSystemDirectiveLocation = Core.Name "hydra.graphql.syntax.TypeSystemDirectiveLocation"+_TypeSystemDirectiveLocation_SCHEMA = Core.Name "SCHEMA"+_TypeSystemDirectiveLocation_SCALAR = Core.Name "SCALAR"+_TypeSystemDirectiveLocation_OBJECT = Core.Name "OBJECT"+_TypeSystemDirectiveLocation_FIELD_DEFINITION = Core.Name "FIELD_DEFINITION"+_TypeSystemDirectiveLocation_ARGUMENT_DEFINITION = Core.Name "ARGUMENT_DEFINITION"+_TypeSystemDirectiveLocation_INTERFACE = Core.Name "INTERFACE"+_TypeSystemDirectiveLocation_UNION = Core.Name "UNION"+_TypeSystemDirectiveLocation_ENUM = Core.Name "ENUM"+_TypeSystemDirectiveLocation_ENUM_VALUE = Core.Name "ENUM_VALUE"+_TypeSystemDirectiveLocation_INPUT_OBJECT = Core.Name "INPUT_OBJECT"+_TypeSystemDirectiveLocation_INPUT_FIELD_DEFINITION = Core.Name "INPUT_FIELD_DEFINITION"
+ src/main/haskell/Hydra/Iana/Linkrelations.hs view
@@ -0,0 +1,374 @@+-- Note: this is an automatically generated file. Do not edit.+-- | All IANA Link Relation Types, as of 2022-10-11. See https://www.iana.org/assignments/link-relations/link-relations.xhtml++module Hydra.Iana.Linkrelations where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | An IANA link relation type+data LinkRelationType =+  -- | Refers to a resource that is the subject of the link's context. [RFC6903], section 2+  LinkRelationTypeAbout |+  -- | Asserts that the link target provides an access control resource for the link context. [https://solidproject.org/TR/wac#acl-link-relation]+  LinkRelationTypeAcl |+  -- | Refers to a substitute for this context [HTML]+  LinkRelationTypeAlternate |+  -- | Used to reference alternative content that uses the AMP profile of the HTML format. [AMP HTML]+  LinkRelationTypeAmphtml |+  -- | Refers to an appendix. [HTML 4.01 Specification]+  LinkRelationTypeAppendix |+  -- | Refers to an icon for the context. Synonym for icon. [Configuring Web Applications]+  LinkRelationTypeApple_touch_icon |+  -- | Refers to a launch screen for the context. [Configuring Web Applications]+  LinkRelationTypeApple_touch_startup_image |+  -- | Refers to a collection of records, documents, or other materials of historical interest. [HTML5]+  LinkRelationTypeArchives |+  -- | Refers to the context's author. [HTML]+  LinkRelationTypeAuthor |+  -- | Identifies the entity that blocks access to a resource following receipt of a legal demand. [RFC7725]+  LinkRelationTypeBlocked_by |+  -- | Gives a permanent link to use for bookmarking purposes. [HTML]+  LinkRelationTypeBookmark |+  -- | Designates the preferred version of a resource (the IRI and its contents). [RFC6596]+  LinkRelationTypeCanonical |+  -- | Refers to a chapter in a collection of resources. [HTML 4.01 Specification]+  LinkRelationTypeChapter |+  -- | Indicates that the link target is preferred over the link context for the purpose of permanent citation. [RFC8574]+  LinkRelationTypeCite_as |+  -- | The target IRI points to a resource which represents the collection resource for the context IRI. [RFC6573]+  LinkRelationTypeCollection |+  -- | Refers to a table of contents. [HTML 4.01 Specification]+  LinkRelationTypeContents |+  -- | The document linked to was later converted to the document that contains this link relation. For example, an RFC can have a link to the Internet-Draft that became the RFC; in that case, the link relation would be "convertedFrom". [RFC7991] This relation is different than "predecessor-version" in that "predecessor-version" is for items in a version control system. It is also different than "previous" in that this relation is used for converted resources, not those that are part of a sequence of resources.+  LinkRelationTypeConvertedfrom |+  -- | Refers to a copyright statement that applies to the link's context. [HTML 4.01 Specification]+  LinkRelationTypeCopyright |+  -- | The target IRI points to a resource where a submission form can be obtained. [RFC6861]+  LinkRelationTypeCreate_form |+  -- | Refers to a resource containing the most recent item(s) in a collection of resources. [RFC5005]+  LinkRelationTypeCurrent |+  -- | Refers to a resource providing information about the link's context. [Protocol for Web Description Resources (POWDER)]+  LinkRelationTypeDescribedby |+  -- | The relationship A 'describes' B asserts that resource A provides a description of resource B. There are no constraints on the format or representation of either A or B, neither are there any further constraints on either resource. [RFC6892] This link relation type is the inverse of the 'describedby' relation type. While 'describedby' establishes a relation from the described resource back to the resource that describes it, 'describes' established a relation from the describing resource to the resource it describes. If B is 'describedby' A, then A 'describes' B.+  LinkRelationTypeDescribes |+  -- | Refers to a list of patent disclosures made with respect to material for which 'disclosure' relation is specified. [RFC6579]+  LinkRelationTypeDisclosure |+  -- | Used to indicate an origin that will be used to fetch required resources for the link context, and that the user agent ought to resolve as early as possible. [Resource Hints]+  LinkRelationTypeDns_prefetch |+  -- | Refers to a resource whose available representations are byte-for-byte identical with the corresponding representations of the context IRI. [RFC6249] This relation is for static resources. That is, an HTTP GET request on any duplicate will return the same representation. It does not make sense for dynamic or POSTable resources and should not be used for them.+  LinkRelationTypeDuplicate |+  -- | Refers to a resource that can be used to edit the link's context. [RFC5023]+  LinkRelationTypeEdit |+  -- | The target IRI points to a resource where a submission form for editing associated resource can be obtained. [RFC6861]+  LinkRelationTypeEdit_form |+  -- | Refers to a resource that can be used to edit media associated with the link's context. [RFC5023]+  LinkRelationTypeEdit_media |+  -- | Identifies a related resource that is potentially large and might require special handling. [RFC4287]+  LinkRelationTypeEnclosure |+  -- | Refers to a resource that is not part of the same site as the current context. [HTML]+  LinkRelationTypeExternal |+  -- | An IRI that refers to the furthest preceding resource in a series of resources. [RFC8288] This relation type registration did not indicate a reference. Originally requested by Mark Nottingham in December 2004.+  LinkRelationTypeFirst |+  -- | Refers to a glossary of terms. [HTML 4.01 Specification]+  LinkRelationTypeGlossary |+  -- | Refers to context-sensitive help. [HTML]+  LinkRelationTypeHelp |+  -- | Refers to a resource hosted by the server indicated by the link context. [RFC6690] This relation is used in CoRE where links are retrieved as a "/.well-known/core" resource representation, and is the default relation type in the CoRE Link Format.+  LinkRelationTypeHosts |+  -- | Refers to a hub that enables registration for notification of updates to the context. [WebSub] This relation type was requested by Brett Slatkin.+  LinkRelationTypeHub |+  -- | Refers to an icon representing the link's context. [HTML]+  LinkRelationTypeIcon |+  -- | Refers to an index. [HTML 4.01 Specification]+  LinkRelationTypeIndex |+  -- | refers to a resource associated with a time interval that ends before the beginning of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.21+  LinkRelationTypeIntervalafter |+  -- | refers to a resource associated with a time interval that begins after the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.22+  LinkRelationTypeIntervalbefore |+  -- | refers to a resource associated with a time interval that begins after the beginning of the time interval associated with the context resource, and ends before the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.23+  LinkRelationTypeIntervalcontains |+  -- | refers to a resource associated with a time interval that begins after the end of the time interval associated with the context resource, or ends before the beginning of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.24+  LinkRelationTypeIntervaldisjoint |+  -- | refers to a resource associated with a time interval that begins before the beginning of the time interval associated with the context resource, and ends after the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.25+  LinkRelationTypeIntervalduring |+  -- | refers to a resource associated with a time interval whose beginning coincides with the beginning of the time interval associated with the context resource, and whose end coincides with the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.26+  LinkRelationTypeIntervalequals |+  -- | refers to a resource associated with a time interval that begins after the beginning of the time interval associated with the context resource, and whose end coincides with the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.27+  LinkRelationTypeIntervalfinishedby |+  -- | refers to a resource associated with a time interval that begins before the beginning of the time interval associated with the context resource, and whose end coincides with the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.28+  LinkRelationTypeIntervalfinishes |+  -- | refers to a resource associated with a time interval that begins before or is coincident with the beginning of the time interval associated with the context resource, and ends after or is coincident with the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.29+  LinkRelationTypeIntervalin |+  -- | refers to a resource associated with a time interval whose beginning coincides with the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.30+  LinkRelationTypeIntervalmeets |+  -- | refers to a resource associated with a time interval whose end coincides with the beginning of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.31+  LinkRelationTypeIntervalmetby |+  -- | refers to a resource associated with a time interval that begins before the beginning of the time interval associated with the context resource, and ends after the beginning of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.32+  LinkRelationTypeIntervaloverlappedby |+  -- | refers to a resource associated with a time interval that begins before the end of the time interval associated with the context resource, and ends after the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.33+  LinkRelationTypeIntervaloverlaps |+  -- | refers to a resource associated with a time interval whose beginning coincides with the beginning of the time interval associated with the context resource, and ends before the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.34+  LinkRelationTypeIntervalstartedby |+  -- | refers to a resource associated with a time interval whose beginning coincides with the beginning of the time interval associated with the context resource, and ends after the end of the time interval associated with the context resource [Time Ontology in OWL] section 4.2.35+  LinkRelationTypeIntervalstarts |+  -- | The target IRI points to a resource that is a member of the collection represented by the context IRI. [RFC6573]+  LinkRelationTypeItem |+  -- | An IRI that refers to the furthest following resource in a series of resources. [RFC8288] This relation type registration did not indicate a reference. Originally requested by Mark Nottingham in December 2004.+  LinkRelationTypeLast |+  -- | Points to a resource containing the latest (e.g., current) version of the context. [RFC5829]+  LinkRelationTypeLatest_version |+  -- | Refers to a license associated with this context. [RFC4946] For implications of use in HTML, see: http://www.w3.org/TR/html5/links.html#link-type-license+  LinkRelationTypeLicense |+  -- | The link target of a link with the "linkset" relation type provides a set of links, including links in which the link context of the link participates. [RFC9264]+  LinkRelationTypeLinkset |+  -- | Refers to further information about the link's context, expressed as a LRDD ("Link-based Resource Descriptor Document") resource. See [RFC6415] for information about processing this relation type in host-meta documents. When used elsewhere, it refers to additional links and other metadata. Multiple instances indicate additional LRDD resources. LRDD resources MUST have an "application/xrd+xml" representation, and MAY have others. [RFC6415]+  LinkRelationTypeLrdd |+  -- | Links to a manifest file for the context. [Web App Manifest]+  LinkRelationTypeManifest |+  -- | Refers to a mask that can be applied to the icon for the context. [Creating Pinned Tab Icons]+  LinkRelationTypeMask_icon |+  -- | Refers to a feed of personalised media recommendations relevant to the link context. [https://wicg.github.io/media-feeds/#discovery-of-media-feeds]+  LinkRelationTypeMedia_feed |+  -- | The Target IRI points to a Memento, a fixed resource that will not change state anymore. [RFC7089] A Memento for an Original Resource is a resource that encapsulates a prior state of the Original Resource.+  LinkRelationTypeMemento |+  -- | Links to the context's Micropub endpoint. [Micropub]+  LinkRelationTypeMicropub |+  -- | Refers to a module that the user agent is to preemptively fetch and store for use in the current context. [HTML]+  LinkRelationTypeModulepreload |+  -- | Refers to a resource that can be used to monitor changes in an HTTP resource. [RFC5989]+  LinkRelationTypeMonitor |+  -- | Refers to a resource that can be used to monitor changes in a specified group of HTTP resources. [RFC5989]+  LinkRelationTypeMonitor_group |+  -- | Indicates that the link's context is a part of a series, and that the next in the series is the link target. [HTML]+  LinkRelationTypeNext |+  -- | Refers to the immediately following archive resource. [RFC5005]+  LinkRelationTypeNext_archive |+  -- | Indicates that the context's original author or publisher does not endorse the link target. [HTML]+  LinkRelationTypeNofollow |+  -- | Indicates that any newly created top-level browsing context which results from following the link will not be an auxiliary browsing context. [HTML]+  LinkRelationTypeNoopener |+  -- | Indicates that no referrer information is to be leaked when following the link. [HTML]+  LinkRelationTypeNoreferrer |+  -- | Indicates that any newly created top-level browsing context which results from following the link will be an auxiliary browsing context. [HTML]+  LinkRelationTypeOpener |+  -- | Refers to an OpenID Authentication server on which the context relies for an assertion that the end user controls an Identifier. [OpenID Authentication 2.0 - Final]+  LinkRelationTypeOpenid2_local_id |+  -- | Refers to a resource which accepts OpenID Authentication protocol messages for the context. [OpenID Authentication 2.0 - Final]+  LinkRelationTypeOpenid2_provider |+  -- | The Target IRI points to an Original Resource. [RFC7089] An Original Resource is a resource that exists or used to exist, and for which access to one of its prior states may be required.+  LinkRelationTypeOriginal |+  -- | Refers to a P3P privacy policy for the context. [The Platform for Privacy Preferences 1.0 (P3P1.0) Specification]+  LinkRelationTypeP3pv1 |+  -- | Indicates a resource where payment is accepted. [RFC8288] This relation type registration did not indicate a reference. Requested by Joshua Kinberg and Robert Sayre. It is meant as a general way to facilitate acts of payment, and thus this specification makes no assumptions on the type of payment or transaction protocol. Examples may include a web page where donations are accepted or where goods and services are available for purchase. rel="payment" is not intended to initiate an automated transaction. In Atom documents, a link element with a rel="payment" attribute may exist at the feed/channel level and/or the entry/item level. For example, a rel="payment" link at the feed/channel level may point to a "tip jar" URI, whereas an entry/ item containing a book review may include a rel="payment" link that points to the location where the book may be purchased through an online retailer.+  LinkRelationTypePayment |+  -- | Gives the address of the pingback resource for the link context. [Pingback 1.0]+  LinkRelationTypePingback |+  -- | Used to indicate an origin that will be used to fetch required resources for the link context. Initiating an early connection, which includes the DNS lookup, TCP handshake, and optional TLS negotiation, allows the user agent to mask the high latency costs of establishing a connection. [Resource Hints]+  LinkRelationTypePreconnect |+  -- | Points to a resource containing the predecessor version in the version history. [RFC5829]+  LinkRelationTypePredecessor_version |+  -- | The prefetch link relation type is used to identify a resource that might be required by the next navigation from the link context, and that the user agent ought to fetch, such that the user agent can deliver a faster response once the resource is requested in the future. [Resource Hints]+  LinkRelationTypePrefetch |+  -- | Refers to a resource that should be loaded early in the processing of the link's context, without blocking rendering. [Preload] Additional target attributes establish the detailed fetch properties of the link.+  LinkRelationTypePreload |+  -- | Used to identify a resource that might be required by the next navigation from the link context, and that the user agent ought to fetch and execute, such that the user agent can deliver a faster response once the resource is requested in the future. [Resource Hints]+  LinkRelationTypePrerender |+  -- | Indicates that the link's context is a part of a series, and that the previous in the series is the link target. [HTML]+  LinkRelationTypePrev |+  -- | Refers to a resource that provides a preview of the link's context. [RFC6903], section 3+  LinkRelationTypePreview |+  -- | Refers to the previous resource in an ordered series of resources. Synonym for "prev". [HTML 4.01 Specification]+  LinkRelationTypePrevious |+  -- | Refers to the immediately preceding archive resource. [RFC5005]+  LinkRelationTypePrev_archive |+  -- | Refers to a privacy policy associated with the link's context. [RFC6903], section 4+  LinkRelationTypePrivacy_policy |+  -- | Identifying that a resource representation conforms to a certain profile, without affecting the non-profile semantics of the resource representation. [RFC6906] Profile URIs are primarily intended to be used as identifiers, and thus clients SHOULD NOT indiscriminately access profile URIs.+  LinkRelationTypeProfile |+  -- | Links to a publication manifest. A manifest represents structured information about a publication, such as informative metadata, a list of resources, and a default reading order. [Publication Manifest]+  LinkRelationTypePublication |+  -- | Identifies a related resource. [RFC4287]+  LinkRelationTypeRelated |+  -- | Identifies the root of RESTCONF API as configured on this HTTP server. The "restconf" relation defines the root of the API defined in RFC8040. Subsequent revisions of RESTCONF will use alternate relation values to support protocol versioning. [RFC8040]+  LinkRelationTypeRestconf |+  -- | Identifies a resource that is a reply to the context of the link. [RFC4685]+  LinkRelationTypeReplies |+  -- | The resource identified by the link target provides an input value to an instance of a rule, where the resource which represents the rule instance is identified by the link context. [OCF Core Optional 2.2.0]+  LinkRelationTypeRuleinput |+  -- | Refers to a resource that can be used to search through the link's context and related resources. [OpenSearch]+  LinkRelationTypeSearch |+  -- | Refers to a section in a collection of resources. [HTML 4.01 Specification]+  LinkRelationTypeSection |+  -- | Conveys an identifier for the link's context. [RFC4287]+  LinkRelationTypeSelf |+  -- | Indicates a URI that can be used to retrieve a service document. [RFC5023] When used in an Atom document, this relation type specifies Atom Publishing Protocol service documents by default. Requested by James Snell.+  LinkRelationTypeService |+  -- | Identifies service description for the context that is primarily intended for consumption by machines. [RFC8631]+  LinkRelationTypeService_desc |+  -- | Identifies service documentation for the context that is primarily intended for human consumption. [RFC8631]+  LinkRelationTypeService_doc |+  -- | Identifies general metadata for the context that is primarily intended for consumption by machines. [RFC8631]+  LinkRelationTypeService_meta |+  -- | refers to a capability document that defines parameters or configuration requirements for automated peering and communication channel negotiation of the Session Initiation Protocol (SIP). [draft-engi-siptrunkingcapability-link]+  LinkRelationTypeSiptrunkingcapability |+  -- | Refers to a resource that is within a context that is sponsored (such as advertising or another compensation agreement). [Google Blog post 09-2019]+  LinkRelationTypeSponsored |+  -- | Refers to the first resource in a collection of resources. [HTML 4.01 Specification]+  LinkRelationTypeStart |+  -- | Identifies a resource that represents the context's status. [RFC8631]+  LinkRelationTypeStatus |+  -- | Refers to a stylesheet. [HTML]+  LinkRelationTypeStylesheet |+  -- | Refers to a resource serving as a subsection in a collection of resources. [HTML 4.01 Specification]+  LinkRelationTypeSubsection |+  -- | Points to a resource containing the successor version in the version history. [RFC5829]+  LinkRelationTypeSuccessor_version |+  -- | Identifies a resource that provides information about the context's retirement policy. [RFC8594]+  LinkRelationTypeSunset |+  -- | Gives a tag (identified by the given address) that applies to the current document. [HTML]+  LinkRelationTypeTag |+  -- | Refers to the terms of service associated with the link's context. [RFC6903], section 5+  LinkRelationTypeTerms_of_service |+  -- | The Target IRI points to a TimeGate for an Original Resource. [RFC7089] A TimeGate for an Original Resource is a resource that is capable of datetime negotiation to support access to prior states of the Original Resource.+  LinkRelationTypeTimegate |+  -- | The Target IRI points to a TimeMap for an Original Resource. [RFC7089] A TimeMap for an Original Resource is a resource from which a list of URIs of Mementos of the Original Resource is available.+  LinkRelationTypeTimemap |+  -- | Refers to a resource identifying the abstract semantic type of which the link's context is considered to be an instance. [RFC6903], section 6+  LinkRelationTypeType |+  -- | Refers to a resource that is within a context that is User Generated Content. [Google Blog post 09-2019]+  LinkRelationTypeUgc |+  -- | Refers to a parent document in a hierarchy of documents. [RFC8288] This relation type registration did not indicate a reference. Requested by Noah Slater.+  LinkRelationTypeUp |+  -- | Points to a resource containing the version history for the context. [RFC5829]+  LinkRelationTypeVersion_history |+  -- | Identifies a resource that is the source of the information in the link's context. [RFC4287]+  LinkRelationTypeVia |+  -- | Identifies a target URI that supports the Webmention protocol. This allows clients that mention a resource in some form of publishing process to contact that endpoint and inform it that this resource has been mentioned. [Webmention] This is a similar "Linkback" mechanism to the ones of Refback, Trackback, and Pingback. It uses a different protocol, though, and thus should be discoverable through its own link relation type.+  LinkRelationTypeWebmention |+  -- | Points to a working copy for this resource. [RFC5829]+  LinkRelationTypeWorking_copy |+  -- | Points to the versioned resource from which this working copy was obtained. [RFC5829]+  LinkRelationTypeWorking_copy_of+  deriving (Eq, Ord, Read, Show)+_LinkRelationType = Core.Name "hydra.iana.linkrelations.LinkRelationType"+_LinkRelationType_about = Core.Name "about"+_LinkRelationType_acl = Core.Name "acl"+_LinkRelationType_alternate = Core.Name "alternate"+_LinkRelationType_amphtml = Core.Name "amphtml"+_LinkRelationType_appendix = Core.Name "appendix"+_LinkRelationType_apple_touch_icon = Core.Name "apple-touch-icon"+_LinkRelationType_apple_touch_startup_image = Core.Name "apple-touch-startup-image"+_LinkRelationType_archives = Core.Name "archives"+_LinkRelationType_author = Core.Name "author"+_LinkRelationType_blocked_by = Core.Name "blocked-by"+_LinkRelationType_bookmark = Core.Name "bookmark"+_LinkRelationType_canonical = Core.Name "canonical"+_LinkRelationType_chapter = Core.Name "chapter"+_LinkRelationType_cite_as = Core.Name "cite-as"+_LinkRelationType_collection = Core.Name "collection"+_LinkRelationType_contents = Core.Name "contents"+_LinkRelationType_convertedfrom = Core.Name "convertedfrom"+_LinkRelationType_copyright = Core.Name "copyright"+_LinkRelationType_create_form = Core.Name "create-form"+_LinkRelationType_current = Core.Name "current"+_LinkRelationType_describedby = Core.Name "describedby"+_LinkRelationType_describes = Core.Name "describes"+_LinkRelationType_disclosure = Core.Name "disclosure"+_LinkRelationType_dns_prefetch = Core.Name "dns-prefetch"+_LinkRelationType_duplicate = Core.Name "duplicate"+_LinkRelationType_edit = Core.Name "edit"+_LinkRelationType_edit_form = Core.Name "edit-form"+_LinkRelationType_edit_media = Core.Name "edit-media"+_LinkRelationType_enclosure = Core.Name "enclosure"+_LinkRelationType_external = Core.Name "external"+_LinkRelationType_first = Core.Name "first"+_LinkRelationType_glossary = Core.Name "glossary"+_LinkRelationType_help = Core.Name "help"+_LinkRelationType_hosts = Core.Name "hosts"+_LinkRelationType_hub = Core.Name "hub"+_LinkRelationType_icon = Core.Name "icon"+_LinkRelationType_index = Core.Name "index"+_LinkRelationType_intervalafter = Core.Name "intervalafter"+_LinkRelationType_intervalbefore = Core.Name "intervalbefore"+_LinkRelationType_intervalcontains = Core.Name "intervalcontains"+_LinkRelationType_intervaldisjoint = Core.Name "intervaldisjoint"+_LinkRelationType_intervalduring = Core.Name "intervalduring"+_LinkRelationType_intervalequals = Core.Name "intervalequals"+_LinkRelationType_intervalfinishedby = Core.Name "intervalfinishedby"+_LinkRelationType_intervalfinishes = Core.Name "intervalfinishes"+_LinkRelationType_intervalin = Core.Name "intervalin"+_LinkRelationType_intervalmeets = Core.Name "intervalmeets"+_LinkRelationType_intervalmetby = Core.Name "intervalmetby"+_LinkRelationType_intervaloverlappedby = Core.Name "intervaloverlappedby"+_LinkRelationType_intervaloverlaps = Core.Name "intervaloverlaps"+_LinkRelationType_intervalstartedby = Core.Name "intervalstartedby"+_LinkRelationType_intervalstarts = Core.Name "intervalstarts"+_LinkRelationType_item = Core.Name "item"+_LinkRelationType_last = Core.Name "last"+_LinkRelationType_latest_version = Core.Name "latest-version"+_LinkRelationType_license = Core.Name "license"+_LinkRelationType_linkset = Core.Name "linkset"+_LinkRelationType_lrdd = Core.Name "lrdd"+_LinkRelationType_manifest = Core.Name "manifest"+_LinkRelationType_mask_icon = Core.Name "mask-icon"+_LinkRelationType_media_feed = Core.Name "media-feed"+_LinkRelationType_memento = Core.Name "memento"+_LinkRelationType_micropub = Core.Name "micropub"+_LinkRelationType_modulepreload = Core.Name "modulepreload"+_LinkRelationType_monitor = Core.Name "monitor"+_LinkRelationType_monitor_group = Core.Name "monitor-group"+_LinkRelationType_next = Core.Name "next"+_LinkRelationType_next_archive = Core.Name "next-archive"+_LinkRelationType_nofollow = Core.Name "nofollow"+_LinkRelationType_noopener = Core.Name "noopener"+_LinkRelationType_noreferrer = Core.Name "noreferrer"+_LinkRelationType_opener = Core.Name "opener"+_LinkRelationType_openid2_local_id = Core.Name "openid2.local_id"+_LinkRelationType_openid2_provider = Core.Name "openid2.provider"+_LinkRelationType_original = Core.Name "original"+_LinkRelationType_p3pv1 = Core.Name "p3pv1"+_LinkRelationType_payment = Core.Name "payment"+_LinkRelationType_pingback = Core.Name "pingback"+_LinkRelationType_preconnect = Core.Name "preconnect"+_LinkRelationType_predecessor_version = Core.Name "predecessor-version"+_LinkRelationType_prefetch = Core.Name "prefetch"+_LinkRelationType_preload = Core.Name "preload"+_LinkRelationType_prerender = Core.Name "prerender"+_LinkRelationType_prev = Core.Name "prev"+_LinkRelationType_preview = Core.Name "preview"+_LinkRelationType_previous = Core.Name "previous"+_LinkRelationType_prev_archive = Core.Name "prev-archive"+_LinkRelationType_privacy_policy = Core.Name "privacy-policy"+_LinkRelationType_profile = Core.Name "profile"+_LinkRelationType_publication = Core.Name "publication"+_LinkRelationType_related = Core.Name "related"+_LinkRelationType_restconf = Core.Name "restconf"+_LinkRelationType_replies = Core.Name "replies"+_LinkRelationType_ruleinput = Core.Name "ruleinput"+_LinkRelationType_search = Core.Name "search"+_LinkRelationType_section = Core.Name "section"+_LinkRelationType_self = Core.Name "self"+_LinkRelationType_service = Core.Name "service"+_LinkRelationType_service_desc = Core.Name "service-desc"+_LinkRelationType_service_doc = Core.Name "service-doc"+_LinkRelationType_service_meta = Core.Name "service-meta"+_LinkRelationType_siptrunkingcapability = Core.Name "siptrunkingcapability"+_LinkRelationType_sponsored = Core.Name "sponsored"+_LinkRelationType_start = Core.Name "start"+_LinkRelationType_status = Core.Name "status"+_LinkRelationType_stylesheet = Core.Name "stylesheet"+_LinkRelationType_subsection = Core.Name "subsection"+_LinkRelationType_successor_version = Core.Name "successor-version"+_LinkRelationType_sunset = Core.Name "sunset"+_LinkRelationType_tag = Core.Name "tag"+_LinkRelationType_terms_of_service = Core.Name "terms-of-service"+_LinkRelationType_timegate = Core.Name "timegate"+_LinkRelationType_timemap = Core.Name "timemap"+_LinkRelationType_type = Core.Name "type"+_LinkRelationType_ugc = Core.Name "ugc"+_LinkRelationType_up = Core.Name "up"+_LinkRelationType_version_history = Core.Name "version-history"+_LinkRelationType_via = Core.Name "via"+_LinkRelationType_webmention = Core.Name "webmention"+_LinkRelationType_working_copy = Core.Name "working-copy"+_LinkRelationType_working_copy_of = Core.Name "working-copy-of"
+ src/main/haskell/Hydra/Json/Schema.hs view
@@ -0,0 +1,174 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for JSON Schema. Based on https://cswr.github.io/JsonSchema/spec/grammar++module Hydra.Json.Schema where+import qualified Hydra.Core as Core+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+data Document =+  Document {+    documentId :: (Maybe String),+    documentDefinitions :: (Maybe (M.Map Keyword Schema)),+    documentRoot :: Schema}+  deriving (Eq, Ord, Read, Show)+_Document = Core.Name "hydra.json.schema.Document"+_Document_id = Core.Name "id"+_Document_definitions = Core.Name "definitions"+_Document_root = Core.Name "root"+newtype Keyword =+  Keyword {+    unKeyword :: String}+  deriving (Eq, Ord, Read, Show)+_Keyword = Core.Name "hydra.json.schema.Keyword"+newtype Schema =+  Schema {+    unSchema :: [Restriction]}+  deriving (Eq, Ord, Read, Show)+_Schema = Core.Name "hydra.json.schema.Schema"+data Restriction =+  RestrictionType Type |+  RestrictionString StringRestriction |+  RestrictionNumber NumericRestriction |+  RestrictionArray ArrayRestriction |+  RestrictionObject ObjectRestriction |+  RestrictionMultiple MultipleRestriction |+  RestrictionReference SchemaReference |+  RestrictionTitle String |+  RestrictionDescription String+  deriving (Eq, Ord, Read, Show)+_Restriction = Core.Name "hydra.json.schema.Restriction"+_Restriction_type = Core.Name "type"+_Restriction_string = Core.Name "string"+_Restriction_number = Core.Name "number"+_Restriction_array = Core.Name "array"+_Restriction_object = Core.Name "object"+_Restriction_multiple = Core.Name "multiple"+_Restriction_reference = Core.Name "reference"+_Restriction_title = Core.Name "title"+_Restriction_description = Core.Name "description"+data Type =+  TypeSingle TypeName |+  TypeMultiple [TypeName]+  deriving (Eq, Ord, Read, Show)+_Type = Core.Name "hydra.json.schema.Type"+_Type_single = Core.Name "single"+_Type_multiple = Core.Name "multiple"+data TypeName =+  TypeNameString |+  TypeNameInteger |+  TypeNameNumber |+  TypeNameBoolean |+  TypeNameNull |+  TypeNameArray |+  TypeNameObject+  deriving (Eq, Ord, Read, Show)+_TypeName = Core.Name "hydra.json.schema.TypeName"+_TypeName_string = Core.Name "string"+_TypeName_integer = Core.Name "integer"+_TypeName_number = Core.Name "number"+_TypeName_boolean = Core.Name "boolean"+_TypeName_null = Core.Name "null"+_TypeName_array = Core.Name "array"+_TypeName_object = Core.Name "object"+data StringRestriction =+  StringRestrictionMinLength Int |+  StringRestrictionMaxLength Int |+  StringRestrictionPattern RegularExpression+  deriving (Eq, Ord, Read, Show)+_StringRestriction = Core.Name "hydra.json.schema.StringRestriction"+_StringRestriction_minLength = Core.Name "minLength"+_StringRestriction_maxLength = Core.Name "maxLength"+_StringRestriction_pattern = Core.Name "pattern"+newtype RegularExpression =+  RegularExpression {+    unRegularExpression :: String}+  deriving (Eq, Ord, Read, Show)+_RegularExpression = Core.Name "hydra.json.schema.RegularExpression"+data NumericRestriction =+  NumericRestrictionMinimum Limit |+  NumericRestrictionMaximum Limit |+  NumericRestrictionMultipleOf Int+  deriving (Eq, Ord, Read, Show)+_NumericRestriction = Core.Name "hydra.json.schema.NumericRestriction"+_NumericRestriction_minimum = Core.Name "minimum"+_NumericRestriction_maximum = Core.Name "maximum"+_NumericRestriction_multipleOf = Core.Name "multipleOf"+data Limit =+  Limit {+    limitValue :: Int,+    limitExclusive :: Bool}+  deriving (Eq, Ord, Read, Show)+_Limit = Core.Name "hydra.json.schema.Limit"+_Limit_value = Core.Name "value"+_Limit_exclusive = Core.Name "exclusive"+data ArrayRestriction =+  ArrayRestrictionItems Items |+  ArrayRestrictionAdditionalItems AdditionalItems |+  ArrayRestrictionMinItems Int |+  ArrayRestrictionMaxItems Int |+  ArrayRestrictionUniqueItems Bool+  deriving (Eq, Ord, Read, Show)+_ArrayRestriction = Core.Name "hydra.json.schema.ArrayRestriction"+_ArrayRestriction_items = Core.Name "items"+_ArrayRestriction_additionalItems = Core.Name "additionalItems"+_ArrayRestriction_minItems = Core.Name "minItems"+_ArrayRestriction_maxItems = Core.Name "maxItems"+_ArrayRestriction_uniqueItems = Core.Name "uniqueItems"+data Items =+  ItemsSameItems Schema |+  ItemsVarItems [Schema]+  deriving (Eq, Ord, Read, Show)+_Items = Core.Name "hydra.json.schema.Items"+_Items_sameItems = Core.Name "sameItems"+_Items_varItems = Core.Name "varItems"+data AdditionalItems =+  AdditionalItemsAny Bool |+  AdditionalItemsSchema Schema+  deriving (Eq, Ord, Read, Show)+_AdditionalItems = Core.Name "hydra.json.schema.AdditionalItems"+_AdditionalItems_any = Core.Name "any"+_AdditionalItems_schema = Core.Name "schema"+data ObjectRestriction =+  ObjectRestrictionProperties (M.Map Keyword Schema) |+  ObjectRestrictionAdditionalProperties AdditionalItems |+  ObjectRestrictionRequired [Keyword] |+  ObjectRestrictionMinProperties Int |+  ObjectRestrictionMaxProperties Int |+  ObjectRestrictionDependencies (M.Map Keyword SchemaOrArray) |+  ObjectRestrictionPatternProperties (M.Map RegularExpression Schema)+  deriving (Eq, Ord, Read, Show)+_ObjectRestriction = Core.Name "hydra.json.schema.ObjectRestriction"+_ObjectRestriction_properties = Core.Name "properties"+_ObjectRestriction_additionalProperties = Core.Name "additionalProperties"+_ObjectRestriction_required = Core.Name "required"+_ObjectRestriction_minProperties = Core.Name "minProperties"+_ObjectRestriction_maxProperties = Core.Name "maxProperties"+_ObjectRestriction_dependencies = Core.Name "dependencies"+_ObjectRestriction_patternProperties = Core.Name "patternProperties"+data SchemaOrArray =+  SchemaOrArraySchema Schema |+  SchemaOrArrayArray [Keyword]+  deriving (Eq, Ord, Read, Show)+_SchemaOrArray = Core.Name "hydra.json.schema.SchemaOrArray"+_SchemaOrArray_schema = Core.Name "schema"+_SchemaOrArray_array = Core.Name "array"+data MultipleRestriction =+  MultipleRestrictionAllOf [Schema] |+  MultipleRestrictionAnyOf [Schema] |+  MultipleRestrictionOneOf [Schema] |+  MultipleRestrictionNot Schema |+  MultipleRestrictionEnum [Model.Value]+  deriving (Eq, Ord, Read, Show)+_MultipleRestriction = Core.Name "hydra.json.schema.MultipleRestriction"+_MultipleRestriction_allOf = Core.Name "allOf"+_MultipleRestriction_anyOf = Core.Name "anyOf"+_MultipleRestriction_oneOf = Core.Name "oneOf"+_MultipleRestriction_not = Core.Name "not"+_MultipleRestriction_enum = Core.Name "enum"+newtype SchemaReference =+  SchemaReference {+    unSchemaReference :: String}+  deriving (Eq, Ord, Read, Show)+_SchemaReference = Core.Name "hydra.json.schema.SchemaReference"
+ src/main/haskell/Hydra/Json/Schema/Coder.hs view
@@ -0,0 +1,257 @@+-- Note: this is an automatically generated file. Do not edit.+-- | JSON Schema code generator: converts Hydra modules to JSON Schema documents++module Hydra.Json.Schema.Coder where+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Constants as Constants+import qualified Hydra.Core as Core+import qualified Hydra.File as File+import qualified Hydra.Dependencies as Dependencies+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Json.Schema as Schema+import qualified Hydra.Json.Schema.Serde as Serde+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Predicates as Predicates+import qualified Hydra.Query as Query+import qualified Hydra.Reflect as Reflect+import qualified Hydra.Relational as Relational+import qualified Hydra.Show.Variants as ShowVariants+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variables as Variables+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+import qualified Data.Set as S+-- | Construct JSON Schema documents from type definitions+constructModule :: t0 -> Graph.Graph -> t1 -> [Packaging.TypeDefinition] -> Either Errors.Error (M.Map String Schema.Document)+constructModule cx g mod typeDefs =++      let typeBody = \td -> Core.typeSchemeBody (Packaging.typeDefinitionBody td)+          typeMap = Maps.fromList (Lists.map (\td -> (Packaging.typeDefinitionName td, (typeBody td))) typeDefs)+      in (Eithers.map (\ps -> Maps.fromList ps) (Eithers.mapList (\td -> typeDefToDocument cx g typeMap (Packaging.typeDefinitionName td) (typeBody td)) typeDefs))+-- | Build a single-property record Schema for one branch of an Either oneOf+eitherBranch :: String -> [Schema.Restriction] -> Schema.Schema+eitherBranch label res =+    Schema.Schema [+      Schema.RestrictionType (Schema.TypeSingle Schema.TypeNameObject),+      (Schema.RestrictionObject (Schema.ObjectRestrictionProperties (Maps.singleton (Schema.Keyword label) (Schema.Schema res)))),+      (Schema.RestrictionObject (Schema.ObjectRestrictionRequired [+        Schema.Keyword label])),+      (Schema.RestrictionObject (Schema.ObjectRestrictionAdditionalProperties (Schema.AdditionalItemsAny False)))]+-- | Encode a field type as a JSON Schema keyword-schema pair+encodeField :: t0 -> Graph.Graph -> Core.FieldType -> Either Errors.Error (Schema.Keyword, Schema.Schema)+encodeField cx g ft =++      let name = Core.fieldTypeName ft+          typ = Core.fieldTypeType ft+      in (Eithers.map (\res -> (Schema.Keyword (Core.unName name), (Schema.Schema res))) (typeToExpr cx g False typ))+-- | Encode a Hydra name as a safe identifier string, replacing non-alphanumeric characters with underscores+encodeName :: Core.Name -> String+encodeName name = Formatting.nonAlnumToUnderscores (Core.unName name)+-- | Encode a named type as a list of JSON Schema restrictions with a title+encodeNamedType :: t0 -> Graph.Graph -> Core.Name -> Core.Type -> Either Errors.Error [Schema.Restriction]+encodeNamedType cx g name typ =+    Eithers.map (\res -> Lists.concat [+      [+        Schema.RestrictionTitle (Core.unName name)],+      res]) (typeToExpr cx g False (Strip.deannotateType typ))+-- | Encode a record or union as a list of JSON Schema object restrictions; isUnion adds min/maxProperties=1+encodeRecordOrUnion :: t0 -> Graph.Graph -> Bool -> Bool -> [Core.FieldType] -> Either Errors.Error [Schema.Restriction]+encodeRecordOrUnion cx g optional isUnion fields =+    Eithers.bind (Eithers.mapList (\ft -> encodeField cx g ft) fields) (\props ->+      let objRes = [+            Schema.RestrictionObject (Schema.ObjectRestrictionProperties (Maps.fromList props))]+          reqs =+                  Lists.foldl (\acc -> \f -> Logic.ifElse (isRequiredField f) (Lists.concat2 acc [+                    Schema.Keyword (Core.unName (Core.fieldTypeName f))]) acc) [] fields+          reqRes = Logic.ifElse (Lists.null reqs) [] [+                Schema.RestrictionObject (Schema.ObjectRestrictionRequired reqs)]+          addPropsRes = [+                Schema.RestrictionObject (Schema.ObjectRestrictionAdditionalProperties (Schema.AdditionalItemsAny False))]+          cardRes =+                  Logic.ifElse isUnion [+                    Schema.RestrictionObject (Schema.ObjectRestrictionMinProperties 1),+                    (Schema.RestrictionObject (Schema.ObjectRestrictionMaxProperties 1))] []+      in (Right (Lists.concat [+        jsType optional Schema.TypeNameObject,+        objRes,+        reqRes,+        addPropsRes,+        cardRes])))+-- | Encode a union type, splitting unit-typed (simple) variants into a string-enum branch+encodeUnion :: t0 -> Graph.Graph -> Bool -> [Core.FieldType] -> Either Errors.Error [Schema.Restriction]+encodeUnion cx g optional fields =++      let isSimple = \f -> Predicates.isUnitType (Strip.deannotateType (Core.fieldTypeType f))+          simple = Lists.filter isSimple fields+          nonsimple = Lists.filter (\f -> Logic.not (isSimple f)) fields+      in (Logic.ifElse (Lists.null simple) (encodeRecordOrUnion cx g optional True fields) (Eithers.bind (encodeRecordOrUnion cx g False True nonsimple) (\recRes ->+        let names = Lists.map (\f -> Core.unName (Core.fieldTypeName f)) simple+            simpleSchema =+                    Schema.Schema [+                      Schema.RestrictionType (Schema.TypeSingle Schema.TypeNameString),+                      (Schema.RestrictionMultiple (Schema.MultipleRestrictionEnum (Lists.map (\n -> Model.ValueString n) names)))]+        in (Right [+          Schema.RestrictionMultiple (Schema.MultipleRestrictionOneOf [+            Schema.Schema recRes,+            simpleSchema])]))))+-- | Determine whether a field is required (i.e., not optional/Maybe)+isRequiredField :: Core.FieldType -> Bool+isRequiredField ft =++      let typ = Core.fieldTypeType ft+      in case (Strip.deannotateType typ) of+        Core.TypeOptional _ -> False+        _ -> True+-- | Build the JSON Schema type-restriction list for a type name, optionally widening to allow null+jsType :: Bool -> Schema.TypeName -> [Schema.Restriction]+jsType optional tname =+    [+      Schema.RestrictionType (Logic.ifElse optional (Schema.TypeMultiple [+        tname,+        Schema.TypeNameNull]) (Schema.TypeSingle tname))]+-- | Map a Hydra literal type to a JSON Schema type name+literalTypeName :: Core.LiteralType -> Schema.TypeName+literalTypeName lt =+    case lt of+      Core.LiteralTypeBinary -> Schema.TypeNameString+      Core.LiteralTypeBoolean -> Schema.TypeNameBoolean+      Core.LiteralTypeFloat _ -> Schema.TypeNameNumber+      Core.LiteralTypeInteger _ -> Schema.TypeNameInteger+      Core.LiteralTypeString -> Schema.TypeNameString+      _ -> Schema.TypeNameString+-- | Convert a Hydra module to a map from file path to JSON Schema document string+moduleToJsonSchema :: t0 -> [Packaging.Definition] -> t1 -> Graph.Graph -> Either Errors.Error (M.Map String String)+moduleToJsonSchema mod defs cx g =++      let partitioned = Environment.partitionDefinitions defs+          typeDefs = Pairs.first partitioned+      in (Eithers.map (\docs -> Maps.map (\doc -> Serde.jsonSchemaDocumentToString doc) docs) (constructModule cx g mod typeDefs))+-- | Compute the JSON Schema output file path for a named type+nameToPath :: Core.Name -> String+nameToPath name =++      let qn = Names.qualifyName name+          mns = Util.qualifiedNameModuleName qn+          local = Util.qualifiedNameLocal qn+          nsPart = Optionals.cases mns "" (\ns -> Strings.cat2 (Packaging.unModuleName ns) ".")+      in (Names.moduleNameToFilePath Util.CaseConventionCamel (File.FileExtension "json") (Packaging.ModuleName (Strings.cat2 nsPart local)))+-- | Build the JSON Schema restriction list for a pair type+pairRestrictions :: Bool -> [Schema.Restriction] -> [Schema.Restriction] -> [Schema.Restriction]+pairRestrictions optional firstRes secondRes =+    Lists.concat [+      jsType optional Schema.TypeNameObject,+      [+        Schema.RestrictionObject (Schema.ObjectRestrictionProperties (Maps.fromList [+          (Schema.Keyword "first", (Schema.Schema firstRes)),+          (Schema.Keyword "second", (Schema.Schema secondRes))]))],+      [+        Schema.RestrictionObject (Schema.ObjectRestrictionRequired [+          Schema.Keyword "first",+          (Schema.Keyword "second")])],+      [+        Schema.RestrictionObject (Schema.ObjectRestrictionAdditionalProperties (Schema.AdditionalItemsAny False))]]+-- | Create a JSON Schema reference restriction for a named type+referenceRestriction :: Core.Name -> Schema.Restriction+referenceRestriction name =+    Schema.RestrictionReference (Schema.SchemaReference (Strings.cat [+      "#/$defs/",+      (encodeName name)]))+-- | Walk the transitive named-type dependency closure of a root type through typeMap; the visited set guards against cycles in self-/mutually-recursive types+transitiveTypeDeps :: M.Map Core.Name Core.Type -> S.Set Core.Name -> Core.Type -> S.Set Core.Name+transitiveTypeDeps typeMap visited rootType =++      let directDeps = Dependencies.typeDependencyNames True rootType+          step =+                  \acc -> \n -> Logic.ifElse (Sets.member n acc) acc (+                    let acc1 = Sets.insert n acc+                    in (Optionals.cases (Maps.lookup n typeMap) acc1 (\t -> transitiveTypeDeps typeMap acc1 t)))+      in (Lists.foldl step visited (Sets.toList directDeps))+-- | Build a JSON Schema document for a single named type, with $defs covering its transitive dependencies and short-name substitution applied+typeDefToDocument :: t0 -> Graph.Graph -> M.Map Core.Name Core.Type -> Core.Name -> Core.Type -> Either Errors.Error (String, Schema.Document)+typeDefToDocument cx g typeMap rootName rootType =++      let depNames = Sets.toList (transitiveTypeDeps typeMap Sets.empty rootType)+          allNames = Lists.concat2 [+                rootName] (Lists.filter (\n -> Logic.not (Equality.equal n rootName)) depNames)+          allTypes = Lists.map (\n -> Optionals.fromOptional (Core.TypeVariable n) (Maps.lookup n typeMap)) allNames+          nameSubst = Dependencies.toShortNames allNames+          types = Lists.map (\t -> Variables.substituteTypeVariables nameSubst t) allTypes+          names = Lists.map (\n -> Optionals.fromOptional n (Maps.lookup n nameSubst)) allNames+          subRoot = Optionals.fromOptional rootName (Maps.lookup rootName nameSubst)+          pairs = Lists.zip names types+      in (Eithers.bind (Eithers.mapList (\p -> typeToKeywordSchemaPair cx g (Pairs.first p) (Pairs.second p)) pairs) (\schemas -> Right (+        nameToPath rootName,+        Schema.Document {+          Schema.documentId = Nothing,+          Schema.documentDefinitions = (Just (Maps.fromList schemas)),+          Schema.documentRoot = (Schema.Schema [+            referenceRestriction subRoot])})))+-- | Encode a Hydra type as a list of JSON Schema restrictions+typeToExpr :: t0 -> Graph.Graph -> Bool -> Core.Type -> Either Errors.Error [Schema.Restriction]+typeToExpr cx g optional typ =+    case typ of+      Core.TypeAnnotated _ -> Eithers.bind (typeToExpr cx g optional (Strip.deannotateType typ)) (\res -> Eithers.bind (Annotations.getTypeDescription cx g typ) (\mdesc -> Right (Lists.concat2 (Optionals.cases mdesc [] (\d -> [+        Schema.RestrictionDescription d])) res)))+      Core.TypeApplication v0 -> typeToExpr cx g optional (Core.applicationTypeFunction v0)+      Core.TypeEither v0 ->+        let lt = Core.eitherTypeLeft v0+            rt = Core.eitherTypeRight v0+        in (Eithers.bind (typeToExpr cx g False lt) (\leftRes -> Eithers.bind (typeToExpr cx g False rt) (\rightRes -> Right [+          Schema.RestrictionMultiple (Schema.MultipleRestrictionOneOf [+            eitherBranch "left" leftRes,+            (eitherBranch "right" rightRes)])])))+      Core.TypeForall v0 -> typeToExpr cx g optional (Core.forallTypeBody v0)+      Core.TypeList v0 -> Eithers.bind (typeToExpr cx g False v0) (\els -> Right (Lists.concat2 (jsType optional Schema.TypeNameArray) [+        Schema.RestrictionArray (Schema.ArrayRestrictionItems (Schema.ItemsSameItems (Schema.Schema els)))]))+      Core.TypeLiteral v0 -> Right (jsType optional (literalTypeName v0))+      Core.TypeMap v0 ->+        let vt = Core.mapTypeValues v0+        in (Eithers.bind (typeToExpr cx g False vt) (\vRes -> Right (Lists.concat2 (jsType optional Schema.TypeNameObject) [+          Schema.RestrictionObject (Schema.ObjectRestrictionAdditionalProperties (Schema.AdditionalItemsSchema (Schema.Schema vRes)))])))+      Core.TypeOptional v0 -> typeToExpr cx g True v0+      Core.TypePair v0 ->+        let ft = Core.pairTypeFirst v0+            st = Core.pairTypeSecond v0+        in (Eithers.bind (typeToExpr cx g False ft) (\firstRes -> Eithers.bind (typeToExpr cx g False st) (\secondRes -> Right (pairRestrictions optional firstRes secondRes))))+      Core.TypeRecord v0 -> encodeRecordOrUnion cx g optional False v0+      Core.TypeSet v0 -> Eithers.bind (typeToExpr cx g False v0) (\els -> Right (Lists.concat2 (jsType optional Schema.TypeNameArray) [+        Schema.RestrictionArray (Schema.ArrayRestrictionItems (Schema.ItemsSameItems (Schema.Schema els)))]))+      Core.TypeUnion v0 -> encodeUnion cx g optional v0+      Core.TypeVariable v0 -> Right [+        referenceRestriction v0]+      Core.TypeWrap v0 -> typeToExpr cx g optional v0+      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "JSON Schema: unsupported type variant: " (ShowVariants.typeVariant (Reflect.typeVariant typ)))))+-- | Build a (Keyword, Schema) pair for a named type, used as a $defs entry+typeToKeywordSchemaPair :: t0 -> Graph.Graph -> Core.Name -> Core.Type -> Either Errors.Error (Schema.Keyword, Schema.Schema)+typeToKeywordSchemaPair cx g name typ =+    Eithers.map (\res -> (Schema.Keyword (encodeName name), (Schema.Schema res))) (encodeNamedType cx g name typ)
+ src/main/haskell/Hydra/Json/Schema/Language.hs view
@@ -0,0 +1,71 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints for JSON Schema++module Hydra.Json.Schema.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Reflect as Reflect+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Language constraints for JSON Schema+jsonSchemaLanguage :: Coders.Language+jsonSchemaLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.json.schema"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes = Sets.fromList [+      Core.FloatTypeFloat64]+    integerTypes = Sets.fromList [+      Core.IntegerTypeBigint]+    termVariants = Sets.fromList Reflect.termVariants+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantApplication,+          Variants.TypeVariantEither,+          Variants.TypeVariantForall,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantPair,+          Variants.TypeVariantRecord,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnion,+          Variants.TypeVariantVariable,+          Variants.TypeVariantWrap]+    typePredicate = \_ -> True
+ src/main/haskell/Hydra/Json/Schema/Serde.hs view
@@ -0,0 +1,286 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Serialization functions for converting JSON Schema documents to JSON values++module Hydra.Json.Schema.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Json.Schema as Schema+import qualified Hydra.Json.Writer as Writer+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Encode additional items as a JSON value+additionalItemsToExpr :: Schema.AdditionalItems -> Model.Value+additionalItemsToExpr ai =+    case ai of+      Schema.AdditionalItemsAny v0 -> Model.ValueBoolean v0+      Schema.AdditionalItemsSchema v0 -> schemaToExpr v0+-- | Encode an array restriction as a key-value pair+arrayRestrictionToExpr :: Schema.ArrayRestriction -> (String, Model.Value)+arrayRestrictionToExpr r =+    case r of+      Schema.ArrayRestrictionItems v0 -> itemsToExpr v0+      Schema.ArrayRestrictionAdditionalItems v0 -> (key_additionalItems, (additionalItemsToExpr v0))+      Schema.ArrayRestrictionMinItems v0 -> (key_minItems, (integerToExpr v0))+      Schema.ArrayRestrictionMaxItems v0 -> (key_maxItems, (integerToExpr v0))+      Schema.ArrayRestrictionUniqueItems v0 -> (key_uniqueItems, (Model.ValueBoolean v0))+-- | Extract the map from a JSON object value+fromObject :: Model.Value -> M.Map String Model.Value+fromObject v =+    case v of+      Model.ValueObject v0 -> Maps.fromList v0+-- | Encode an integer as a JSON number value+integerToExpr :: Int -> Model.Value+integerToExpr n = Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint n))+-- | Encode items as a key-value pair+itemsToExpr :: Schema.Items -> (String, Model.Value)+itemsToExpr items =+    (+      key_items,+      case items of+        Schema.ItemsSameItems v0 -> schemaToExpr v0+        Schema.ItemsVarItems v0 -> Model.ValueArray (Lists.map schemaToExpr v0))+-- | Convert a JSON Schema document to a JSON value+jsonSchemaDocumentToJsonValue :: Schema.Document -> Model.Value+jsonSchemaDocumentToJsonValue doc =++      let mid = Schema.documentId doc+          mdefs = Schema.documentDefinitions doc+          root = Schema.documentRoot doc+          schemaMap = fromObject (schemaToExpr root)+          restMap =+                  fromObject (toObject [+                    (key_id, (Optionals.map (\i -> Model.ValueString i) mid)),+                    (key_schema, (Optionals.pure (Model.ValueString "http://json-schema.org/2020-12/schema"))),+                    (+                      key_definitions,+                      (Optionals.map (\mp -> Model.ValueObject ((Lists.map (\p ->+                        let k = Pairs.first p+                            schema = Pairs.second p+                        in (Schema.unKeyword k, (schemaToExpr schema))) (Maps.toList mp)))) mdefs))])+      in (Model.ValueObject (Maps.toList (Maps.union schemaMap restMap)))+-- | Convert a JSON Schema document to a JSON string+jsonSchemaDocumentToString :: Schema.Document -> String+jsonSchemaDocumentToString doc = Writer.printJson (jsonSchemaDocumentToJsonValue doc)+key_additionalItems :: String+key_additionalItems = "additionalItems"+key_additionalProperties :: String+key_additionalProperties = "additionalProperties"+key_allOf :: String+key_allOf = "allOf"+key_anyOf :: String+key_anyOf = "anyOf"+key_definitions :: String+key_definitions = "$defs"+key_dependencies :: String+key_dependencies = "dependencies"+key_description :: String+key_description = "description"+key_enum :: String+key_enum = "enum"+key_exclusiveMaximum :: String+key_exclusiveMaximum = "exclusiveMaximum"+key_exclusiveMinimum :: String+key_exclusiveMinimum = "exclusiveMinimum"+key_id :: String+key_id = "$id"+key_items :: String+key_items = "items"+key_label :: String+key_label = "label"+key_maxItems :: String+key_maxItems = "maxItems"+key_maxLength :: String+key_maxLength = "maxLength"+key_maxProperties :: String+key_maxProperties = "maxProperties"+key_maximum :: String+key_maximum = "maximum"+key_minItems :: String+key_minItems = "minItems"+key_minLength :: String+key_minLength = "minLength"+key_minProperties :: String+key_minProperties = "minProperties"+key_minimum :: String+key_minimum = "minimum"+key_multipleOf :: String+key_multipleOf = "multipleOf"+key_not :: String+key_not = "not"+key_oneOf :: String+key_oneOf = "oneOf"+key_pattern :: String+key_pattern = "pattern"+key_patternProperties :: String+key_patternProperties = "patternProperties"+key_properties :: String+key_properties = "properties"+key_ref :: String+key_ref = "$ref"+key_required :: String+key_required = "required"+key_schema :: String+key_schema = "$schema"+key_title :: String+key_title = "title"+key_type :: String+key_type = "type"+key_uniqueItems :: String+key_uniqueItems = "uniqueItems"+-- | Encode a keyword-schema-or-array pair as a key-value pair+keywordSchemaOrArrayToExpr :: (Schema.Keyword, Schema.SchemaOrArray) -> (String, Model.Value)+keywordSchemaOrArrayToExpr p =++      let k = Pairs.first p+          s = Pairs.second p+      in (Schema.unKeyword k, (schemaOrArrayToExpr s))+-- | Encode a keyword as a JSON string value+keywordToExpr :: Schema.Keyword -> Model.Value+keywordToExpr k = Model.ValueString (Schema.unKeyword k)+-- | Encode a multiple restriction as a key-value pair+multipleRestrictionToExpr :: Schema.MultipleRestriction -> (String, Model.Value)+multipleRestrictionToExpr r =+    case r of+      Schema.MultipleRestrictionAllOf v0 -> (key_allOf, (Model.ValueArray (Lists.map schemaToExpr v0)))+      Schema.MultipleRestrictionAnyOf v0 -> (key_anyOf, (Model.ValueArray (Lists.map schemaToExpr v0)))+      Schema.MultipleRestrictionOneOf v0 -> (key_oneOf, (Model.ValueArray (Lists.map schemaToExpr v0)))+      Schema.MultipleRestrictionNot v0 -> (key_not, (schemaToExpr v0))+      Schema.MultipleRestrictionEnum v0 -> (key_enum, (Model.ValueArray v0))+-- | Encode a numeric restriction as a list of key-value pairs+numericRestrictionToExpr :: Schema.NumericRestriction -> [(String, Model.Value)]+numericRestrictionToExpr r =+    case r of+      Schema.NumericRestrictionMinimum v0 ->+        let value = Schema.limitValue v0+            excl = Schema.limitExclusive v0+        in (Lists.concat [+          [+            (key_minimum, (integerToExpr value))],+          (Logic.ifElse excl [+            (key_exclusiveMinimum, (Model.ValueBoolean True))] [])])+      Schema.NumericRestrictionMaximum v0 ->+        let value = Schema.limitValue v0+            excl = Schema.limitExclusive v0+        in (Lists.concat [+          [+            (key_maximum, (integerToExpr value))],+          (Logic.ifElse excl [+            (key_exclusiveMaximum, (Model.ValueBoolean True))] [])])+      Schema.NumericRestrictionMultipleOf v0 -> [+        (key_multipleOf, (integerToExpr v0))]+-- | Encode an object restriction as a key-value pair+objectRestrictionToExpr :: Schema.ObjectRestriction -> (String, Model.Value)+objectRestrictionToExpr r =+    case r of+      Schema.ObjectRestrictionProperties v0 -> (key_properties, (Model.ValueObject ((Lists.map propertyToExpr (Maps.toList v0)))))+      Schema.ObjectRestrictionAdditionalProperties v0 -> (key_additionalProperties, (additionalItemsToExpr v0))+      Schema.ObjectRestrictionRequired v0 -> (key_required, (Model.ValueArray (Lists.map keywordToExpr v0)))+      Schema.ObjectRestrictionMinProperties v0 -> (key_minProperties, (integerToExpr v0))+      Schema.ObjectRestrictionMaxProperties v0 -> (key_maxProperties, (integerToExpr v0))+      Schema.ObjectRestrictionDependencies v0 -> (key_dependencies, (Model.ValueObject ((Lists.map keywordSchemaOrArrayToExpr (Maps.toList v0)))))+      Schema.ObjectRestrictionPatternProperties v0 -> (key_patternProperties, (Model.ValueObject ((Lists.map patternPropertyToExpr (Maps.toList v0)))))+-- | Encode a pattern property pair as a key-value pair+patternPropertyToExpr :: (Schema.RegularExpression, Schema.Schema) -> (String, Model.Value)+patternPropertyToExpr p =++      let pat = Pairs.first p+          s = Pairs.second p+      in (Schema.unRegularExpression pat, (schemaToExpr s))+-- | Encode a property pair as a key-value pair+propertyToExpr :: (Schema.Keyword, Schema.Schema) -> (String, Model.Value)+propertyToExpr p =++      let k = Pairs.first p+          s = Pairs.second p+      in (Schema.unKeyword k, (schemaToExpr s))+-- | Encode a restriction as a list of key-value pairs+restrictionToExpr :: Schema.Restriction -> [(String, Model.Value)]+restrictionToExpr r =+    case r of+      Schema.RestrictionType v0 -> [+        (key_type, (typeToExpr v0))]+      Schema.RestrictionString v0 -> [+        stringRestrictionToExpr v0]+      Schema.RestrictionNumber v0 -> numericRestrictionToExpr v0+      Schema.RestrictionArray v0 -> [+        arrayRestrictionToExpr v0]+      Schema.RestrictionObject v0 -> [+        objectRestrictionToExpr v0]+      Schema.RestrictionMultiple v0 -> [+        multipleRestrictionToExpr v0]+      Schema.RestrictionReference v0 -> [+        (key_ref, (schemaReferenceToExpr v0))]+      Schema.RestrictionTitle v0 -> [+        (key_title, (Model.ValueString v0))]+      Schema.RestrictionDescription v0 -> [+        (key_description, (Model.ValueString v0))]+-- | Encode a schema or array as a JSON value+schemaOrArrayToExpr :: Schema.SchemaOrArray -> Model.Value+schemaOrArrayToExpr soa =+    case soa of+      Schema.SchemaOrArraySchema v0 -> schemaToExpr v0+      Schema.SchemaOrArrayArray v0 -> Model.ValueArray (Lists.map keywordToExpr v0)+-- | Encode a schema reference as a JSON string value+schemaReferenceToExpr :: Schema.SchemaReference -> Model.Value+schemaReferenceToExpr sr = Model.ValueString (Schema.unSchemaReference sr)+-- | Encode a schema as a JSON object value+schemaToExpr :: Schema.Schema -> Model.Value+schemaToExpr s = Model.ValueObject ((Lists.concat (Lists.map restrictionToExpr (Schema.unSchema s))))+-- | Encode a string restriction as a key-value pair+stringRestrictionToExpr :: Schema.StringRestriction -> (String, Model.Value)+stringRestrictionToExpr r =+    case r of+      Schema.StringRestrictionMaxLength v0 -> (key_maxLength, (Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint v0))))+      Schema.StringRestrictionMinLength v0 -> (key_minLength, (Model.ValueNumber (Literals.bigintToDecimal (Literals.int32ToBigint v0))))+      Schema.StringRestrictionPattern v0 -> (key_pattern, (Model.ValueString (Schema.unRegularExpression v0)))+-- | Construct a JSON object from a list of optional key-value pairs, filtering out Nothing values+toObject :: [(String, (Maybe Model.Value))] -> Model.Value+toObject pairs =+    Model.ValueObject ((Optionals.cat (Lists.map (\p ->+      let k = Pairs.first p+          mv = Pairs.second p+      in (Optionals.map (\v -> (k, v)) mv)) pairs)))+-- | Encode a type name as a JSON string value+typeNameToExpr :: Schema.TypeName -> Model.Value+typeNameToExpr t =+    case t of+      Schema.TypeNameString -> Model.ValueString "string"+      Schema.TypeNameInteger -> Model.ValueString "integer"+      Schema.TypeNameNumber -> Model.ValueString "number"+      Schema.TypeNameBoolean -> Model.ValueString "boolean"+      Schema.TypeNameNull -> Model.ValueString "null"+      Schema.TypeNameArray -> Model.ValueString "array"+      Schema.TypeNameObject -> Model.ValueString "object"+-- | Encode a type as a JSON value+typeToExpr :: Schema.Type -> Model.Value+typeToExpr t =+    case t of+      Schema.TypeSingle v0 -> typeNameToExpr v0+      Schema.TypeMultiple v0 -> Model.ValueArray (Lists.map typeNameToExpr v0)
+ src/main/haskell/Hydra/Kusto/Kql.hs view
@@ -0,0 +1,464 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A partial KQL (Kusto Query Language) model, based on examples from the documentation. Not normative.++module Hydra.Kusto.Kql where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Int as I+data BetweenExpression =+  BetweenExpression {+    betweenExpressionNot :: Bool,+    betweenExpressionExpression :: Expression,+    betweenExpressionLowerBound :: Expression,+    betweenExpressionUpperBound :: Expression}+  deriving (Eq, Ord, Read, Show)+_BetweenExpression = Core.Name "hydra.kusto.kql.BetweenExpression"+_BetweenExpression_not = Core.Name "not"+_BetweenExpression_expression = Core.Name "expression"+_BetweenExpression_lowerBound = Core.Name "lowerBound"+_BetweenExpression_upperBound = Core.Name "upperBound"+data BinaryExpression =+  BinaryExpression {+    binaryExpressionLeft :: Expression,+    binaryExpressionOperator :: BinaryOperator,+    binaryExpressionRight :: Expression}+  deriving (Eq, Ord, Read, Show)+_BinaryExpression = Core.Name "hydra.kusto.kql.BinaryExpression"+_BinaryExpression_left = Core.Name "left"+_BinaryExpression_operator = Core.Name "operator"+_BinaryExpression_right = Core.Name "right"+data BinaryOperator =+  BinaryOperatorCaseInsensitiveEqual |+  BinaryOperatorContains |+  BinaryOperatorDivide |+  BinaryOperatorEndsWith |+  BinaryOperatorEqual |+  BinaryOperatorGreater |+  BinaryOperatorGreaterOrEqual |+  BinaryOperatorHas |+  BinaryOperatorHasPrefix |+  BinaryOperatorHasSuffix |+  BinaryOperatorLess |+  BinaryOperatorLessOrEqual |+  BinaryOperatorMatchesRegex |+  BinaryOperatorMinus |+  BinaryOperatorNotEqual |+  BinaryOperatorPlus |+  BinaryOperatorStartsWith |+  BinaryOperatorTimes+  deriving (Eq, Ord, Read, Show)+_BinaryOperator = Core.Name "hydra.kusto.kql.BinaryOperator"+_BinaryOperator_caseInsensitiveEqual = Core.Name "caseInsensitiveEqual"+_BinaryOperator_contains = Core.Name "contains"+_BinaryOperator_divide = Core.Name "divide"+_BinaryOperator_endsWith = Core.Name "endsWith"+_BinaryOperator_equal = Core.Name "equal"+_BinaryOperator_greater = Core.Name "greater"+_BinaryOperator_greaterOrEqual = Core.Name "greaterOrEqual"+_BinaryOperator_has = Core.Name "has"+_BinaryOperator_hasPrefix = Core.Name "hasPrefix"+_BinaryOperator_hasSuffix = Core.Name "hasSuffix"+_BinaryOperator_less = Core.Name "less"+_BinaryOperator_lessOrEqual = Core.Name "lessOrEqual"+_BinaryOperator_matchesRegex = Core.Name "matchesRegex"+_BinaryOperator_minus = Core.Name "minus"+_BinaryOperator_notEqual = Core.Name "notEqual"+_BinaryOperator_plus = Core.Name "plus"+_BinaryOperator_startsWith = Core.Name "startsWith"+_BinaryOperator_times = Core.Name "times"+data BuiltInFunction =+  BuiltInFunctionAgo |+  BuiltInFunctionBin |+  BuiltInFunctionCount |+  BuiltInFunctionDcount |+  BuiltInFunctionEndofday |+  BuiltInFunctionExtract |+  BuiltInFunctionFormat_datetime |+  BuiltInFunctionMaterialize |+  BuiltInFunctionNow |+  BuiltInFunctionRange |+  BuiltInFunctionStartofday |+  BuiltInFunctionStrcat |+  BuiltInFunctionTodynamic+  deriving (Eq, Ord, Read, Show)+_BuiltInFunction = Core.Name "hydra.kusto.kql.BuiltInFunction"+_BuiltInFunction_ago = Core.Name "ago"+_BuiltInFunction_bin = Core.Name "bin"+_BuiltInFunction_count = Core.Name "count"+_BuiltInFunction_dcount = Core.Name "dcount"+_BuiltInFunction_endofday = Core.Name "endofday"+_BuiltInFunction_extract = Core.Name "extract"+_BuiltInFunction_format_datetime = Core.Name "format_datetime"+_BuiltInFunction_materialize = Core.Name "materialize"+_BuiltInFunction_now = Core.Name "now"+_BuiltInFunction_range = Core.Name "range"+_BuiltInFunction_startofday = Core.Name "startofday"+_BuiltInFunction_strcat = Core.Name "strcat"+_BuiltInFunction_todynamic = Core.Name "todynamic"+data ColumnAlias =+  ColumnAlias {+    columnAliasColumn :: ColumnName,+    columnAliasAlias :: ColumnName}+  deriving (Eq, Ord, Read, Show)+_ColumnAlias = Core.Name "hydra.kusto.kql.ColumnAlias"+_ColumnAlias_column = Core.Name "column"+_ColumnAlias_alias = Core.Name "alias"+data ColumnAssignment =+  ColumnAssignment {+    columnAssignmentColumn :: ColumnName,+    columnAssignmentExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_ColumnAssignment = Core.Name "hydra.kusto.kql.ColumnAssignment"+_ColumnAssignment_column = Core.Name "column"+_ColumnAssignment_expression = Core.Name "expression"+newtype ColumnName =+  ColumnName {+    unColumnName :: String}+  deriving (Eq, Ord, Read, Show)+_ColumnName = Core.Name "hydra.kusto.kql.ColumnName"+data Columns =+  ColumnsAll |+  ColumnsSingle ColumnName+  deriving (Eq, Ord, Read, Show)+_Columns = Core.Name "hydra.kusto.kql.Columns"+_Columns_all = Core.Name "all"+_Columns_single = Core.Name "single"+data Command =+  CommandCount |+  -- | See https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/distinct-operator+  CommandDistinct [ColumnName] |+  CommandExtend [ColumnAssignment] |+  CommandJoin JoinCommand |+  CommandLimit Int |+  CommandMvexpand ColumnName |+  CommandOrderBy [SortBy] |+  CommandParse ParseCommand |+  CommandPrint PrintCommand |+  CommandProject [Projection] |+  CommandProjectAway [ColumnName] |+  CommandProjectRename [ColumnAlias] |+  CommandRender String |+  CommandSearch SearchCommand |+  CommandSortBy [SortBy] |+  CommandSummarize SummarizeCommand |+  -- | Limit a search to a specified number of results+  CommandTake Int |+  CommandTop TopCommand |+  CommandUnion UnionCommand |+  CommandWhere Expression+  deriving (Eq, Ord, Read, Show)+_Command = Core.Name "hydra.kusto.kql.Command"+_Command_count = Core.Name "count"+_Command_distinct = Core.Name "distinct"+_Command_extend = Core.Name "extend"+_Command_join = Core.Name "join"+_Command_limit = Core.Name "limit"+_Command_mvexpand = Core.Name "mvexpand"+_Command_orderBy = Core.Name "orderBy"+_Command_parse = Core.Name "parse"+_Command_print = Core.Name "print"+_Command_project = Core.Name "project"+_Command_projectAway = Core.Name "projectAway"+_Command_projectRename = Core.Name "projectRename"+_Command_render = Core.Name "render"+_Command_search = Core.Name "search"+_Command_sortBy = Core.Name "sortBy"+_Command_summarize = Core.Name "summarize"+_Command_take = Core.Name "take"+_Command_top = Core.Name "top"+_Command_union = Core.Name "union"+_Command_where = Core.Name "where"+newtype Datetime =+  Datetime {+    unDatetime :: String}+  deriving (Eq, Ord, Read, Show)+_Datetime = Core.Name "hydra.kusto.kql.Datetime"+data Duration =+  Duration {+    durationValue :: Int,+    durationUnit :: DurationUnit}+  deriving (Eq, Ord, Read, Show)+_Duration = Core.Name "hydra.kusto.kql.Duration"+_Duration_value = Core.Name "value"+_Duration_unit = Core.Name "unit"+data DurationUnit =+  DurationUnitSecond |+  DurationUnitMinute |+  DurationUnitHour+  deriving (Eq, Ord, Read, Show)+_DurationUnit = Core.Name "hydra.kusto.kql.DurationUnit"+_DurationUnit_second = Core.Name "second"+_DurationUnit_minute = Core.Name "minute"+_DurationUnit_hour = Core.Name "hour"+data Expression =+  ExpressionAnd [Expression] |+  ExpressionAny |+  ExpressionBetween BetweenExpression |+  ExpressionBinary BinaryExpression |+  ExpressionBraces Expression |+  ExpressionColumn ColumnName |+  ExpressionDataset TableName |+  ExpressionIndex IndexExpression |+  ExpressionList [Expression] |+  ExpressionLiteral Literal |+  ExpressionOr [Expression] |+  ExpressionParentheses Expression |+  ExpressionProperty PropertyExpression |+  ExpressionUnary UnaryExpression+  deriving (Eq, Ord, Read, Show)+_Expression = Core.Name "hydra.kusto.kql.Expression"+_Expression_and = Core.Name "and"+_Expression_any = Core.Name "any"+_Expression_between = Core.Name "between"+_Expression_binary = Core.Name "binary"+_Expression_braces = Core.Name "braces"+_Expression_column = Core.Name "column"+_Expression_dataset = Core.Name "dataset"+_Expression_index = Core.Name "index"+_Expression_list = Core.Name "list"+_Expression_literal = Core.Name "literal"+_Expression_or = Core.Name "or"+_Expression_parentheses = Core.Name "parentheses"+_Expression_property = Core.Name "property"+_Expression_unary = Core.Name "unary"+data Function =+  FunctionBuiltIn BuiltInFunction |+  FunctionCustom FunctionName+  deriving (Eq, Ord, Read, Show)+_Function = Core.Name "hydra.kusto.kql.Function"+_Function_builtIn = Core.Name "builtIn"+_Function_custom = Core.Name "custom"+data FunctionExpression =+  FunctionExpression {+    functionExpressionFunction :: Function,+    functionExpressionArguments :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_FunctionExpression = Core.Name "hydra.kusto.kql.FunctionExpression"+_FunctionExpression_function = Core.Name "function"+_FunctionExpression_arguments = Core.Name "arguments"+newtype FunctionName =+  FunctionName {+    unFunctionName :: String}+  deriving (Eq, Ord, Read, Show)+_FunctionName = Core.Name "hydra.kusto.kql.FunctionName"+data IndexExpression =+  IndexExpression {+    indexExpressionExpression :: Expression,+    indexExpressionIndex :: String}+  deriving (Eq, Ord, Read, Show)+_IndexExpression = Core.Name "hydra.kusto.kql.IndexExpression"+_IndexExpression_expression = Core.Name "expression"+_IndexExpression_index = Core.Name "index"+data JoinCommand =+  JoinCommand {+    joinCommandKind :: JoinKind,+    joinCommandExpression :: TableName,+    joinCommandOn :: Expression}+  deriving (Eq, Ord, Read, Show)+_JoinCommand = Core.Name "hydra.kusto.kql.JoinCommand"+_JoinCommand_kind = Core.Name "kind"+_JoinCommand_expression = Core.Name "expression"+_JoinCommand_on = Core.Name "on"+data JoinKind =+  JoinKindLeftouter |+  JoinKindLeftsemi |+  JoinKindLeftanti |+  JoinKindFullouter |+  JoinKindInner |+  JoinKindInnerunique |+  JoinKindRightouter |+  JoinKindRightsemi |+  JoinKindRightanti+  deriving (Eq, Ord, Read, Show)+_JoinKind = Core.Name "hydra.kusto.kql.JoinKind"+_JoinKind_leftouter = Core.Name "leftouter"+_JoinKind_leftsemi = Core.Name "leftsemi"+_JoinKind_leftanti = Core.Name "leftanti"+_JoinKind_fullouter = Core.Name "fullouter"+_JoinKind_inner = Core.Name "inner"+_JoinKind_innerunique = Core.Name "innerunique"+_JoinKind_rightouter = Core.Name "rightouter"+_JoinKind_rightsemi = Core.Name "rightsemi"+_JoinKind_rightanti = Core.Name "rightanti"+data KeyValuePair =+  KeyValuePair {+    keyValuePairKey :: String,+    keyValuePairValue :: Expression}+  deriving (Eq, Ord, Read, Show)+_KeyValuePair = Core.Name "hydra.kusto.kql.KeyValuePair"+_KeyValuePair_key = Core.Name "key"+_KeyValuePair_value = Core.Name "value"+data LetBinding =+  LetBinding {+    letBindingName :: ColumnName,+    letBindingExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_LetBinding = Core.Name "hydra.kusto.kql.LetBinding"+_LetBinding_name = Core.Name "name"+_LetBinding_expression = Core.Name "expression"+data LetExpression =+  LetExpression {+    letExpressionBindings :: [LetBinding],+    letExpressionExpression :: TabularExpression}+  deriving (Eq, Ord, Read, Show)+_LetExpression = Core.Name "hydra.kusto.kql.LetExpression"+_LetExpression_bindings = Core.Name "bindings"+_LetExpression_expression = Core.Name "expression"+data Literal =+  LiteralDuration Duration |+  LiteralDatetime Datetime |+  LiteralString String |+  LiteralInt Int |+  LiteralLong I.Int64 |+  LiteralDouble Double |+  LiteralBoolean Bool+  deriving (Eq, Ord, Read, Show)+_Literal = Core.Name "hydra.kusto.kql.Literal"+_Literal_duration = Core.Name "duration"+_Literal_datetime = Core.Name "datetime"+_Literal_string = Core.Name "string"+_Literal_int = Core.Name "int"+_Literal_long = Core.Name "long"+_Literal_double = Core.Name "double"+_Literal_boolean = Core.Name "boolean"+data Order =+  OrderAscending |+  OrderDescending+  deriving (Eq, Ord, Read, Show)+_Order = Core.Name "hydra.kusto.kql.Order"+_Order_ascending = Core.Name "ascending"+_Order_descending = Core.Name "descending"+data Parameter =+  Parameter {+    parameterKey :: String,+    parameterValue :: Literal}+  deriving (Eq, Ord, Read, Show)+_Parameter = Core.Name "hydra.kusto.kql.Parameter"+_Parameter_key = Core.Name "key"+_Parameter_value = Core.Name "value"+data ParseCommand =+  ParseCommand {+    parseCommandColumn :: ColumnName,+    parseCommandPairs :: [KeyValuePair]}+  deriving (Eq, Ord, Read, Show)+_ParseCommand = Core.Name "hydra.kusto.kql.ParseCommand"+_ParseCommand_column = Core.Name "column"+_ParseCommand_pairs = Core.Name "pairs"+newtype PipelineExpression =+  PipelineExpression {+    unPipelineExpression :: [TabularExpression]}+  deriving (Eq, Ord, Read, Show)+_PipelineExpression = Core.Name "hydra.kusto.kql.PipelineExpression"+data PrintCommand =+  PrintCommand {+    printCommandColumn :: (Maybe ColumnName),+    printCommandExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_PrintCommand = Core.Name "hydra.kusto.kql.PrintCommand"+_PrintCommand_column = Core.Name "column"+_PrintCommand_expression = Core.Name "expression"+data Projection =+  Projection {+    projectionExpression :: Expression,+    projectionAlias :: (Maybe ColumnName)}+  deriving (Eq, Ord, Read, Show)+_Projection = Core.Name "hydra.kusto.kql.Projection"+_Projection_expression = Core.Name "expression"+_Projection_alias = Core.Name "alias"+data PropertyExpression =+  PropertyExpression {+    propertyExpressionExpression :: Expression,+    propertyExpressionProperty :: String}+  deriving (Eq, Ord, Read, Show)+_PropertyExpression = Core.Name "hydra.kusto.kql.PropertyExpression"+_PropertyExpression_expression = Core.Name "expression"+_PropertyExpression_property = Core.Name "property"+newtype Query =+  Query {+    unQuery :: TabularExpression}+  deriving (Eq, Ord, Read, Show)+_Query = Core.Name "hydra.kusto.kql.Query"+-- | Search across all datasets and columns or, if provided, specific datasets and/or columns+data SearchCommand =+  SearchCommand {+    searchCommandDatasets :: [TableName],+    searchCommandPattern :: Expression}+  deriving (Eq, Ord, Read, Show)+_SearchCommand = Core.Name "hydra.kusto.kql.SearchCommand"+_SearchCommand_datasets = Core.Name "datasets"+_SearchCommand_pattern = Core.Name "pattern"+data SummarizeCommand =+  SummarizeCommand {+    summarizeCommandColumns :: [ColumnAssignment],+    summarizeCommandBy :: [ColumnName]}+  deriving (Eq, Ord, Read, Show)+_SummarizeCommand = Core.Name "hydra.kusto.kql.SummarizeCommand"+_SummarizeCommand_columns = Core.Name "columns"+_SummarizeCommand_by = Core.Name "by"+newtype TableName =+  TableName {+    unTableName :: String}+  deriving (Eq, Ord, Read, Show)+_TableName = Core.Name "hydra.kusto.kql.TableName"+data TopCommand =+  TopCommand {+    topCommandCount :: Int,+    topCommandSort :: [SortBy]}+  deriving (Eq, Ord, Read, Show)+_TopCommand = Core.Name "hydra.kusto.kql.TopCommand"+_TopCommand_count = Core.Name "count"+_TopCommand_sort = Core.Name "sort"+data SortBy =+  SortBy {+    sortByColumn :: ColumnName,+    sortByOrder :: (Maybe Order)}+  deriving (Eq, Ord, Read, Show)+_SortBy = Core.Name "hydra.kusto.kql.SortBy"+_SortBy_column = Core.Name "column"+_SortBy_order = Core.Name "order"+data TabularExpression =+  TabularExpressionCommand Command |+  TabularExpressionPipeline PipelineExpression |+  TabularExpressionLet LetExpression |+  TabularExpressionTable TableName+  deriving (Eq, Ord, Read, Show)+_TabularExpression = Core.Name "hydra.kusto.kql.TabularExpression"+_TabularExpression_command = Core.Name "command"+_TabularExpression_pipeline = Core.Name "pipeline"+_TabularExpression_let = Core.Name "let"+_TabularExpression_table = Core.Name "table"+data UnaryExpression =+  UnaryExpression {+    unaryExpressionOperator :: UnaryOperator,+    unaryExpressionExpression :: Expression}+  deriving (Eq, Ord, Read, Show)+_UnaryExpression = Core.Name "hydra.kusto.kql.UnaryExpression"+_UnaryExpression_operator = Core.Name "operator"+_UnaryExpression_expression = Core.Name "expression"+data UnaryOperator =+  UnaryOperatorNot+  deriving (Eq, Ord, Read, Show)+_UnaryOperator = Core.Name "hydra.kusto.kql.UnaryOperator"+_UnaryOperator_not = Core.Name "not"+data UnionCommand =+  UnionCommand {+    unionCommandParameters :: [Parameter],+    unionCommandKind :: (Maybe UnionKind),+    unionCommandWithSource :: (Maybe ColumnName),+    unionCommandIsFuzzy :: (Maybe Bool),+    unionCommandTables :: [TableName]}+  deriving (Eq, Ord, Read, Show)+_UnionCommand = Core.Name "hydra.kusto.kql.UnionCommand"+_UnionCommand_parameters = Core.Name "parameters"+_UnionCommand_kind = Core.Name "kind"+_UnionCommand_withSource = Core.Name "withSource"+_UnionCommand_isFuzzy = Core.Name "isFuzzy"+_UnionCommand_tables = Core.Name "tables"+data UnionKind =+  UnionKindInner |+  UnionKindOuter+  deriving (Eq, Ord, Read, Show)+_UnionKind = Core.Name "hydra.kusto.kql.UnionKind"+_UnionKind_inner = Core.Name "inner"+_UnionKind_outer = Core.Name "outer"
+ src/main/haskell/Hydra/Osv/Schema.hs view
@@ -0,0 +1,179 @@+-- Note: this is an automatically generated file. Do not edit.+-- | See https://ossf.github.io/osv-schema++module Hydra.Osv.Schema where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+data Credited =+  Credited {+    creditedName :: String,+    creditedContact :: (Maybe [Url])}+  deriving (Eq, Ord, Read, Show)+_Credited = Core.Name "hydra.osv.schema.Credited"+_Credited_name = Core.Name "name"+_Credited_contact = Core.Name "contact"+-- | One of a limited set of defined ecosystems, currently Go, npm, OSS-Fuzz, PyPI, RubyGems, crates.io, Packagist, Maven, NuGet, Linux, Debian, Hex, Android, GitHub Actions, or Pub+newtype Ecosystem =+  Ecosystem {+    unEcosystem :: String}+  deriving (Eq, Ord, Read, Show)+_Ecosystem = Core.Name "hydra.osv.schema.Ecosystem"+data Entry =+  Entry {+    -- | The default value is '1.0.0', matching version 1.0 of the OSV Schema+    entrySchemaVersion :: (Maybe OsvVersion),+    entryId :: Id,+    entryModified :: Timestamp,+    entryPublished :: (Maybe Timestamp),+    entryWithdrawn :: (Maybe Timestamp),+    entryAliases :: (Maybe [Id]),+    entryRelated :: (Maybe [Id]),+    entrySummary :: (Maybe String),+    entryDetails :: (Maybe Markdown),+    entrySeverity :: (Maybe [Severity]),+    entryAffected :: (Maybe [PackageVersions]),+    entryReferences :: (Maybe [Reference]),+    entryCredits :: (Maybe [Credited])}+  deriving (Eq, Ord, Read, Show)+_Entry = Core.Name "hydra.osv.schema.Entry"+_Entry_schemaVersion = Core.Name "schemaVersion"+_Entry_id = Core.Name "id"+_Entry_modified = Core.Name "modified"+_Entry_published = Core.Name "published"+_Entry_withdrawn = Core.Name "withdrawn"+_Entry_aliases = Core.Name "aliases"+_Entry_related = Core.Name "related"+_Entry_summary = Core.Name "summary"+_Entry_details = Core.Name "details"+_Entry_severity = Core.Name "severity"+_Entry_affected = Core.Name "affected"+_Entry_references = Core.Name "references"+_Entry_credits = Core.Name "credits"+data Event =+  EventIntroduced VersionOrZero |+  EventFixed Version |+  EventLastAffected Version |+  EventLimit VersionOrStar+  deriving (Eq, Ord, Read, Show)+_Event = Core.Name "hydra.osv.schema.Event"+_Event_introduced = Core.Name "introduced"+_Event_fixed = Core.Name "fixed"+_Event_lastAffected = Core.Name "lastAffected"+_Event_limit = Core.Name "limit"+-- | A string of the format <DB>-<ENTRYID>, where DB names the database and ENTRYID is in the format used by the database. For example: OSV-2020-111, CVE-2021-3114, or GHSA-vp9c-fpxx-744v+newtype Id =+  Id {+    unId :: String}+  deriving (Eq, Ord, Read, Show)+_Id = Core.Name "hydra.osv.schema.Id"+-- | CommonMark markdown text+newtype Markdown =+  Markdown {+    unMarkdown :: String}+  deriving (Eq, Ord, Read, Show)+_Markdown = Core.Name "hydra.osv.schema.Markdown"+-- | A string which follows the SemVer 2.0.0 format, with no leading 'v' prefix+newtype OsvVersion =+  OsvVersion {+    unOsvVersion :: String}+  deriving (Eq, Ord, Read, Show)+_OsvVersion = Core.Name "hydra.osv.schema.OsvVersion"+data Package =+  Package {+    packageEcosystem :: Ecosystem,+    packageName :: String,+    packagePurl :: (Maybe Url)}+  deriving (Eq, Ord, Read, Show)+_Package = Core.Name "hydra.osv.schema.Package"+_Package_ecosystem = Core.Name "ecosystem"+_Package_name = Core.Name "name"+_Package_purl = Core.Name "purl"+data PackageVersions =+  PackageVersions {+    packageVersionsPackage :: Package,+    packageVersionsRanges :: (Maybe [VersionRange]),+    packageVersionsVersions :: (Maybe [Version])}+  deriving (Eq, Ord, Read, Show)+_PackageVersions = Core.Name "hydra.osv.schema.PackageVersions"+_PackageVersions_package = Core.Name "package"+_PackageVersions_ranges = Core.Name "ranges"+_PackageVersions_versions = Core.Name "versions"+data Reference =+  Reference {+    referenceType :: ReferenceType,+    referenceUrl :: Url}+  deriving (Eq, Ord, Read, Show)+_Reference = Core.Name "hydra.osv.schema.Reference"+_Reference_type = Core.Name "type"+_Reference_url = Core.Name "url"+-- | One of ADVISORY, ARTICLE, REPORT, FIX, GIT, PACKAGE, EVIDENCE, or WEB+newtype ReferenceType =+  ReferenceType {+    unReferenceType :: String}+  deriving (Eq, Ord, Read, Show)+_ReferenceType = Core.Name "hydra.osv.schema.ReferenceType"+data Severity =+  Severity {+    severityType :: SeverityType,+    severityScore :: SeverityScore}+  deriving (Eq, Ord, Read, Show)+_Severity = Core.Name "hydra.osv.schema.Severity"+_Severity_type = Core.Name "type"+_Severity_score = Core.Name "score"+newtype SeverityScore =+  SeverityScore {+    unSeverityScore :: String}+  deriving (Eq, Ord, Read, Show)+_SeverityScore = Core.Name "hydra.osv.schema.SeverityScore"+-- | The value CVSS_V3, or future supported types+newtype SeverityType =+  SeverityType {+    unSeverityType :: String}+  deriving (Eq, Ord, Read, Show)+_SeverityType = Core.Name "hydra.osv.schema.SeverityType"+-- | An RFC3339-formatted timestamp in UTC (ending in 'Z')+newtype Timestamp =+  Timestamp {+    unTimestamp :: String}+  deriving (Eq, Ord, Read, Show)+_Timestamp = Core.Name "hydra.osv.schema.Timestamp"+newtype Url =+  Url {+    unUrl :: String}+  deriving (Eq, Ord, Read, Show)+_Url = Core.Name "hydra.osv.schema.Url"+-- | A version number in an ecosystem-specific format+newtype Version =+  Version {+    unVersion :: String}+  deriving (Eq, Ord, Read, Show)+_Version = Core.Name "hydra.osv.schema.Version"+-- | An ecosystem-specific version number, or the string '*' representing infinity+newtype VersionOrStar =+  VersionOrStar {+    unVersionOrStar :: String}+  deriving (Eq, Ord, Read, Show)+_VersionOrStar = Core.Name "hydra.osv.schema.VersionOrStar"+-- | An ecosystem-specific version number, or the string '0' representing a version that sorts before any other version+newtype VersionOrZero =+  VersionOrZero {+    unVersionOrZero :: String}+  deriving (Eq, Ord, Read, Show)+_VersionOrZero = Core.Name "hydra.osv.schema.VersionOrZero"+data VersionRange =+  VersionRange {+    versionRangeType :: VersionType,+    versionRangeRepo :: (Maybe Url),+    versionRangeEvents :: [Event]}+  deriving (Eq, Ord, Read, Show)+_VersionRange = Core.Name "hydra.osv.schema.VersionRange"+_VersionRange_type = Core.Name "type"+_VersionRange_repo = Core.Name "repo"+_VersionRange_events = Core.Name "events"+-- | One of the values 'SEMVER', 'ECOSYSTEM', or 'GIT+newtype VersionType =+  VersionType {+    unVersionType :: String}+  deriving (Eq, Ord, Read, Show)+_VersionType = Core.Name "hydra.osv.schema.VersionType"
+ src/main/haskell/Hydra/Parquet/Format.hs view
@@ -0,0 +1,726 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for the Parquet format. Based on the Thrift-based specification at:+-- |   https://github.com/apache/parquet-format/blob/master/src/main/thrift/parquet.thrift++module Hydra.Parquet.Format where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.ByteString as B+import qualified Data.Int as I+-- | Types supported by Parquet.  These types are intended to be used in combination with the encodings to control the on disk storage format. For example INT16 is not included as a type since a good encoding of INT32 would handle this.+data Type =+  TypeBoolean |+  TypeInt32 |+  TypeInt64 |+  TypeFloat |+  TypeDouble |+  TypeByteArray |+  TypeFixedLenByteArray+  deriving (Eq, Ord, Read, Show)+_Type = Core.Name "hydra.parquet.format.Type"+_Type_boolean = Core.Name "boolean"+_Type_int32 = Core.Name "int32"+_Type_int64 = Core.Name "int64"+_Type_float = Core.Name "float"+_Type_double = Core.Name "double"+_Type_byteArray = Core.Name "byteArray"+_Type_fixedLenByteArray = Core.Name "fixedLenByteArray"+-- | Representation of Schemas+data FieldRepetitionType =+  -- | This field is required (can not be null) and each record has exactly 1 value.+  FieldRepetitionTypeRequired |+  -- | The field is optional (can be null) and each record has 0 or 1 values.+  FieldRepetitionTypeOptional |+  -- | The field is repeated and can contain 0 or more values+  FieldRepetitionTypeRepeated+  deriving (Eq, Ord, Read, Show)+_FieldRepetitionType = Core.Name "hydra.parquet.format.FieldRepetitionType"+_FieldRepetitionType_required = Core.Name "required"+_FieldRepetitionType_optional = Core.Name "optional"+_FieldRepetitionType_repeated = Core.Name "repeated"+-- | Statistics per row group and per page. All fields are optional.+data Statistics =+  Statistics {+    statisticsNullCount :: (Maybe Integer),+    statisticsDistinctCount :: (Maybe Integer),+    -- | Max value for the column, determined by its ColumnOrder. Values are encoded using PLAIN encoding, except that variable-length byte arrays do not include a length prefix.+    statisticsMaxValue :: (Maybe B.ByteString),+    -- | Max value for the column, determined by its ColumnOrder. Values are encoded using PLAIN encoding, except that variable-length byte arrays do not include a length prefix.+    statisticsMinValue :: (Maybe B.ByteString)}+  deriving (Eq, Ord, Read, Show)+_Statistics = Core.Name "hydra.parquet.format.Statistics"+_Statistics_nullCount = Core.Name "nullCount"+_Statistics_distinctCount = Core.Name "distinctCount"+_Statistics_maxValue = Core.Name "maxValue"+_Statistics_minValue = Core.Name "minValue"+-- | Decimal logical type annotation. To maintain forward-compatibility in v1, implementations using this logical type must also set scale and precision on the annotated SchemaElement. Allowed for physical types: INT32, INT64, FIXED, and BINARY+data DecimalType =+  DecimalType {+    decimalTypeScale :: Int,+    decimalTypePrecision :: Int}+  deriving (Eq, Ord, Read, Show)+_DecimalType = Core.Name "hydra.parquet.format.DecimalType"+_DecimalType_scale = Core.Name "scale"+_DecimalType_precision = Core.Name "precision"+data TimeUnit =+  TimeUnitMillis |+  TimeUnitMicros |+  TimeUnitNanos+  deriving (Eq, Ord, Read, Show)+_TimeUnit = Core.Name "hydra.parquet.format.TimeUnit"+_TimeUnit_millis = Core.Name "millis"+_TimeUnit_micros = Core.Name "micros"+_TimeUnit_nanos = Core.Name "nanos"+-- | Timestamp logical type annotation. Allowed for physical types: INT64+data TimestampType =+  TimestampType {+    timestampTypeIsAdjustedToUtc :: Bool,+    timestampTypeUnit :: TimeUnit}+  deriving (Eq, Ord, Read, Show)+_TimestampType = Core.Name "hydra.parquet.format.TimestampType"+_TimestampType_isAdjustedToUtc = Core.Name "isAdjustedToUtc"+_TimestampType_unit = Core.Name "unit"+-- | Time logical type annotation. Allowed for physical types: INT32 (millis), INT64 (micros, nanos)+data TimeType =+  TimeType {+    timeTypeIsAdjustedToUtc :: Bool,+    timeTypeUnit :: TimeUnit}+  deriving (Eq, Ord, Read, Show)+_TimeType = Core.Name "hydra.parquet.format.TimeType"+_TimeType_isAdjustedToUtc = Core.Name "isAdjustedToUtc"+_TimeType_unit = Core.Name "unit"+-- | Integer logical type annotation. bitWidth must be 8, 16, 32, or 64. Allowed for physical types: INT32, INT64+data IntType =+  IntType {+    intTypeBitWidth :: I.Int16,+    intTypeIsSigned :: Bool}+  deriving (Eq, Ord, Read, Show)+_IntType = Core.Name "hydra.parquet.format.IntType"+_IntType_bitWidth = Core.Name "bitWidth"+_IntType_isSigned = Core.Name "isSigned"+-- | LogicalType annotations to replace ConvertedType. To maintain compatibility, implementations using LogicalType for a SchemaElement aust also set the corresponding ConvertedType (if any) from the following table.+data LogicalType =+  -- | use ConvertedType UTF8+  LogicalTypeString |+  -- | use ConvertedType MAP+  LogicalTypeMap |+  -- | use ConvertedType LIST+  LogicalTypeList |+  -- | use ConvertedType ENUM+  LogicalTypeEnum |+  -- | use ConvertedType DECIMAL + SchemaElement.{scale, precision}+  LogicalTypeDecimal DecimalType |+  -- | use ConvertedType DATE+  LogicalTypeDate |+  -- | use ConvertedType TIME_MICROS for TIME(isAdjustedToUTC = *, unit = MICROS). use ConvertedType TIME_MILLIS for TIME(isAdjustedToUTC = *, unit = MILLIS)+  LogicalTypeTime TimeType |+  -- | use ConvertedType TIMESTAMP_MICROS for TIMESTAMP(isAdjustedToUTC = *, unit = MICROS). use ConvertedType TIMESTAMP_MILLIS for TIMESTAMP(isAdjustedToUTC = *, unit = MILLIS)+  LogicalTypeTimestamp TimestampType |+  -- | use ConvertedType INT_* or UINT_*+  LogicalTypeInteger IntType |+  -- | no compatible ConvertedType+  LogicalTypeUnknown |+  -- | use ConvertedType JSON+  LogicalTypeJson |+  -- | use ConvertedType BSON+  LogicalTypeBson |+  -- | no compatible ConvertedType+  LogicalTypeUuid+  deriving (Eq, Ord, Read, Show)+_LogicalType = Core.Name "hydra.parquet.format.LogicalType"+_LogicalType_string = Core.Name "string"+_LogicalType_map = Core.Name "map"+_LogicalType_list = Core.Name "list"+_LogicalType_enum = Core.Name "enum"+_LogicalType_decimal = Core.Name "decimal"+_LogicalType_date = Core.Name "date"+_LogicalType_time = Core.Name "time"+_LogicalType_timestamp = Core.Name "timestamp"+_LogicalType_integer = Core.Name "integer"+_LogicalType_unknown = Core.Name "unknown"+_LogicalType_json = Core.Name "json"+_LogicalType_bson = Core.Name "bson"+_LogicalType_uuid = Core.Name "uuid"+-- | Represents a element inside a schema definition.+-- | - if it is a group (inner node) then type is undefined and num_children is defined+-- | - if it is a primitive type (leaf) then type is defined and num_children is undefined+-- | the nodes are listed in depth first traversal order.+data SchemaElement =+  SchemaElement {+    -- | Data type for this field. Not set if the current element is a non-leaf node+    schemaElementType :: (Maybe Type),+    -- | If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the values. Otherwise, if specified, this is the maximum bit length to store any of the values. (e.g. a low cardinality INT col could have this set to 3).  Note that this is in the schema, and therefore fixed for the entire file.+    schemaElementTypeLength :: (Maybe Int),+    -- | repetition of the field. The root of the schema does not have a repetition_type. All other nodes must have one+    schemaElementRepetitionType :: (Maybe FieldRepetitionType),+    -- | Name of the field in the schema+    schemaElementName :: String,+    -- | Nested fields.  Since thrift does not support nested fields, the nesting is flattened to a single list by a depth-first traversal. The children count is used to construct the nested relationship. This field is not set when the element is a primitive type+    schemaElementNumChildren :: (Maybe Int),+    -- | When the original schema supports field ids, this will save the original field id in the parquet schema+    schemaElementFieldId :: (Maybe Int),+    -- | The logical type of this SchemaElement. LogicalType replaces ConvertedType, but ConvertedType is still required for some logical types to ensure forward-compatibility in format v1.+    schemaElementLogicalType :: (Maybe LogicalType)}+  deriving (Eq, Ord, Read, Show)+_SchemaElement = Core.Name "hydra.parquet.format.SchemaElement"+_SchemaElement_type = Core.Name "type"+_SchemaElement_typeLength = Core.Name "typeLength"+_SchemaElement_repetitionType = Core.Name "repetitionType"+_SchemaElement_name = Core.Name "name"+_SchemaElement_numChildren = Core.Name "numChildren"+_SchemaElement_fieldId = Core.Name "fieldId"+_SchemaElement_logicalType = Core.Name "logicalType"+-- | Encodings supported by Parquet.  Not all encodings are valid for all types.  These enums are also used to specify the encoding of definition and repetition levels. See the accompanying doc for the details of the more complicated encodings.+data Encoding =+  -- | Default encoding.+  -- | BOOLEAN - 1 bit per value. 0 is false; 1 is true.+  -- | INT32 - 4 bytes per value.  Stored as little-endian.+  -- | INT64 - 8 bytes per value.  Stored as little-endian.+  -- | FLOAT - 4 bytes per value.  IEEE. Stored as little-endian.+  -- | DOUBLE - 8 bytes per value.  IEEE. Stored as little-endian.+  -- | BYTE_ARRAY - 4 byte length stored as little endian, followed by bytes.+  -- | FIXED_LEN_BYTE_ARRAY - Just the bytes.+  EncodingPlain |+  -- | Group packed run length encoding. Usable for definition/repetition levels encoding and Booleans (on one bit: 0 is false; 1 is true.)+  EncodingRle |+  -- | Bit packed encoding.  This can only be used if the data has a known max width.  Usable for definition/repetition levels encoding.+  EncodingBitPacked |+  -- | Delta encoding for integers. This can be used for int columns and works best on sorted data+  EncodingDeltaBinaryPacked |+  -- | Encoding for byte arrays to separate the length values and the data. The lengths are encoded using DELTA_BINARY_PACKED+  EncodingDeltaLengthByteArray |+  -- | Incremental-encoded byte array. Prefix lengths are encoded using DELTA_BINARY_PACKED. Suffixes are stored as delta length byte arrays.+  EncodingDeltaByteArray |+  -- | Dictionary encoding: the ids are encoded using the RLE encoding+  EncodingRleDictionary |+  -- | Encoding for floating-point data. K byte-streams are created where K is the size in bytes of the data type. The individual bytes of an FP value are scattered to the corresponding stream and the streams are concatenated. This itself does not reduce the size of the data but can lead to better compression afterwards.+  EncodingByteStreamSplit+  deriving (Eq, Ord, Read, Show)+_Encoding = Core.Name "hydra.parquet.format.Encoding"+_Encoding_plain = Core.Name "plain"+_Encoding_rle = Core.Name "rle"+_Encoding_bitPacked = Core.Name "bitPacked"+_Encoding_deltaBinaryPacked = Core.Name "deltaBinaryPacked"+_Encoding_deltaLengthByteArray = Core.Name "deltaLengthByteArray"+_Encoding_deltaByteArray = Core.Name "deltaByteArray"+_Encoding_rleDictionary = Core.Name "rleDictionary"+_Encoding_byteStreamSplit = Core.Name "byteStreamSplit"+-- | Supported compression algorithms. Codecs added in format version X.Y can be read by readers based on X.Y and later. Codec support may vary between readers based on the format version and libraries available at runtime. See Compression.md for a detailed specification of these algorithms.+data CompressionCodec =+  CompressionCodecUncompressed |+  CompressionCodecSnappy |+  CompressionCodecGzip |+  CompressionCodecLzo |+  -- | Added in 2.4+  CompressionCodecBrotli |+  -- | Added in 2.4+  CompressionCodecZstd |+  -- | Added in 2.9+  CompressionCodecLz4Raw+  deriving (Eq, Ord, Read, Show)+_CompressionCodec = Core.Name "hydra.parquet.format.CompressionCodec"+_CompressionCodec_uncompressed = Core.Name "uncompressed"+_CompressionCodec_snappy = Core.Name "snappy"+_CompressionCodec_gzip = Core.Name "gzip"+_CompressionCodec_lzo = Core.Name "lzo"+_CompressionCodec_brotli = Core.Name "brotli"+_CompressionCodec_zstd = Core.Name "zstd"+_CompressionCodec_lz4Raw = Core.Name "lz4Raw"+data PageType =+  PageTypeDataPage |+  PageTypeIndexPage |+  PageTypeDictionaryPage |+  PageTypeDataPageV2+  deriving (Eq, Ord, Read, Show)+_PageType = Core.Name "hydra.parquet.format.PageType"+_PageType_dataPage = Core.Name "dataPage"+_PageType_indexPage = Core.Name "indexPage"+_PageType_dictionaryPage = Core.Name "dictionaryPage"+_PageType_dataPageV2 = Core.Name "dataPageV2"+-- | Enum to annotate whether lists of min/max elements inside ColumnIndex are ordered and if so, in which direction.+data BoundaryOrder =+  BoundaryOrderUnordered |+  BoundaryOrderAscending |+  BoundaryOrderDescending+  deriving (Eq, Ord, Read, Show)+_BoundaryOrder = Core.Name "hydra.parquet.format.BoundaryOrder"+_BoundaryOrder_unordered = Core.Name "unordered"+_BoundaryOrder_ascending = Core.Name "ascending"+_BoundaryOrder_descending = Core.Name "descending"+-- | Data page header+data DataPageHeader =+  DataPageHeader {+    -- | Number of values, including NULLs, in this data page.+    dataPageHeaderNumValues :: Int,+    -- | Encoding used for this data page+    dataPageHeaderEncoding :: Encoding,+    -- | Encoding used for definition levels+    dataPageHeaderDefinitionLevelEncoding :: Encoding,+    -- | Encoding used for repetition levels+    dataPageHeaderRepetitionLevelEncoding :: Encoding,+    -- | Optional statistics for the data in this page+    dataPageHeaderStatistics :: (Maybe Statistics)}+  deriving (Eq, Ord, Read, Show)+_DataPageHeader = Core.Name "hydra.parquet.format.DataPageHeader"+_DataPageHeader_numValues = Core.Name "numValues"+_DataPageHeader_encoding = Core.Name "encoding"+_DataPageHeader_definitionLevelEncoding = Core.Name "definitionLevelEncoding"+_DataPageHeader_repetitionLevelEncoding = Core.Name "repetitionLevelEncoding"+_DataPageHeader_statistics = Core.Name "statistics"+data IndexPageHeader =+  IndexPageHeader {}+  deriving (Eq, Ord, Read, Show)+_IndexPageHeader = Core.Name "hydra.parquet.format.IndexPageHeader"+-- | The dictionary page must be placed at the first position of the column chunk if it is partly or completely dictionary encoded. At most one dictionary page can be placed in a column chunk.+data DictionaryPageHeader =+  DictionaryPageHeader {+    -- | Number of values in the dictionary+    dictionaryPageHeaderNumValues :: Int,+    -- | Encoding using this dictionary page+    dictionaryPageHeaderEncoding :: Encoding,+    -- | If true, the entries in the dictionary are sorted in ascending order+    dictionaryPageHeaderIsSorted :: (Maybe Bool)}+  deriving (Eq, Ord, Read, Show)+_DictionaryPageHeader = Core.Name "hydra.parquet.format.DictionaryPageHeader"+_DictionaryPageHeader_numValues = Core.Name "numValues"+_DictionaryPageHeader_encoding = Core.Name "encoding"+_DictionaryPageHeader_isSorted = Core.Name "isSorted"+-- | New page format allowing reading levels without decompressing the data Repetition and definition levels are uncompressed The remaining section containing the data is compressed if is_compressed is true+data DataPageHeaderV2 =+  DataPageHeaderV2 {+    -- | Number of values, including NULLs, in this data page.+    dataPageHeaderV2NumValues :: Int,+    -- | Number of NULL values, in this data page. Number of non-null = num_values - num_nulls which is also the number of values in the data section+    dataPageHeaderV2NumNulls :: Int,+    -- | Number of rows in this data page. which means pages change on record boundaries (r = 0)+    dataPageHeaderV2NumRows :: Int,+    -- | Encoding used for data in this page+    dataPageHeaderV2Encoding :: Encoding,+    -- | length of the definition levels+    dataPageHeaderV2DefinitionLevelsByteLength :: Int,+    -- | length of the repetition levels+    dataPageHeaderV2RepetitionLevelsByteLength :: Int,+    -- | whether the values are compressed. Which means the section of the page between definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included) is compressed with the compression_codec. If missing it is considered compressed+    dataPageHeaderV2IsCompressed :: (Maybe Bool),+    -- | optional statistics for the data in this page+    dataPageHeaderV2Statistics :: (Maybe Statistics)}+  deriving (Eq, Ord, Read, Show)+_DataPageHeaderV2 = Core.Name "hydra.parquet.format.DataPageHeaderV2"+_DataPageHeaderV2_numValues = Core.Name "numValues"+_DataPageHeaderV2_numNulls = Core.Name "numNulls"+_DataPageHeaderV2_numRows = Core.Name "numRows"+_DataPageHeaderV2_encoding = Core.Name "encoding"+_DataPageHeaderV2_definitionLevelsByteLength = Core.Name "definitionLevelsByteLength"+_DataPageHeaderV2_repetitionLevelsByteLength = Core.Name "repetitionLevelsByteLength"+_DataPageHeaderV2_isCompressed = Core.Name "isCompressed"+_DataPageHeaderV2_statistics = Core.Name "statistics"+-- | The algorithm used in Bloom filter.+data BloomFilterAlgorithm =+  -- | Block-based Bloom filter.+  BloomFilterAlgorithmBlock+  deriving (Eq, Ord, Read, Show)+_BloomFilterAlgorithm = Core.Name "hydra.parquet.format.BloomFilterAlgorithm"+_BloomFilterAlgorithm_block = Core.Name "block"+-- | The hash function used in Bloom filter. This function takes the hash of a column value using plain encoding.+data BloomFilterHash =+  -- | xxHash Strategy.+  BloomFilterHashXxhash+  deriving (Eq, Ord, Read, Show)+_BloomFilterHash = Core.Name "hydra.parquet.format.BloomFilterHash"+_BloomFilterHash_xxhash = Core.Name "xxhash"+-- | The compression used in the Bloom filter.+data BloomFilterCompression =+  BloomFilterCompressionUncompressed+  deriving (Eq, Ord, Read, Show)+_BloomFilterCompression = Core.Name "hydra.parquet.format.BloomFilterCompression"+_BloomFilterCompression_uncompressed = Core.Name "uncompressed"+-- | Bloom filter header is stored at beginning of Bloom filter data of each column and followed by its bitset.+data BloomFilterHeader =+  BloomFilterHeader {+    -- | The size of bitset in bytes+    bloomFilterHeaderNumBytes :: Int,+    -- | The algorithm for setting bits.+    bloomFilterHeaderAlgorithm :: BloomFilterAlgorithm,+    -- | The hash function used for Bloom filter.+    bloomFilterHeaderHash :: BloomFilterHash,+    -- | The compression used in the Bloom filter+    bloomFilterHeaderCompression :: BloomFilterCompression}+  deriving (Eq, Ord, Read, Show)+_BloomFilterHeader = Core.Name "hydra.parquet.format.BloomFilterHeader"+_BloomFilterHeader_numBytes = Core.Name "numBytes"+_BloomFilterHeader_algorithm = Core.Name "algorithm"+_BloomFilterHeader_hash = Core.Name "hash"+_BloomFilterHeader_compression = Core.Name "compression"+data PageHeader =+  PageHeader {+    -- | the type of the page: indicates which of the *_header fields is set+    pageHeaderType :: PageType,+    -- | Uncompressed page size in bytes (not including this header)+    pageHeaderUncompressedPageSize :: Int,+    -- | Compressed (and potentially encrypted) page size in bytes, not including this header+    pageHeaderCompressedPageSize :: Int,+    -- | The 32bit CRC for the page, to be be calculated as follows:+    -- | - Using the standard CRC32 algorithm+    -- | - On the data only, i.e. this header should not be included. 'Data'+    -- |   hereby refers to the concatenation of the repetition levels, the+    -- |   definition levels and the column value, in this exact order.+    -- | - On the encoded versions of the repetition levels, definition levels and+    -- |   column values+    -- | - On the compressed versions of the repetition levels, definition levels+    -- |   and column values where possible;+    -- |   - For v1 data pages, the repetition levels, definition levels and column+    -- |     values are always compressed together. If a compression scheme is+    -- |     specified, the CRC shall be calculated on the compressed version of+    -- |     this concatenation. If no compression scheme is specified, the CRC+    -- |     shall be calculated on the uncompressed version of this concatenation.+    -- |   - For v2 data pages, the repetition levels and definition levels are+    -- |     handled separately from the data and are never compressed (only+    -- |     encoded). If a compression scheme is specified, the CRC shall be+    -- |     calculated on the concatenation of the uncompressed repetition levels,+    -- |     uncompressed definition levels and the compressed column values.+    -- |     If no compression scheme is specified, the CRC shall be calculated on+    -- |     the uncompressed concatenation.+    -- | - In encrypted columns, CRC is calculated after page encryption; the+    -- |   encryption itself is performed after page compression (if compressed)+    -- | If enabled, this allows for disabling checksumming in HDFS if only a few pages need to be read. +    pageHeaderCrc :: (Maybe Int),+    pageHeaderDataPageHeader :: (Maybe DataPageHeader),+    pageHeaderIndexPageHeader :: (Maybe IndexPageHeader),+    pageHeaderDictionaryPageHeader :: (Maybe DictionaryPageHeader),+    pageHeaderDataPageHeaderV2 :: (Maybe DataPageHeaderV2)}+  deriving (Eq, Ord, Read, Show)+_PageHeader = Core.Name "hydra.parquet.format.PageHeader"+_PageHeader_type = Core.Name "type"+_PageHeader_uncompressedPageSize = Core.Name "uncompressedPageSize"+_PageHeader_compressedPageSize = Core.Name "compressedPageSize"+_PageHeader_crc = Core.Name "crc"+_PageHeader_dataPageHeader = Core.Name "dataPageHeader"+_PageHeader_indexPageHeader = Core.Name "indexPageHeader"+_PageHeader_dictionaryPageHeader = Core.Name "dictionaryPageHeader"+_PageHeader_dataPageHeaderV2 = Core.Name "dataPageHeaderV2"+-- | Wrapper struct to store key values+data KeyValue =+  KeyValue {+    keyValueKey :: String,+    keyValueValue :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_KeyValue = Core.Name "hydra.parquet.format.KeyValue"+_KeyValue_key = Core.Name "key"+_KeyValue_value = Core.Name "value"+-- | Wrapper struct to specify sort order+data SortingColumn =+  SortingColumn {+    -- | The column index (in this row group)+    sortingColumnColumnIdx :: Int,+    -- | If true, indicates this column is sorted in descending order.+    sortingColumnDescending :: Bool,+    -- | If true, nulls will come before non-null values, otherwise, nulls go at the end.+    sortingColumnNullsFirst :: Bool}+  deriving (Eq, Ord, Read, Show)+_SortingColumn = Core.Name "hydra.parquet.format.SortingColumn"+_SortingColumn_columnIdx = Core.Name "columnIdx"+_SortingColumn_descending = Core.Name "descending"+_SortingColumn_nullsFirst = Core.Name "nullsFirst"+-- | statistics of a given page type and encoding+data PageEncodingStats =+  PageEncodingStats {+    -- | the page type (data/dic/...)+    pageEncodingStatsPageType :: PageType,+    -- | encoding of the page+    pageEncodingStatsEncoding :: Encoding,+    -- | number of pages of this type with this encoding+    pageEncodingStatsCount :: Int}+  deriving (Eq, Ord, Read, Show)+_PageEncodingStats = Core.Name "hydra.parquet.format.PageEncodingStats"+_PageEncodingStats_pageType = Core.Name "pageType"+_PageEncodingStats_encoding = Core.Name "encoding"+_PageEncodingStats_count = Core.Name "count"+-- | Description for column metadata+data ColumnMetaData =+  ColumnMetaData {+    -- | Type of this column+    columnMetaDataType :: Type,+    -- | Set of all encodings used for this column. The purpose is to validate whether we can decode those pages.+    columnMetaDataEncodings :: [Encoding],+    -- | Path in schema+    columnMetaDataPathInSchema :: [String],+    -- | Compression codec+    columnMetaDataCodec :: CompressionCodec,+    -- | Number of values in this column+    columnMetaDataNumValues :: I.Int64,+    -- | total byte size of all uncompressed pages in this column chunk (including the headers)+    columnMetaDataTotalUncompressedSize :: I.Int64,+    -- | total byte size of all compressed, and potentially encrypted, pages in this column chunk (including the headers)+    columnMetaDataTotalCompressedSize :: I.Int64,+    -- | Optional key/value metadata+    columnMetaDataKeyValueMetadata :: (Maybe [KeyValue]),+    -- | Byte offset from beginning of file to first data page+    columnMetaDataDataPageOffset :: I.Int64,+    -- | Byte offset from beginning of file to root index page+    columnMetaDataIndexPageOffset :: (Maybe I.Int64),+    -- | Byte offset from the beginning of file to first (only) dictionary page+    columnMetaDataDictionaryPageOffset :: (Maybe I.Int64),+    -- | optional statistics for this column chunk+    columnMetaDataStatistics :: (Maybe Statistics),+    -- | Set of all encodings used for pages in this column chunk. This information can be used to determine if all data pages are dictionary encoded for example+    columnMetaDataEncodingStats :: (Maybe [PageEncodingStats]),+    -- | Byte offset from beginning of file to Bloom filter data.+    columnMetaDataBloomFilterOffset :: (Maybe I.Int64)}+  deriving (Eq, Ord, Read, Show)+_ColumnMetaData = Core.Name "hydra.parquet.format.ColumnMetaData"+_ColumnMetaData_type = Core.Name "type"+_ColumnMetaData_encodings = Core.Name "encodings"+_ColumnMetaData_pathInSchema = Core.Name "pathInSchema"+_ColumnMetaData_codec = Core.Name "codec"+_ColumnMetaData_numValues = Core.Name "numValues"+_ColumnMetaData_totalUncompressedSize = Core.Name "totalUncompressedSize"+_ColumnMetaData_totalCompressedSize = Core.Name "totalCompressedSize"+_ColumnMetaData_keyValueMetadata = Core.Name "keyValueMetadata"+_ColumnMetaData_dataPageOffset = Core.Name "dataPageOffset"+_ColumnMetaData_indexPageOffset = Core.Name "indexPageOffset"+_ColumnMetaData_dictionaryPageOffset = Core.Name "dictionaryPageOffset"+_ColumnMetaData_statistics = Core.Name "statistics"+_ColumnMetaData_encodingStats = Core.Name "encodingStats"+_ColumnMetaData_bloomFilterOffset = Core.Name "bloomFilterOffset"+data EncryptionWithFooterKey =+  EncryptionWithFooterKey {}+  deriving (Eq, Ord, Read, Show)+_EncryptionWithFooterKey = Core.Name "hydra.parquet.format.EncryptionWithFooterKey"+data EncryptionWithColumnKey =+  EncryptionWithColumnKey {+    -- | Column path in schema+    encryptionWithColumnKeyPathInSchema :: [String],+    -- | Retrieval metadata of column encryption key+    encryptionWithColumnKeyKeyMetadata :: (Maybe B.ByteString)}+  deriving (Eq, Ord, Read, Show)+_EncryptionWithColumnKey = Core.Name "hydra.parquet.format.EncryptionWithColumnKey"+_EncryptionWithColumnKey_pathInSchema = Core.Name "pathInSchema"+_EncryptionWithColumnKey_keyMetadata = Core.Name "keyMetadata"+data ColumnCryptoMetaData =+  ColumnCryptoMetaDataEncryptionWithFooterKey EncryptionWithFooterKey |+  ColumnCryptoMetaDataEncryptionWithColumnKey EncryptionWithColumnKey+  deriving (Eq, Ord, Read, Show)+_ColumnCryptoMetaData = Core.Name "hydra.parquet.format.ColumnCryptoMetaData"+_ColumnCryptoMetaData_encryptionWithFooterKey = Core.Name "encryptionWithFooterKey"+_ColumnCryptoMetaData_encryptionWithColumnKey = Core.Name "encryptionWithColumnKey"+data ColumnChunk =+  ColumnChunk {+    -- | File where column data is stored.  If not set, assumed to be same file as metadata.  This path is relative to the current file.+    columnChunkFilePath :: (Maybe String),+    -- | Byte offset in file_path to the ColumnMetaData+    columnChunkFileOffset :: I.Int64,+    -- | Column metadata for this chunk. This is the same content as what is at file_path/file_offset.  Having it here has it replicated in the file metadata.+    columnChunkMetaData :: (Maybe ColumnMetaData),+    -- | File offset of ColumnChunk's OffsetIndex+    columnChunkOffsetIndexOffset :: (Maybe I.Int64),+    -- | Size of ColumnChunk's OffsetIndex, in bytes+    columnChunkOffsetIndexLength :: (Maybe Int),+    -- | File offset of ColumnChunk's ColumnIndex+    columnChunkColumnIndexOffset :: (Maybe I.Int64),+    -- | Size of ColumnChunk's ColumnIndex, in bytes+    columnChunkColumnIndexLength :: (Maybe Int),+    -- | Crypto metadata of encrypted columns+    columnChunkCryptoMetadata :: (Maybe ColumnCryptoMetaData),+    -- | Encrypted column metadata for this chunk+    columnChunkEncryptedColumnMetadata :: (Maybe B.ByteString)}+  deriving (Eq, Ord, Read, Show)+_ColumnChunk = Core.Name "hydra.parquet.format.ColumnChunk"+_ColumnChunk_filePath = Core.Name "filePath"+_ColumnChunk_fileOffset = Core.Name "fileOffset"+_ColumnChunk_metaData = Core.Name "metaData"+_ColumnChunk_offsetIndexOffset = Core.Name "offsetIndexOffset"+_ColumnChunk_offsetIndexLength = Core.Name "offsetIndexLength"+_ColumnChunk_columnIndexOffset = Core.Name "columnIndexOffset"+_ColumnChunk_columnIndexLength = Core.Name "columnIndexLength"+_ColumnChunk_cryptoMetadata = Core.Name "cryptoMetadata"+_ColumnChunk_encryptedColumnMetadata = Core.Name "encryptedColumnMetadata"+data RowGroup =+  RowGroup {+    -- | Metadata for each column chunk in this row group. This list must have the same order as the SchemaElement list in FileMetaData.+    rowGroupColumns :: [ColumnChunk],+    -- | Total byte size of all the uncompressed column data in this row group+    rowGroupTotalByteSize :: I.Int64,+    -- | Number of rows in this row group+    rowGroupNumRows :: I.Int64,+    -- | If set, specifies a sort ordering of the rows in this RowGroup. The sorting columns can be a subset of all the columns.+    rowGroupSortingColumns :: (Maybe [SortingColumn]),+    -- | Byte offset from beginning of file to first page (data or dictionary) in this row group+    rowGroupFileOffset :: (Maybe I.Int64),+    -- | Total byte size of all compressed (and potentially encrypted) column data in this row group+    rowGroupTotalCompressedSize :: (Maybe I.Int64),+    -- | Row group ordinal in the file+    rowGroupOrdinal :: (Maybe I.Int16)}+  deriving (Eq, Ord, Read, Show)+_RowGroup = Core.Name "hydra.parquet.format.RowGroup"+_RowGroup_columns = Core.Name "columns"+_RowGroup_totalByteSize = Core.Name "totalByteSize"+_RowGroup_numRows = Core.Name "numRows"+_RowGroup_sortingColumns = Core.Name "sortingColumns"+_RowGroup_fileOffset = Core.Name "fileOffset"+_RowGroup_totalCompressedSize = Core.Name "totalCompressedSize"+_RowGroup_ordinal = Core.Name "ordinal"+-- | Union to specify the order used for the min_value and max_value fields for a column. This union takes the role of an enhanced enum that allows rich elements (which will be needed for a collation-based ordering in the future). Possible values are:+-- | * TypeDefinedOrder - the column uses the order defined by its logical or physical type (if there is no logical type).+-- | If the reader does not support the value of this union, min and max stats for this column should be ignored. +data ColumnOrder =+  -- | The sort orders for logical types are:+  -- |   UTF8 - unsigned byte-wise comparison+  -- |   INT8 - signed comparison+  -- |   INT16 - signed comparison+  -- |   INT32 - signed comparison+  -- |   INT64 - signed comparison+  -- |   UINT8 - unsigned comparison+  -- |   UINT16 - unsigned comparison+  -- |   UINT32 - unsigned comparison+  -- |   UINT64 - unsigned comparison+  -- |   DECIMAL - signed comparison of the represented value+  -- |   DATE - signed comparison+  -- |   TIME_MILLIS - signed comparison+  -- |   TIME_MICROS - signed comparison+  -- |   TIMESTAMP_MILLIS - signed comparison+  -- |   TIMESTAMP_MICROS - signed comparison+  -- |   INTERVAL - unsigned comparison+  -- |   JSON - unsigned byte-wise comparison+  -- |   BSON - unsigned byte-wise comparison+  -- |   ENUM - unsigned byte-wise comparison+  -- |   LIST - undefined+  -- |   MAP - undefined+  -- | In the absence of logical types, the sort order is determined by the physical type:+  -- |   BOOLEAN - false, true+  -- |   INT32 - signed comparison+  -- |   INT64 - signed comparison+  -- |   INT96 (only used for legacy timestamps) - undefined+  -- |   FLOAT - signed comparison of the represented value (*)+  -- |   DOUBLE - signed comparison of the represented value (*)+  -- |   BYTE_ARRAY - unsigned byte-wise comparison+  -- |   FIXED_LEN_BYTE_ARRAY - unsigned byte-wise comparison+  -- | (*) Because the sorting order is not specified properly for floating+  -- |     point values (relations vs. total ordering) the following+  -- |     compatibility rules should be applied when reading statistics:+  -- |     - If the min is a NaN, it should be ignored.+  -- |     - If the max is a NaN, it should be ignored.+  -- |     - If the min is +0, the row group may contain -0 values as well.+  -- |     - If the max is -0, the row group may contain +0 values as well.+  -- |     - When looking for NaN values, min and max should be ignored.+  ColumnOrderTypeOrder+  deriving (Eq, Ord, Read, Show)+_ColumnOrder = Core.Name "hydra.parquet.format.ColumnOrder"+_ColumnOrder_typeOrder = Core.Name "typeOrder"+data PageLocation =+  PageLocation {+    -- | Offset of the page in the file+    pageLocationOffset :: I.Int64,+    -- | Size of the page, including header. Sum of compressed_page_size and header length+    pageLocationCompressedPageSize :: Int,+    -- | Index within the RowGroup of the first row of the page; this means pages change on record boundaries (r = 0).+    pageLocationFirstRowIndex :: I.Int64}+  deriving (Eq, Ord, Read, Show)+_PageLocation = Core.Name "hydra.parquet.format.PageLocation"+_PageLocation_offset = Core.Name "offset"+_PageLocation_compressedPageSize = Core.Name "compressedPageSize"+_PageLocation_firstRowIndex = Core.Name "firstRowIndex"+data OffsetIndex =+  OffsetIndex {+    -- | PageLocations, ordered by increasing PageLocation.offset. It is required that page_locations[i].first_row_index < page_locations[i+1].first_row_index.+    offsetIndexPageLocations :: [PageLocation]}+  deriving (Eq, Ord, Read, Show)+_OffsetIndex = Core.Name "hydra.parquet.format.OffsetIndex"+_OffsetIndex_pageLocations = Core.Name "pageLocations"+-- | Description for ColumnIndex. Each <array-field>[i] refers to the page at OffsetIndex.page_locations[i]+data ColumnIndex =+  ColumnIndex {+    -- | A list of Boolean values to determine the validity of the corresponding min and max values. If true, a page contains only null values, and writers have to set the corresponding entries in min_values and max_values to byte[0], so that all lists have the same length. If false, the corresponding entries in min_values and max_values must be valid.+    columnIndexNullPages :: [Bool],+    -- | minValues and maxValues are lists containing lower and upper bounds for the values of each page determined by the ColumnOrder of the column. These may be the actual minimum and maximum values found on a page, but can also be (more compact) values that do not exist on a page. For example, instead of storing "Blart Versenwald III", a writer may set min_values[i]="B", max_values[i]="C". Such more compact values must still be valid values within the column's logical type. Readers must make sure that list entries are populated before using them by inspecting null_pages.+    columnIndexMinValues :: [B.ByteString],+    columnIndexMaxValues :: [B.ByteString],+    -- | Stores whether both min_values and max_values are orderd and if so, in which direction. This allows readers to perform binary searches in both lists. Readers cannot assume that max_values[i] <= min_values[i+1], even if the lists are ordered.+    columnIndexBoundaryOrder :: BoundaryOrder,+    -- | A list containing the number of null values for each page+    columnIndexNullCounts :: (Maybe [I.Int64])}+  deriving (Eq, Ord, Read, Show)+_ColumnIndex = Core.Name "hydra.parquet.format.ColumnIndex"+_ColumnIndex_nullPages = Core.Name "nullPages"+_ColumnIndex_minValues = Core.Name "minValues"+_ColumnIndex_maxValues = Core.Name "maxValues"+_ColumnIndex_boundaryOrder = Core.Name "boundaryOrder"+_ColumnIndex_nullCounts = Core.Name "nullCounts"+data AesGcmV1 =+  AesGcmV1 {+    -- | AAD prefix+    aesGcmV1AadPrefix :: (Maybe B.ByteString),+    -- | Unique file identifier part of AAD suffix+    aesGcmV1AadFileUnique :: (Maybe B.ByteString),+    -- | In files encrypted with AAD prefix without storing it, readers must supply the prefix+    aesGcmV1SupplyAadPrefix :: (Maybe Bool)}+  deriving (Eq, Ord, Read, Show)+_AesGcmV1 = Core.Name "hydra.parquet.format.AesGcmV1"+_AesGcmV1_aadPrefix = Core.Name "aadPrefix"+_AesGcmV1_aadFileUnique = Core.Name "aadFileUnique"+_AesGcmV1_supplyAadPrefix = Core.Name "supplyAadPrefix"+data AesGcmCtrV1 =+  AesGcmCtrV1 {+    -- | AAD prefix+    aesGcmCtrV1AadPrefix :: (Maybe B.ByteString),+    -- | Unique file identifier part of AAD suffix+    aesGcmCtrV1AadFileUnique :: (Maybe B.ByteString),+    -- | In files encrypted with AAD prefix without storing it, readers must supply the prefix+    aesGcmCtrV1SupplyAadPrefix :: (Maybe Bool)}+  deriving (Eq, Ord, Read, Show)+_AesGcmCtrV1 = Core.Name "hydra.parquet.format.AesGcmCtrV1"+_AesGcmCtrV1_aadPrefix = Core.Name "aadPrefix"+_AesGcmCtrV1_aadFileUnique = Core.Name "aadFileUnique"+_AesGcmCtrV1_supplyAadPrefix = Core.Name "supplyAadPrefix"+data EncryptionAlgorithm =+  EncryptionAlgorithmAesGcmV1 AesGcmV1 |+  EncryptionAlgorithmAesGcmCtrV1 AesGcmCtrV1+  deriving (Eq, Ord, Read, Show)+_EncryptionAlgorithm = Core.Name "hydra.parquet.format.EncryptionAlgorithm"+_EncryptionAlgorithm_aesGcmV1 = Core.Name "aesGcmV1"+_EncryptionAlgorithm_aesGcmCtrV1 = Core.Name "aesGcmCtrV1"+-- | Description for file metadata+data FileMetaData =+  FileMetaData {+    -- | Version of this file+    fileMetaDataVersion :: Int,+    -- | Parquet schema for this file.  This schema contains metadata for all the columns. The schema is represented as a tree with a single root.  The nodes of the tree are flattened to a list by doing a depth-first traversal. The column metadata contains the path in the schema for that column which can be used to map columns to nodes in the schema. The first element is the root+    fileMetaDataSchema :: [SchemaElement],+    -- | Number of rows in this file+    fileMetaDataNumRows :: I.Int64,+    -- | Row groups in this file+    fileMetaDataRowGroups :: [RowGroup],+    -- | Optional key/value metadata+    fileMetaDataKeyValueMetadata :: (Maybe [KeyValue]),+    -- | String for application that wrote this file.  This should be in the format <Application> version <App Version> (build <App Build Hash>). e.g. impala version 1.0 (build 6cf94d29b2b7115df4de2c06e2ab4326d721eb55)+    fileMetaDataCreatedBy :: (Maybe String),+    -- | Sort order used for the min_value and max_value fields in the Statistics objects and the min_values and max_values fields in the ColumnIndex objects of each column in this file. Sort orders are listed in the order matching the columns in the schema. The indexes are not necessary the same though, because only leaf nodes of the schema are represented in the list of sort orders.+    -- | Without column_orders, the meaning of the min_value and max_value fields in the Statistics object and the ColumnIndex object is undefined. To ensure well-defined behaviour, if these fields are written to a Parquet file, column_orders must be written as well.+    -- | The obsolete min and max fields in the Statistics object are always sorted by signed comparison regardless of column_orders.+    fileMetaDataColumnOrders :: (Maybe [ColumnOrder]),+    -- | Encryption algorithm. This field is set only in encrypted files with plaintext footer. Files with encrypted footer store algorithm id in FileCryptoMetaData structure.+    fileMetaDataEncryptionAlgorithm :: (Maybe EncryptionAlgorithm),+    -- | Retrieval metadata of key used for signing the footer. Used only in encrypted files with plaintext footer.+    fileMetaDataFooterSigningKeyMetadata :: (Maybe B.ByteString)}+  deriving (Eq, Ord, Read, Show)+_FileMetaData = Core.Name "hydra.parquet.format.FileMetaData"+_FileMetaData_version = Core.Name "version"+_FileMetaData_schema = Core.Name "schema"+_FileMetaData_numRows = Core.Name "numRows"+_FileMetaData_rowGroups = Core.Name "rowGroups"+_FileMetaData_keyValueMetadata = Core.Name "keyValueMetadata"+_FileMetaData_createdBy = Core.Name "createdBy"+_FileMetaData_columnOrders = Core.Name "columnOrders"+_FileMetaData_encryptionAlgorithm = Core.Name "encryptionAlgorithm"+_FileMetaData_footerSigningKeyMetadata = Core.Name "footerSigningKeyMetadata"+-- | Crypto metadata for files with encrypted footer+data FileCryptoMetaData =+  FileCryptoMetaData {+    -- | Encryption algorithm. This field is only used for files with encrypted footer. Files with plaintext footer store algorithm id inside footer (FileMetaData structure).+    fileCryptoMetaDataEncryptionAlgorithm :: EncryptionAlgorithm,+    -- | Retrieval metadata of key used for encryption of footer, and (possibly) columns+    fileCryptoMetaDataKeyMetadata :: (Maybe B.ByteString)}+  deriving (Eq, Ord, Read, Show)+_FileCryptoMetaData = Core.Name "hydra.parquet.format.FileCryptoMetaData"+_FileCryptoMetaData_encryptionAlgorithm = Core.Name "encryptionAlgorithm"+_FileCryptoMetaData_keyMetadata = Core.Name "keyMetadata"
+ src/main/haskell/Hydra/Pegasus/Coder.hs view
@@ -0,0 +1,268 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Pegasus PDL code generator: converts Hydra modules to PDL schema files++module Hydra.Pegasus.Coder where+import qualified Hydra.Analysis as Analysis+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.File as File+import qualified Hydra.Dependencies as Dependencies+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Pegasus.Language as Language+import qualified Hydra.Pegasus.Pdl as Pdl+import qualified Hydra.Pegasus.Serde as Serde+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Show.Core as ShowCore+import qualified Hydra.Sorting as Sorting+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | Construct PDL schema files from type definitions, with topological sorting and cycle detection+constructModule :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Packaging.Module -> [Packaging.TypeDefinition] -> Either Errors.Error (M.Map String Pdl.SchemaFile)+constructModule cx g aliases mod typeDefs =++      let groups = Dependencies.topologicalSortTypeDefinitions typeDefs+      in (Optionals.cases (Lists.find (\grp -> Equality.gt (Lists.length grp) 1) groups) (+        let sortedDefs = Lists.concat groups+        in (Eithers.bind (Eithers.mapList (\typeDef -> typeToSchema cx g aliases mod typeDef) sortedDefs) (\schemas -> Right (Maps.fromList (Lists.map (toPair mod aliases) schemas))))) (\cycle -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "types form a cycle (unsupported in PDL): [" (Strings.cat2 (Strings.intercalate ", " (Lists.map (\td -> Core.unName (Packaging.typeDefinitionName td)) cycle)) "]"))))))+-- | Create PDL annotations from an optional doc string+doc :: Maybe String -> Pdl.Annotations+doc s =+    Pdl.Annotations {+      Pdl.annotationsDoc = s,+      Pdl.annotationsDeprecated = False}+encode :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.Type -> Either Errors.Error Pdl.Schema+encode cx g aliases t =+    case (Strip.deannotateType t) of+      Core.TypeRecord v0 -> Logic.ifElse (Lists.null v0) (encode cx g aliases (Core.TypeLiteral (Core.LiteralTypeInteger Core.IntegerTypeInt32))) (Eithers.bind (encodeType cx g aliases t) (\res -> Eithers.either (\schema -> Right schema) (\_ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "type resolved to an unsupported nested named schema: " (ShowCore.type_ t))))) res))+      _ -> Eithers.bind (encodeType cx g aliases t) (\res -> Eithers.either (\schema -> Right schema) (\_ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "type resolved to an unsupported nested named schema: " (ShowCore.type_ t))))) res)+encodeEnumField :: t0 -> Graph.Graph -> Core.FieldType -> Either Errors.Error Pdl.EnumField+encodeEnumField cx g ft =++      let name = Core.fieldTypeName ft+          typ = Core.fieldTypeType ft+      in (Eithers.bind (getAnns cx g typ) (\anns -> Right (Pdl.EnumField {+        Pdl.enumFieldName = (Pdl.EnumFieldName (Formatting.convertCase Util.CaseConventionCamel Util.CaseConventionUpperSnake (Core.unName name))),+        Pdl.enumFieldAnnotations = anns})))+encodePossiblyOptionalType :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.Type -> Either Errors.Error (Pdl.Schema, Bool)+encodePossiblyOptionalType cx g aliases typ =+    case (Strip.deannotateType typ) of+      Core.TypeOptional v0 -> Eithers.bind (encode cx g aliases v0) (\t -> Right (t, True))+      Core.TypeRecord _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeUnion _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeLiteral _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeList _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeMap _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeSet _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeVariable _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeWrap _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeEither _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypePair _ -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeVoid -> Eithers.bind (encode cx g aliases typ) (\t -> Right (t, False))+      Core.TypeAnnotated v0 -> encodePossiblyOptionalType cx g aliases (Core.annotatedTypeBody v0)+encodeRecordField :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.FieldType -> Either Errors.Error Pdl.RecordField+encodeRecordField cx g aliases ft =++      let name = Core.fieldTypeName ft+          typ = Core.fieldTypeType ft+      in (Eithers.bind (getAnns cx g typ) (\anns -> Eithers.bind (encodePossiblyOptionalType cx g aliases typ) (\optResult ->+        let schema = Pairs.first optResult+            optional = Pairs.second optResult+        in (Right (Pdl.RecordField {+          Pdl.recordFieldName = (Pdl.FieldName (Core.unName name)),+          Pdl.recordFieldValue = schema,+          Pdl.recordFieldOptional = optional,+          Pdl.recordFieldDefault = Nothing,+          Pdl.recordFieldAnnotations = anns})))))+-- | Encode a Hydra type as either a PDL Schema (Left) or a PDL NamedSchemaType (Right)+encodeType :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.Type -> Either Errors.Error (Either Pdl.Schema Pdl.NamedSchemaType)+encodeType cx g aliases typ =+    case typ of+      Core.TypeAnnotated v0 -> encodeType cx g aliases (Core.annotatedTypeBody v0)+      Core.TypeEither v0 -> Eithers.bind (encode cx g aliases (Core.eitherTypeLeft v0)) (\leftSchema -> Eithers.bind (encode cx g aliases (Core.eitherTypeRight v0)) (\rightSchema ->+        let leftMember =+                Pdl.UnionMember {+                  Pdl.unionMemberAlias = (Just (Pdl.FieldName "left")),+                  Pdl.unionMemberValue = leftSchema,+                  Pdl.unionMemberAnnotations = noAnnotations}+            rightMember =+                    Pdl.UnionMember {+                      Pdl.unionMemberAlias = (Just (Pdl.FieldName "right")),+                      Pdl.unionMemberValue = rightSchema,+                      Pdl.unionMemberAnnotations = noAnnotations}+        in (Right (Left (Pdl.SchemaUnion (Pdl.UnionSchema [+          leftMember,+          rightMember]))))))+      Core.TypeList v0 -> Eithers.bind (encode cx g aliases v0) (\inner -> Right (Left (Pdl.SchemaArray inner)))+      Core.TypeLiteral v0 -> case v0 of+        Core.LiteralTypeBinary -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeBytes))+        Core.LiteralTypeBoolean -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeBoolean))+        Core.LiteralTypeFloat v1 -> case v1 of+          Core.FloatTypeFloat32 -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeFloat))+          Core.FloatTypeFloat64 -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeDouble))+          _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected " (Strings.cat2 "float32 or float64" (Strings.cat2 ", found: " (ShowCore.type_ typ))))))+        Core.LiteralTypeInteger v1 -> case v1 of+          Core.IntegerTypeInt32 -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeInt))+          Core.IntegerTypeInt64 -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeLong))+          _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected " (Strings.cat2 "int32 or int64" (Strings.cat2 ", found: " (ShowCore.type_ typ))))))+        Core.LiteralTypeString -> Right (Left (Pdl.SchemaPrimitive Pdl.PrimitiveTypeString))+        _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected " (Strings.cat2 "PDL-supported literal type" (Strings.cat2 ", found: " (ShowCore.type_ typ))))))+      Core.TypeMap v0 -> Eithers.bind (encode cx g aliases (Core.mapTypeValues v0)) (\inner -> Right (Left (Pdl.SchemaMap inner)))+      Core.TypePair v0 -> Eithers.bind (encode cx g aliases (Core.pairTypeFirst v0)) (\firstSchema -> Eithers.bind (encode cx g aliases (Core.pairTypeSecond v0)) (\secondSchema ->+        let firstField =+                Pdl.RecordField {+                  Pdl.recordFieldName = (Pdl.FieldName "first"),+                  Pdl.recordFieldValue = firstSchema,+                  Pdl.recordFieldOptional = False,+                  Pdl.recordFieldDefault = Nothing,+                  Pdl.recordFieldAnnotations = noAnnotations}+            secondField =+                    Pdl.RecordField {+                      Pdl.recordFieldName = (Pdl.FieldName "second"),+                      Pdl.recordFieldValue = secondSchema,+                      Pdl.recordFieldOptional = False,+                      Pdl.recordFieldDefault = Nothing,+                      Pdl.recordFieldAnnotations = noAnnotations}+        in (Right (Right (Pdl.NamedSchemaTypeRecord (Pdl.RecordSchema {+          Pdl.recordSchemaFields = [+            firstField,+            secondField],+          Pdl.recordSchemaIncludes = []}))))))+      Core.TypeSet v0 -> Eithers.bind (encode cx g aliases v0) (\inner -> Right (Left (Pdl.SchemaArray inner)))+      Core.TypeVariable v0 -> Right (Left (Pdl.SchemaNamed (pdlNameForElement aliases True v0)))+      Core.TypeWrap v0 -> encodeType cx g aliases v0+      Core.TypeOptional _ -> Left (Errors.ErrorOther (Errors.OtherError "optionals unexpected at top level"))+      Core.TypeRecord v0 -> Eithers.bind (Eithers.mapList (encodeRecordField cx g aliases) v0) (\rfields -> Right (Right (Pdl.NamedSchemaTypeRecord (Pdl.RecordSchema {+        Pdl.recordSchemaFields = rfields,+        Pdl.recordSchemaIncludes = []}))))+      Core.TypeUnion v0 -> Logic.ifElse (Lists.foldl (\b -> \t -> Logic.and b (Equality.equal (Strip.deannotateType t) Core.TypeUnit)) True (Lists.map (\f -> Core.fieldTypeType f) v0)) (Eithers.bind (Eithers.mapList (encodeEnumField cx g) v0) (\fs -> Right (Right (Pdl.NamedSchemaTypeEnum (Pdl.EnumSchema {+        Pdl.enumSchemaFields = fs}))))) (Eithers.bind (Eithers.mapList (encodeUnionField cx g aliases) v0) (\members -> Right (Left (Pdl.SchemaUnion (Pdl.UnionSchema members)))))+      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat2 "Expected " (Strings.cat2 "PDL-supported type" (Strings.cat2 ", found: " (ShowCore.type_ typ))))))+encodeUnionField :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> Core.FieldType -> Either Errors.Error Pdl.UnionMember+encodeUnionField cx g aliases ft =++      let name = Core.fieldTypeName ft+          typ = Core.fieldTypeType ft+      in (Eithers.bind (getAnns cx g typ) (\anns -> Eithers.bind (encodePossiblyOptionalType cx g aliases typ) (\optResult ->+        let s = Pairs.first optResult+            optional = Pairs.second optResult+            schema =+                    Logic.ifElse optional (Pdl.SchemaUnion (Pdl.UnionSchema (Lists.map (\ms -> simpleUnionMember ms) [+                      Pdl.SchemaNull,+                      s]))) s+        in (Right (Pdl.UnionMember {+          Pdl.unionMemberAlias = (Just (Pdl.FieldName (Core.unName name))),+          Pdl.unionMemberValue = schema,+          Pdl.unionMemberAnnotations = anns})))))+getAnns :: t0 -> Graph.Graph -> Core.Type -> Either Errors.Error Pdl.Annotations+getAnns cx g typ = Eithers.bind (Annotations.getTypeDescription cx g typ) (\r -> Right (doc r))+-- | Compute import aliases for a module's dependencies+importAliasesForModule :: t0 -> Graph.Graph -> Packaging.Module -> Either Errors.Error (M.Map Packaging.ModuleName String)+importAliasesForModule cx g mod =+    Eithers.bind (Analysis.moduleDependencyModuleNames cx g False True True False mod) (\nss -> Right (Maps.fromList (Lists.map (\ns_ -> (ns_, (slashesToDots (Packaging.unModuleName ns_)))) (Sets.toList nss))))+-- | Convert a Hydra module to a map of file paths to PDL schema strings+moduleToPdl :: Packaging.Module -> [Packaging.Definition] -> t0 -> Graph.Graph -> Either Errors.Error (M.Map String String)+moduleToPdl mod defs cx g =+    Eithers.bind (moduleToPegasusSchemas cx g mod defs) (\files -> Right (Maps.fromList (Lists.map (\pair -> (Pairs.first pair, (Serialization.printExpr (Serialization.parenthesize (Serde.schemaFileToExpr (Pairs.second pair)))))) (Maps.toList files))))+-- | Convert a Hydra module and its definitions to PDL schema files+moduleToPegasusSchemas :: t0 -> Graph.Graph -> Packaging.Module -> [Packaging.Definition] -> Either Errors.Error (M.Map String Pdl.SchemaFile)+moduleToPegasusSchemas cx g mod defs =++      let partitioned = Environment.partitionDefinitions defs+          typeDefs = Pairs.first partitioned+      in (Eithers.bind (importAliasesForModule cx g mod) (\aliases -> constructModule cx g aliases mod typeDefs))+-- | Empty PDL annotations+noAnnotations :: Pdl.Annotations+noAnnotations =+    Pdl.Annotations {+      Pdl.annotationsDoc = Nothing,+      Pdl.annotationsDeprecated = False}+-- | Convert a Hydra element name to a PDL qualified name+pdlNameForElement :: M.Map Packaging.ModuleName String -> Bool -> Core.Name -> Pdl.QualifiedName+pdlNameForElement aliases withNs name =++      let qn = Names.qualifyName name+          ns_ = Util.qualifiedNameModuleName qn+          local = Util.qualifiedNameLocal qn+          alias = Optionals.bind ns_ (\n -> Maps.lookup n aliases)+      in Pdl.QualifiedName {+        Pdl.qualifiedNameName = (Pdl.Name local),+        Pdl.qualifiedNameNamespace = (Logic.ifElse withNs (Optionals.map (\a -> Pdl.Namespace a) alias) Nothing)}+-- | Convert a module's namespace to a PDL namespace+pdlNameForModule :: Packaging.Module -> Pdl.Namespace+pdlNameForModule mod = Pdl.Namespace (slashesToDots (Packaging.unModuleName (Packaging.moduleName mod)))+-- | Create a simple union member without an alias+simpleUnionMember :: Pdl.Schema -> Pdl.UnionMember+simpleUnionMember schema =+    Pdl.UnionMember {+      Pdl.unionMemberAlias = Nothing,+      Pdl.unionMemberValue = schema,+      Pdl.unionMemberAnnotations = noAnnotations}+-- | Replace all forward slashes with dots in a string+slashesToDots :: String -> String+slashesToDots s = Strings.intercalate "." (Strings.splitOn "/" s)+toPair :: Packaging.Module -> t0 -> (Pdl.NamedSchema, [Pdl.QualifiedName]) -> (String, Pdl.SchemaFile)+toPair mod aliases schemaPair =++      let schema = Pairs.first schemaPair+          imports = Pairs.second schemaPair+          ns_ = pdlNameForModule mod+          local = Pdl.unName (Pdl.qualifiedNameName (Pdl.namedSchemaQualifiedName schema))+          path =+                  Names.moduleNameToFilePath Util.CaseConventionCamel (File.FileExtension "pdl") (Packaging.ModuleName (Strings.cat2 (Packaging.unModuleName (Packaging.moduleName mod)) (Strings.cat2 "/" local)))+      in (+        path,+        Pdl.SchemaFile {+          Pdl.schemaFileNamespace = ns_,+          Pdl.schemaFilePackage = Nothing,+          Pdl.schemaFileImports = imports,+          Pdl.schemaFileSchemas = [+            schema]})+typeToSchema :: t0 -> Graph.Graph -> M.Map Packaging.ModuleName String -> t1 -> Packaging.TypeDefinition -> Either Errors.Error (Pdl.NamedSchema, [t2])+typeToSchema cx g aliases mod typeDef =++      let typ = Core.typeSchemeBody (Packaging.typeDefinitionBody typeDef)+      in (Eithers.bind (encodeType cx g aliases typ) (\res ->+        let ptype = Eithers.either (\schema -> Pdl.NamedSchemaTypeTyperef schema) (\t -> t) res+        in (Eithers.bind (Annotations.getTypeDescription cx g typ) (\descr ->+          let anns = doc descr+              qname = pdlNameForElement aliases False (Packaging.typeDefinitionName typeDef)+          in (Right (+            Pdl.NamedSchema {+              Pdl.namedSchemaQualifiedName = qname,+              Pdl.namedSchemaType = ptype,+              Pdl.namedSchemaAnnotations = anns},+            []))))))
+ src/main/haskell/Hydra/Pegasus/Language.hs view
@@ -0,0 +1,85 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints for LinkedIn Pegasus (PDL)++module Hydra.Pegasus.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Language constraints for LinkedIn Pegasus (PDL)+pdlLanguage :: Coders.Language+pdlLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.pegasus.pdl"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64]+    termVariants =+        Sets.fromList [+          Variants.TermVariantEither,+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantPair,+          Variants.TermVariantSet,+          Variants.TermVariantWrap,+          Variants.TermVariantOptional,+          Variants.TermVariantRecord,+          Variants.TermVariantInject]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantEither,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantPair,+          Variants.TypeVariantSet,+          Variants.TypeVariantWrap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantRecord,+          Variants.TypeVariantUnion,+          Variants.TypeVariantVariable]+    typePredicate = \_ -> True
+ src/main/haskell/Hydra/Pegasus/Pdl.hs view
@@ -0,0 +1,186 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for PDL (Pegasus Data Language) schemas. Based on the specification at:+-- |   https://linkedin.github.io/rest.li/pdl_schema++module Hydra.Pegasus.Pdl where+import qualified Hydra.Core as Core+import qualified Hydra.Json.Model as Model+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Annotations which can be applied to record fields, aliased union members, enum symbols, or named schemas+data Annotations =+  Annotations {+    annotationsDoc :: (Maybe String),+    annotationsDeprecated :: Bool}+  deriving (Eq, Ord, Read, Show)+_Annotations = Core.Name "hydra.pegasus.pdl.Annotations"+_Annotations_doc = Core.Name "doc"+_Annotations_deprecated = Core.Name "deprecated"+data EnumField =+  EnumField {+    enumFieldName :: EnumFieldName,+    enumFieldAnnotations :: Annotations}+  deriving (Eq, Ord, Read, Show)+_EnumField = Core.Name "hydra.pegasus.pdl.EnumField"+_EnumField_name = Core.Name "name"+_EnumField_annotations = Core.Name "annotations"+newtype EnumFieldName =+  EnumFieldName {+    unEnumFieldName :: String}+  deriving (Eq, Ord, Read, Show)+_EnumFieldName = Core.Name "hydra.pegasus.pdl.EnumFieldName"+data EnumSchema =+  EnumSchema {+    enumSchemaFields :: [EnumField]}+  deriving (Eq, Ord, Read, Show)+_EnumSchema = Core.Name "hydra.pegasus.pdl.EnumSchema"+_EnumSchema_fields = Core.Name "fields"+newtype FieldName =+  FieldName {+    unFieldName :: String}+  deriving (Eq, Ord, Read, Show)+_FieldName = Core.Name "hydra.pegasus.pdl.FieldName"+data NamedSchema =+  NamedSchema {+    namedSchemaQualifiedName :: QualifiedName,+    namedSchemaType :: NamedSchemaType,+    namedSchemaAnnotations :: Annotations}+  deriving (Eq, Ord, Read, Show)+_NamedSchema = Core.Name "hydra.pegasus.pdl.NamedSchema"+_NamedSchema_qualifiedName = Core.Name "qualifiedName"+_NamedSchema_type = Core.Name "type"+_NamedSchema_annotations = Core.Name "annotations"+data NamedSchemaType =+  NamedSchemaTypeRecord RecordSchema |+  NamedSchemaTypeEnum EnumSchema |+  NamedSchemaTypeTyperef Schema+  deriving (Eq, Ord, Read, Show)+_NamedSchemaType = Core.Name "hydra.pegasus.pdl.NamedSchemaType"+_NamedSchemaType_record = Core.Name "record"+_NamedSchemaType_enum = Core.Name "enum"+_NamedSchemaType_typeref = Core.Name "typeref"+newtype Name =+  Name {+    unName :: String}+  deriving (Eq, Ord, Read, Show)+_Name = Core.Name "hydra.pegasus.pdl.Name"+newtype Namespace =+  Namespace {+    unNamespace :: String}+  deriving (Eq, Ord, Read, Show)+_Namespace = Core.Name "hydra.pegasus.pdl.Namespace"+newtype Package =+  Package {+    unPackage :: String}+  deriving (Eq, Ord, Read, Show)+_Package = Core.Name "hydra.pegasus.pdl.Package"+data PrimitiveType =+  PrimitiveTypeBoolean |+  PrimitiveTypeBytes |+  PrimitiveTypeDouble |+  PrimitiveTypeFloat |+  PrimitiveTypeInt |+  PrimitiveTypeLong |+  PrimitiveTypeString+  deriving (Eq, Ord, Read, Show)+_PrimitiveType = Core.Name "hydra.pegasus.pdl.PrimitiveType"+_PrimitiveType_boolean = Core.Name "boolean"+_PrimitiveType_bytes = Core.Name "bytes"+_PrimitiveType_double = Core.Name "double"+_PrimitiveType_float = Core.Name "float"+_PrimitiveType_int = Core.Name "int"+_PrimitiveType_long = Core.Name "long"+_PrimitiveType_string = Core.Name "string"+newtype PropertyKey =+  PropertyKey {+    unPropertyKey :: String}+  deriving (Eq, Ord, Read, Show)+_PropertyKey = Core.Name "hydra.pegasus.pdl.PropertyKey"+data Property =+  Property {+    propertyKey :: PropertyKey,+    propertyValue :: (Maybe Model.Value)}+  deriving (Eq, Ord, Read, Show)+_Property = Core.Name "hydra.pegasus.pdl.Property"+_Property_key = Core.Name "key"+_Property_value = Core.Name "value"+data QualifiedName =+  QualifiedName {+    qualifiedNameName :: Name,+    qualifiedNameNamespace :: (Maybe Namespace)}+  deriving (Eq, Ord, Read, Show)+_QualifiedName = Core.Name "hydra.pegasus.pdl.QualifiedName"+_QualifiedName_name = Core.Name "name"+_QualifiedName_namespace = Core.Name "namespace"+-- | Note: the default value for an enum-valued must be one of the enumerated string symbols+data RecordField =+  RecordField {+    recordFieldName :: FieldName,+    recordFieldValue :: Schema,+    recordFieldOptional :: Bool,+    recordFieldDefault :: (Maybe Model.Value),+    recordFieldAnnotations :: Annotations}+  deriving (Eq, Ord, Read, Show)+_RecordField = Core.Name "hydra.pegasus.pdl.RecordField"+_RecordField_name = Core.Name "name"+_RecordField_value = Core.Name "value"+_RecordField_optional = Core.Name "optional"+_RecordField_default = Core.Name "default"+_RecordField_annotations = Core.Name "annotations"+-- | Note: all included schemas must be record schemas+data RecordSchema =+  RecordSchema {+    recordSchemaFields :: [RecordField],+    recordSchemaIncludes :: [NamedSchema]}+  deriving (Eq, Ord, Read, Show)+_RecordSchema = Core.Name "hydra.pegasus.pdl.RecordSchema"+_RecordSchema_fields = Core.Name "fields"+_RecordSchema_includes = Core.Name "includes"+data Schema =+  SchemaArray Schema |+  SchemaFixed Int |+  SchemaInline NamedSchema |+  SchemaMap Schema |+  SchemaNamed QualifiedName |+  SchemaNull |+  SchemaPrimitive PrimitiveType |+  SchemaUnion UnionSchema+  deriving (Eq, Ord, Read, Show)+_Schema = Core.Name "hydra.pegasus.pdl.Schema"+_Schema_array = Core.Name "array"+_Schema_fixed = Core.Name "fixed"+_Schema_inline = Core.Name "inline"+_Schema_map = Core.Name "map"+_Schema_named = Core.Name "named"+_Schema_null = Core.Name "null"+_Schema_primitive = Core.Name "primitive"+_Schema_union = Core.Name "union"+data SchemaFile =+  SchemaFile {+    schemaFileNamespace :: Namespace,+    schemaFilePackage :: (Maybe Package),+    schemaFileImports :: [QualifiedName],+    schemaFileSchemas :: [NamedSchema]}+  deriving (Eq, Ord, Read, Show)+_SchemaFile = Core.Name "hydra.pegasus.pdl.SchemaFile"+_SchemaFile_namespace = Core.Name "namespace"+_SchemaFile_package = Core.Name "package"+_SchemaFile_imports = Core.Name "imports"+_SchemaFile_schemas = Core.Name "schemas"+-- | Note: annotations are only available for aliased members+data UnionMember =+  UnionMember {+    unionMemberAlias :: (Maybe FieldName),+    unionMemberValue :: Schema,+    unionMemberAnnotations :: Annotations}+  deriving (Eq, Ord, Read, Show)+_UnionMember = Core.Name "hydra.pegasus.pdl.UnionMember"+_UnionMember_alias = Core.Name "alias"+_UnionMember_value = Core.Name "value"+_UnionMember_annotations = Core.Name "annotations"+-- | Note: unions are not allowed as member types of other unions+newtype UnionSchema =+  UnionSchema {+    unUnionSchema :: [UnionMember]}+  deriving (Eq, Ord, Read, Show)+_UnionSchema = Core.Name "hydra.pegasus.pdl.UnionSchema"
+ src/main/haskell/Hydra/Pegasus/Serde.hs view
@@ -0,0 +1,173 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Serialization functions for converting Pegasus PDL AST to abstract expressions++module Hydra.Pegasus.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Pegasus.Pdl as Pdl+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Convert PDL annotations to an optional expression (doc comment)+annotationsToExpr :: Pdl.Annotations -> Maybe Ast.Expr+annotationsToExpr anns =++      let d = Pdl.annotationsDoc anns+      in (Optionals.map (\s -> Serialization.cst (Formatting.javaStyleComment s)) d)+-- | Convert a PDL enum field to an expression+enumFieldToExpr :: Pdl.EnumField -> Ast.Expr+enumFieldToExpr ef =++      let name = Pdl.unEnumFieldName (Pdl.enumFieldName ef)+          anns = Pdl.enumFieldAnnotations ef+      in (withAnnotations anns (Serialization.cst name))+-- | Convert a qualified name to an import expression+importToExpr :: Pdl.QualifiedName -> Ast.Expr+importToExpr qn =+    Serialization.spaceSep [+      Serialization.cst "import",+      (qualifiedNameToExpr qn)]+-- | Convert a named schema to an expression+namedSchemaToExpr :: Pdl.NamedSchema -> Ast.Expr+namedSchemaToExpr ns =++      let qn = Pdl.namedSchemaQualifiedName ns+          t = Pdl.namedSchemaType ns+          anns = Pdl.namedSchemaAnnotations ns+      in (withAnnotations anns (case t of+        Pdl.NamedSchemaTypeRecord v0 ->+          let fields = Pdl.recordSchemaFields v0+          in (Serialization.spaceSep [+            Serialization.cst "record",+            (qualifiedNameToExpr qn),+            (Serialization.curlyBracesList Nothing Serialization.fullBlockStyle (Lists.map recordFieldToExpr fields))])+        Pdl.NamedSchemaTypeEnum v0 ->+          let fields = Pdl.enumSchemaFields v0+          in (Serialization.spaceSep [+            Serialization.cst "enum",+            (qualifiedNameToExpr qn),+            (Serialization.curlyBracesList Nothing Serialization.fullBlockStyle (Lists.map enumFieldToExpr fields))])+        Pdl.NamedSchemaTypeTyperef v0 -> Serialization.spaceSep [+          Serialization.cst "typeref",+          (qualifiedNameToExpr qn),+          (Serialization.cst "="),+          (schemaToExpr v0)]))+-- | Convert a primitive type to an expression+primitiveTypeToExpr :: Pdl.PrimitiveType -> Ast.Expr+primitiveTypeToExpr pt =+    Serialization.cst (case pt of+      Pdl.PrimitiveTypeBoolean -> "boolean"+      Pdl.PrimitiveTypeBytes -> "bytes"+      Pdl.PrimitiveTypeDouble -> "double"+      Pdl.PrimitiveTypeFloat -> "float"+      Pdl.PrimitiveTypeInt -> "int"+      Pdl.PrimitiveTypeLong -> "long"+      Pdl.PrimitiveTypeString -> "string")+-- | Convert a qualified name to an expression+qualifiedNameToExpr :: Pdl.QualifiedName -> Ast.Expr+qualifiedNameToExpr qn =++      let name = Pdl.unName (Pdl.qualifiedNameName qn)+          ns = Pdl.qualifiedNameNamespace qn+          parts =+                  Optionals.cat [+                    Optionals.map (\n -> Pdl.unNamespace n) ns,+                    (Optionals.pure name)]+      in (Serialization.cst (Strings.intercalate "." parts))+-- | Convert a record field to an expression+recordFieldToExpr :: Pdl.RecordField -> Ast.Expr+recordFieldToExpr rf =++      let name = Pdl.unFieldName (Pdl.recordFieldName rf)+          schema = Pdl.recordFieldValue rf+          optional = Pdl.recordFieldOptional rf+          anns = Pdl.recordFieldAnnotations rf+      in (withAnnotations anns (Serialization.spaceSep (Optionals.cat [+        Optionals.pure (Serialization.cst (Strings.cat2 name ":")),+        (Logic.ifElse optional (Optionals.pure (Serialization.cst "optional")) Nothing),+        (Optionals.pure (schemaToExpr schema))])))+-- | Convert a schema file to an expression+schemaFileToExpr :: Pdl.SchemaFile -> Ast.Expr+schemaFileToExpr sf =++      let ns = Pdl.unNamespace (Pdl.schemaFileNamespace sf)+          pkg = Pdl.schemaFilePackage sf+          imports = Pdl.schemaFileImports sf+          schemas = Pdl.schemaFileSchemas sf+          namespaceSec =+                  Optionals.pure (Serialization.spaceSep [+                    Serialization.cst "namespace",+                    (Serialization.cst ns)])+          packageSec =+                  Optionals.map (\p -> Serialization.spaceSep [+                    Serialization.cst "package",+                    (Serialization.cst (Pdl.unPackage p))]) pkg+          importsSec =+                  Logic.ifElse (Lists.null imports) Nothing (Optionals.pure (Serialization.newlineSep (Lists.map importToExpr imports)))+          schemaSecs = Lists.map (\s -> Optionals.pure (namedSchemaToExpr s)) schemas+      in (Serialization.doubleNewlineSep (Optionals.cat (Lists.concat [+        [+          namespaceSec,+          packageSec,+          importsSec],+        schemaSecs])))+-- | Convert a schema to an expression+schemaToExpr :: Pdl.Schema -> Ast.Expr+schemaToExpr schema =+    case schema of+      Pdl.SchemaArray v0 -> Serialization.noSep [+        Serialization.cst "array",+        (Serialization.bracketList Serialization.inlineStyle [+          schemaToExpr v0])]+      Pdl.SchemaMap v0 -> Serialization.noSep [+        Serialization.cst "map",+        (Serialization.bracketList Serialization.inlineStyle [+          Serialization.cst "string",+          (schemaToExpr v0)])]+      Pdl.SchemaNamed v0 -> qualifiedNameToExpr v0+      Pdl.SchemaNull -> Serialization.cst "null"+      Pdl.SchemaPrimitive v0 -> primitiveTypeToExpr v0+      Pdl.SchemaUnion v0 -> Serialization.noSep [+        Serialization.cst "union",+        (Serialization.bracketList Serialization.fullBlockStyle (Lists.map unionMemberToExpr (Pdl.unUnionSchema v0)))]+-- | Convert a union member to an expression+unionMemberToExpr :: Pdl.UnionMember -> Ast.Expr+unionMemberToExpr um =++      let alias = Pdl.unionMemberAlias um+          schema = Pdl.unionMemberValue um+          anns = Pdl.unionMemberAnnotations um+      in (withAnnotations anns (Serialization.spaceSep (Optionals.cat [+        Optionals.map (\fn -> Serialization.cst (Strings.cat2 (Pdl.unFieldName fn) ":")) alias,+        (Optionals.pure (schemaToExpr schema))])))+-- | Prepend annotations (doc comment) to an expression+withAnnotations :: Pdl.Annotations -> Ast.Expr -> Ast.Expr+withAnnotations anns expr =+    Serialization.newlineSep (Optionals.cat [+      annotationsToExpr anns,+      (Optionals.pure expr)])
+ src/main/haskell/Hydra/Protobuf/Any.hs view
@@ -0,0 +1,19 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Based on https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/any.proto++module Hydra.Protobuf.Any where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.ByteString as B+-- | `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message.+data Any =+  Any {+    -- | A URL/resource name that uniquely identifies the type of the serialized protocol buffer message.+    anyTypeUrl :: String,+    -- | Must be a valid serialized protocol buffer of the above specified type.+    anyValue :: B.ByteString}+  deriving (Eq, Ord, Read, Show)+_Any = Core.Name "hydra.protobuf.any.Any"+_Any_typeUrl = Core.Name "typeUrl"+_Any_value = Core.Name "value"
+ src/main/haskell/Hydra/Protobuf/Coder.hs view
@@ -0,0 +1,543 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Protobuf code generator: converts Hydra modules to Protocol Buffers v3 definitions++module Hydra.Protobuf.Coder where+import qualified Hydra.Adapt as Adapt+import qualified Hydra.Analysis as Analysis+import qualified Hydra.Annotations as Annotations+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Constants as Constants+import qualified Hydra.Core as Core+import qualified Hydra.Decode.Core as DecodeCore+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Extract.Core as ExtractCore+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Math as Math+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Predicates as Predicates+import qualified Hydra.Protobuf.Environment as ProtobufEnvironment+import qualified Hydra.Protobuf.Language as Language+import qualified Hydra.Protobuf.Proto3 as Proto3+import qualified Hydra.Protobuf.Serde as Serde+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Rewriting as Rewriting+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Show.Core as ShowCore+import qualified Hydra.Show.Errors as ShowErrors+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variables as Variables+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+import qualified Data.Set as S+-- | Collect all structural type references (Either, Pair) from a list of types+collectStructuralTypes :: [Core.Type] -> S.Set ProtobufEnvironment.StructuralTypeRef+collectStructuralTypes types =+    Lists.foldl (\acc -> \t -> Sets.union acc (collectStructuralTypes_collectFromType t)) Sets.empty types+-- | Collect structural type references from a single type+collectStructuralTypes_collectFromType :: Core.Type -> S.Set ProtobufEnvironment.StructuralTypeRef+collectStructuralTypes_collectFromType typ =+    Rewriting.foldOverType Coders.TraversalOrderPre (\acc -> \t ->+      let st = simplifyType t+      in case st of+        Core.TypeEither v0 -> Sets.insert (ProtobufEnvironment.StructuralTypeRefEither (Core.eitherTypeLeft v0, (Core.eitherTypeRight v0))) acc+        Core.TypePair v0 -> Sets.insert (ProtobufEnvironment.StructuralTypeRefPair (Core.pairTypeFirst v0, (Core.pairTypeSecond v0))) acc+        _ -> acc) Sets.empty typ+-- | Construct a Protobuf file from a Hydra module and its type definitions+constructModule :: ProtobufEnvironment.EncoderState -> Graph.Graph -> Packaging.Module -> [Packaging.TypeDefinition] -> Either Errors.Error Proto3.ProtoFile+constructModule cx g mod typeDefs =++      let ns_ = Packaging.moduleName mod+          desc = Optionals.bind (Packaging.moduleMetadata mod) (\em -> Packaging.entityMetadataDescription em)+          toDef =+                  \td ->+                    let name = Packaging.typeDefinitionName td+                        typ = Core.typeSchemeBody (Packaging.typeDefinitionBody td)+                        encodeDefEither = \n -> \t -> encodeDefinition cx g ns_ n t+                        flatTyp = flattenType typ+                        enc = encodeDefEither name+                    in case (Strip.deannotateType flatTyp) of+                      Core.TypeVariable _ -> enc flatTyp+                      _ -> Eithers.bind (Adapt.adaptTypeForLanguage Language.protobufLanguage flatTyp) (\adaptedType -> enc adaptedType)+          types = Lists.map (\td -> Core.typeSchemeBody (Packaging.typeDefinitionBody td)) typeDefs+          structRefs = collectStructuralTypes types+          javaOptions =+                  [+                    Proto3.Option {+                      Proto3.optionName = javaMultipleFilesOptionName,+                      Proto3.optionValue = (Proto3.ValueBoolean True)},+                    Proto3.Option {+                      Proto3.optionName = javaPackageOptionName,+                      Proto3.optionValue = (Proto3.ValueString (Proto3.unPackageName (namespaceToPackageName ns_)))}]+          descOption =+                  Proto3.Option {+                    Proto3.optionName = Serde.descriptionOptionName,+                    Proto3.optionValue = (Proto3.ValueString (Strings.cat2 (Optionals.cases desc "" (\d -> Strings.cat2 d "\n\n")) Constants.warningAutoGeneratedFile))}+          checkFieldType_wrapper =+                  \typ -> case (Strip.deannotateType typ) of+                    Core.TypeOptional v0 -> case (Strip.deannotateType v0) of+                      Core.TypeLiteral _ -> True+                      _ -> False+                    _ -> False+          checkFieldType_empty = \typ -> Predicates.isUnitType typ+          checkFields =+                  \checkType -> \checkFieldType -> \ts -> Lists.foldl (\b -> \t -> Logic.or b (Rewriting.foldOverType Coders.TraversalOrderPre (\b2 -> \t2 -> Logic.or b2 (+                    let checkResult = checkType t2+                    in (Optionals.cases checkResult (case t2 of+                      Core.TypeRecord v0 -> Lists.foldl (\b3 -> \f -> Logic.or b3 (checkFieldType (Strip.deannotateType (Core.fieldTypeType f)))) False v0+                      Core.TypeUnion v0 -> Lists.foldl (\b3 -> \f -> Logic.or b3 (checkFieldType (Strip.deannotateType (Core.fieldTypeType f)))) False v0+                      _ -> False) (\b3 -> b3)))) False t)) False ts+          wrapperImport =+                  Logic.ifElse (checkFields (\_ -> Nothing) checkFieldType_wrapper types) [+                    Proto3.FileReference "google/protobuf/wrappers.proto"] []+          emptyCheckType = \typ -> Logic.ifElse (isEnumDefinition typ) (Just False) Nothing+          emptyImport =+                  Logic.ifElse (checkFields emptyCheckType checkFieldType_empty types) [+                    Proto3.FileReference "google/protobuf/empty.proto"] []+      in (Eithers.bind (Analysis.moduleDependencyModuleNames (ProtobufEnvironment.encoderStateContext cx) g True False False False mod) (\schemaImports -> Eithers.bind (Eithers.mapList toDef typeDefs) (\definitions ->+        let schemaImportList = Lists.map (\n -> namespaceToFileReference n) (Sets.toList schemaImports)+        in (Eithers.bind (mapAccumResult (\cx0 -> \ref -> generateStructuralTypeMessage cx0 g ns_ ref) cx (Sets.toList structRefs)) (\helperResult ->+          let helperDefs = Pairs.first helperResult+          in (Right (Proto3.ProtoFile {+            Proto3.protoFilePackage = (namespaceToPackageName ns_),+            Proto3.protoFileImports = (Lists.concat [+              schemaImportList,+              wrapperImport,+              emptyImport]),+            Proto3.protoFileTypes = (Lists.concat [+              helperDefs,+              definitions]),+            Proto3.protoFileOptions = (Lists.cons descOption javaOptions)})))))))+-- | Encode a Hydra type as a Protobuf definition+encodeDefinition :: ProtobufEnvironment.EncoderState -> Graph.Graph -> Packaging.ModuleName -> Core.Name -> Core.Type -> Either Errors.Error Proto3.Definition+encodeDefinition cx g localNs name typ =++      let cx1 =+              ProtobufEnvironment.EncoderState {+                ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx),+                ProtobufEnvironment.encoderStateFieldIndex = 0}+          cx2 =+                  Pairs.second (+                    ProtobufEnvironment.encoderStateFieldIndex cx1,+                    ProtobufEnvironment.EncoderState {+                      ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx1),+                      ProtobufEnvironment.encoderStateFieldIndex = (Math.add (ProtobufEnvironment.encoderStateFieldIndex cx1) 1)})+          wrapAsRecordType =+                  \t -> Core.TypeRecord [+                    Core.FieldType {+                      Core.fieldTypeName = (Core.Name "value"),+                      Core.fieldTypeType = t}]+          toEitherString = \result -> result+          encode =+                  \cx0 -> \options -> \t -> case (simplifyType t) of+                    Core.TypeRecord v0 -> Eithers.map (\md -> Proto3.DefinitionMessage md) (toEitherString (encodeRecordType cx0 g localNs options name v0))+                    Core.TypeUnion v0 -> Logic.ifElse (isEnumDefinition t) (Eithers.map (\ed -> Proto3.DefinitionEnum ed) (toEitherString (encodeEnumDefinition cx0 g options name v0))) (encode cx0 options (wrapAsRecordType (Core.TypeUnion v0)))+                    _ -> encode cx0 options (wrapAsRecordType t)+      in (Eithers.bind (toEitherString (findOptions cx g typ)) (\options -> encode cx2 options typ))+-- | Encode a Hydra union type as a Protobuf enum definition+encodeEnumDefinition :: ProtobufEnvironment.EncoderState -> Graph.Graph -> [Proto3.Option] -> Core.Name -> [Core.FieldType] -> Either Errors.Error Proto3.EnumDefinition+encodeEnumDefinition cx g options tname fts =++      let unspecifiedField =+              Proto3.EnumValue {+                Proto3.enumValueName = (encodeEnumValueName tname (Core.Name "unspecified")),+                Proto3.enumValueNumber = 0,+                Proto3.enumValueOptions = []}+          encodeEnumField =+                  \field -> \idx ->+                    let fname = Core.fieldTypeName field+                        ftype = Core.fieldTypeType field+                    in (Eithers.bind (findOptions cx g ftype) (\opts -> Right (Proto3.EnumValue {+                      Proto3.enumValueName = (encodeEnumValueName tname fname),+                      Proto3.enumValueNumber = idx,+                      Proto3.enumValueOptions = opts})))+          indices = Math.range 1 (Lists.length fts)+      in (Eithers.bind (Eithers.mapList (\p -> encodeEnumField (Pairs.first p) (Pairs.second p)) (Lists.zip fts indices)) (\values -> Right (Proto3.EnumDefinition {+        Proto3.enumDefinitionName = (encodeTypeName tname),+        Proto3.enumDefinitionValues = (Lists.cons unspecifiedField values),+        Proto3.enumDefinitionOptions = options})))+-- | Encode an enum value name from type name and field name+encodeEnumValueName :: Core.Name -> Core.Name -> Proto3.EnumValueName+encodeEnumValueName tname fname =++      let prefix = Formatting.nonAlnumToUnderscores (Formatting.convertCaseCamelToUpperSnake (Names.localNameOf tname))+          suffix = Formatting.nonAlnumToUnderscores (Formatting.convertCaseCamelToUpperSnake (Core.unName fname))+      in (Proto3.EnumValueName (Strings.cat [+        prefix,+        "_",+        suffix]))+-- | Encode a field name, optionally preserving the original case+encodeFieldName :: Bool -> Core.Name -> Proto3.FieldName+encodeFieldName preserve name =+    Proto3.FieldName (Logic.ifElse preserve (Core.unName name) (Formatting.convertCaseCamelToLowerSnake (Core.unName name)))+-- | Encode a Hydra field type as a Protobuf field+encodeFieldType :: ProtobufEnvironment.EncoderState -> Graph.Graph -> Packaging.ModuleName -> Core.FieldType -> Either Errors.Error (Proto3.Field, ProtobufEnvironment.EncoderState)+encodeFieldType cx g localNs ft =++      let fname = Core.fieldTypeName ft+          ftype = Core.fieldTypeType ft+          encodeType_ =+                  \cx0 -> \g0 -> \ns0 -> \typ -> case (simplifyType typ) of+                    Core.TypeEither v0 ->+                      let ref = ProtobufEnvironment.StructuralTypeRefEither (Core.eitherTypeLeft v0, (Core.eitherTypeRight v0))+                      in (Right (Proto3.FieldTypeSimple (Proto3.SimpleTypeReference (structuralTypeName ns0 ref))))+                    Core.TypePair v0 ->+                      let ref = ProtobufEnvironment.StructuralTypeRefPair (Core.pairTypeFirst v0, (Core.pairTypeSecond v0))+                      in (Right (Proto3.FieldTypeSimple (Proto3.SimpleTypeReference (structuralTypeName ns0 ref))))+                    Core.TypeList v0 -> Eithers.map (\st -> Proto3.FieldTypeRepeated st) (encodeSimpleType_ cx0 g0 ns0 True v0)+                    Core.TypeSet v0 -> Eithers.map (\st -> Proto3.FieldTypeRepeated st) (encodeSimpleType_ cx0 g0 ns0 True v0)+                    Core.TypeMap v0 -> Eithers.bind (encodeSimpleType_ cx0 g0 ns0 False (Core.mapTypeKeys v0)) (\kt -> Eithers.bind (encodeSimpleType_ cx0 g0 ns0 True (Core.mapTypeValues v0)) (\vt -> Right (Proto3.FieldTypeMap (Proto3.MapType {+                      Proto3.mapTypeKeys = kt,+                      Proto3.mapTypeValues = vt}))))+                    Core.TypeOptional v0 -> case (Strip.deannotateType v0) of+                      Core.TypeLiteral v1 -> Eithers.map (\st -> Proto3.FieldTypeSimple st) (encodeScalarTypeWrapped cx0 v1)+                      _ -> encodeType_ cx0 g0 ns0 v0+                    Core.TypeUnion v0 -> Eithers.bind (mapAccumResult (\cx_ -> \f -> encodeFieldType cx_ g0 ns0 f) cx0 v0) (\pfields ->+                      let fields_ = Pairs.first pfields+                      in (Right (Proto3.FieldTypeOneof fields_)))+                    _ -> Eithers.map (\st -> Proto3.FieldTypeSimple st) (encodeSimpleType_ cx0 g0 ns0 True typ)+          encodeSimpleType_ =+                  \cx0 -> \g0 -> \ns0 -> \noms -> \typ ->+                    let forNominal = \name -> Right (Proto3.SimpleTypeReference (encodeTypeReference ns0 name))+                    in case (simplifyType typ) of+                      Core.TypeLiteral v0 -> Eithers.map (\st -> Proto3.SimpleTypeScalar st) (encodeScalarType cx0 v0)+                      Core.TypeRecord _ -> unexpectedE cx0 "named type reference" "anonymous record type"+                      Core.TypeUnion _ -> unexpectedE cx0 "named type reference" "anonymous union type"+                      Core.TypeUnit -> Right (Proto3.SimpleTypeReference (Proto3.TypeName "google.protobuf.Empty"))+                      Core.TypeVariable v0 -> Logic.ifElse noms (forNominal v0) (Eithers.bind (Lexical.requireBinding g0 v0) (\el ->+                        let term = Core.bindingTerm el+                        in (Eithers.bind (Eithers.bimap (\de -> Errors.ErrorOther (Errors.OtherError (Errors.unDecodingError de))) (\t -> t) (DecodeCore.type_ g0 term)) (\resolvedTyp -> encodeSimpleType_ cx0 g0 ns0 noms resolvedTyp))))+                      _ -> unexpectedE cx0 "simple type" (ShowCore.type_ (Strip.removeTypeAnnotations typ))+      in (Eithers.bind (findOptions cx g ftype) (\options -> Eithers.bind (encodeType_ cx g localNs ftype) (\ft_ ->+        let idxPair =+                (+                  ProtobufEnvironment.encoderStateFieldIndex cx,+                  ProtobufEnvironment.EncoderState {+                    ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx),+                    ProtobufEnvironment.encoderStateFieldIndex = (Math.add (ProtobufEnvironment.encoderStateFieldIndex cx) 1)})+            idx = Pairs.first idxPair+            cx1 = Pairs.second idxPair+        in (Eithers.bind (readBooleanAnnotation cx g Constants.keyPreserveFieldName ftype) (\preserve -> Right (+          Proto3.Field {+            Proto3.fieldName = (encodeFieldName preserve fname),+            Proto3.fieldJsonName = Nothing,+            Proto3.fieldType = ft_,+            Proto3.fieldNumber = idx,+            Proto3.fieldOptions = options},+          cx1))))))+-- | Encode a Hydra record type as a Protobuf message definition+encodeRecordType :: ProtobufEnvironment.EncoderState -> Graph.Graph -> Packaging.ModuleName -> [Proto3.Option] -> Core.Name -> [Core.FieldType] -> Either Errors.Error Proto3.MessageDefinition+encodeRecordType cx g localNs options tname fts =+    Eithers.bind (mapAccumResult (\cx_ -> \f -> encodeFieldType cx_ g localNs f) cx fts) (\result ->+      let pfields = Pairs.first result+      in (Right (Proto3.MessageDefinition {+        Proto3.messageDefinitionName = (encodeTypeName tname),+        Proto3.messageDefinitionFields = pfields,+        Proto3.messageDefinitionOptions = options})))+-- | Encode a Hydra literal type as a Protobuf scalar type+encodeScalarType :: t0 -> Core.LiteralType -> Either Errors.Error Proto3.ScalarType+encodeScalarType cx lt =+    case lt of+      Core.LiteralTypeBinary -> Right Proto3.ScalarTypeBytes+      Core.LiteralTypeBoolean -> Right Proto3.ScalarTypeBool+      Core.LiteralTypeFloat v0 -> case v0 of+        Core.FloatTypeFloat32 -> Right Proto3.ScalarTypeFloat+        Core.FloatTypeFloat64 -> Right Proto3.ScalarTypeDouble+        _ -> unexpectedE cx "32-bit or 64-bit floating-point type" (ShowCore.floatType v0)+      Core.LiteralTypeInteger v0 -> case v0 of+        Core.IntegerTypeInt32 -> Right Proto3.ScalarTypeInt32+        Core.IntegerTypeInt64 -> Right Proto3.ScalarTypeInt64+        Core.IntegerTypeUint32 -> Right Proto3.ScalarTypeUint32+        Core.IntegerTypeUint64 -> Right Proto3.ScalarTypeUint64+        _ -> unexpectedE cx "32-bit or 64-bit integer type" (ShowCore.integerType v0)+      Core.LiteralTypeString -> Right Proto3.ScalarTypeString+      _ -> unexpectedE cx "supported literal type" (ShowCore.literalType lt)+-- | Encode a Hydra literal type as a wrapped Protobuf type (for optional scalars)+encodeScalarTypeWrapped :: t0 -> Core.LiteralType -> Either Errors.Error Proto3.SimpleType+encodeScalarTypeWrapped cx lt =++      let toType =+              \label -> Right (Proto3.SimpleTypeReference (Proto3.TypeName (Strings.cat [+                "google.protobuf.",+                label,+                "Value"])))+      in case lt of+        Core.LiteralTypeBinary -> toType "Bytes"+        Core.LiteralTypeBoolean -> toType "Bool"+        Core.LiteralTypeFloat v0 -> case v0 of+          Core.FloatTypeFloat32 -> toType "Float"+          Core.FloatTypeFloat64 -> toType "Double"+          _ -> unexpectedE cx "32-bit or 64-bit floating-point type" (ShowCore.floatType v0)+        Core.LiteralTypeInteger v0 -> case v0 of+          Core.IntegerTypeInt32 -> toType "Int32"+          Core.IntegerTypeInt64 -> toType "Int64"+          Core.IntegerTypeUint32 -> toType "UInt32"+          Core.IntegerTypeUint64 -> toType "UInt64"+          _ -> unexpectedE cx "32-bit or 64-bit integer type" (ShowCore.integerType v0)+        Core.LiteralTypeString -> toType "String"+        _ -> unexpectedE cx "supported literal type" (ShowCore.literalType lt)+-- | Encode a simple type for helper message fields+encodeSimpleTypeForHelper :: t0 -> Packaging.ModuleName -> Core.Type -> Either Errors.Error Proto3.SimpleType+encodeSimpleTypeForHelper cx localNs typ =++      let forNominal = \name -> Right (Proto3.SimpleTypeReference (encodeTypeReference localNs name))+      in case (simplifyType typ) of+        Core.TypeLiteral v0 -> Eithers.map (\st -> Proto3.SimpleTypeScalar st) (encodeScalarType cx v0)+        Core.TypeRecord _ -> unexpectedE cx "named type reference" "anonymous record type"+        Core.TypeUnion _ -> unexpectedE cx "named type reference" "anonymous union type"+        Core.TypeUnit -> Right (Proto3.SimpleTypeReference (Proto3.TypeName "google.protobuf.Empty"))+        Core.TypeVariable v0 -> forNominal v0+        _ -> unexpectedE cx "simple type in structural type helper" (ShowCore.type_ (Strip.removeTypeAnnotations typ))+-- | Encode a Hydra type name as a Protobuf type name+encodeTypeName :: Core.Name -> Proto3.TypeName+encodeTypeName name = Proto3.TypeName (Names.localNameOf name)+-- | Encode a Hydra name as a Protobuf type reference+encodeTypeReference :: Packaging.ModuleName -> Core.Name -> Proto3.TypeName+encodeTypeReference localNs name =++      let qn = Names.qualifyName name+          local = Util.qualifiedNameLocal qn+          ns_ = Util.qualifiedNameModuleName qn+          localNsParts = Optionals.fromOptional [] (Lists.maybeInit (Strings.splitOn "." (Packaging.unModuleName localNs)))+      in (Proto3.TypeName (Optionals.cases ns_ local (\nsVal ->+        let nsParts = Optionals.fromOptional [] (Lists.maybeInit (Strings.splitOn "." (Packaging.unModuleName nsVal)))+        in (Logic.ifElse (Equality.equal nsParts localNsParts) local (Strings.intercalate "." (Lists.concat [+          nsParts,+          [+            local]]))))))+err :: t0 -> String -> Either Errors.Error t1+err cx msg = Left (Errors.ErrorOther (Errors.OtherError msg))+-- | Find Protobuf options for a type (description and deprecated)+findOptions :: ProtobufEnvironment.EncoderState -> Graph.Graph -> Core.Type -> Either Errors.Error [Proto3.Option]+findOptions cx g typ =+    Eithers.bind (Annotations.getTypeDescription (ProtobufEnvironment.encoderStateContext cx) g typ) (\mdesc -> Eithers.bind (readBooleanAnnotation cx g Constants.keyDeprecated typ) (\bdep ->+      let mdescAnn =+              Optionals.map (\desc_ -> Proto3.Option {+                Proto3.optionName = Serde.descriptionOptionName,+                Proto3.optionValue = (Proto3.ValueString desc_)}) mdesc+          mdepAnn =+                  Logic.ifElse bdep (Just (Proto3.Option {+                    Proto3.optionName = "deprecated",+                    Proto3.optionValue = (Proto3.ValueBoolean True)})) Nothing+      in (Right (Optionals.cat [+        mdescAnn,+        mdepAnn]))))+-- | Eliminate type lambdas and type applications, replacing type variables with the string type+flattenType :: Core.Type -> Core.Type+flattenType typ =+    Rewriting.rewriteType (\recurse -> \t -> case t of+      Core.TypeForall v0 -> recurse (Variables.replaceFreeTypeVariable (Core.forallTypeParameter v0) (Core.TypeLiteral Core.LiteralTypeString) (Core.forallTypeBody v0))+      Core.TypeApplication v0 -> recurse (Core.applicationTypeFunction v0)+      _ -> recurse t) typ+fromEitherString :: t0 -> Either String t1 -> Either Errors.Error t1+fromEitherString cx e = Eithers.bimap (\msg -> Errors.ErrorOther (Errors.OtherError msg)) (\a -> a) e+-- | Generate a helper message definition for a structural type+generateStructuralTypeMessage :: ProtobufEnvironment.EncoderState -> t0 -> Packaging.ModuleName -> ProtobufEnvironment.StructuralTypeRef -> Either Errors.Error (Proto3.Definition, ProtobufEnvironment.EncoderState)+generateStructuralTypeMessage cx g localNs ref =++      let cx1 =+              ProtobufEnvironment.EncoderState {+                ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx),+                ProtobufEnvironment.encoderStateFieldIndex = 0}+          cx2 =+                  Pairs.second (+                    ProtobufEnvironment.encoderStateFieldIndex cx1,+                    ProtobufEnvironment.EncoderState {+                      ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx1),+                      ProtobufEnvironment.encoderStateFieldIndex = (Math.add (ProtobufEnvironment.encoderStateFieldIndex cx1) 1)})+          makeField =+                  \cx0 -> \fname -> \ftyp -> Eithers.bind (encodeSimpleTypeForHelper cx0 localNs ftyp) (\ft ->+                    let idxPair =+                            (+                              ProtobufEnvironment.encoderStateFieldIndex cx0,+                              ProtobufEnvironment.EncoderState {+                                ProtobufEnvironment.encoderStateContext = (ProtobufEnvironment.encoderStateContext cx0),+                                ProtobufEnvironment.encoderStateFieldIndex = (Math.add (ProtobufEnvironment.encoderStateFieldIndex cx0) 1)})+                        idx = Pairs.first idxPair+                        cx1_ = Pairs.second idxPair+                    in (Right (+                      Proto3.Field {+                        Proto3.fieldName = (Proto3.FieldName fname),+                        Proto3.fieldJsonName = Nothing,+                        Proto3.fieldType = (Proto3.FieldTypeSimple ft),+                        Proto3.fieldNumber = idx,+                        Proto3.fieldOptions = []},+                      cx1_)))+      in case ref of+        ProtobufEnvironment.StructuralTypeRefEither v0 ->+          let lt = Pairs.first v0+              rt = Pairs.second v0+          in (Eithers.bind (makeField cx2 "left" lt) (\leftResult ->+            let leftField = Pairs.first leftResult+                cx3 = Pairs.second leftResult+            in (Eithers.bind (makeField cx3 "right" rt) (\rightResult ->+              let rightField = Pairs.first rightResult+                  cx4 = Pairs.second rightResult+              in (Right (+                Proto3.DefinitionMessage (Proto3.MessageDefinition {+                  Proto3.messageDefinitionName = (structuralTypeName localNs ref),+                  Proto3.messageDefinitionFields = [+                    leftField,+                    rightField],+                  Proto3.messageDefinitionOptions = []}),+                cx4))))))+        ProtobufEnvironment.StructuralTypeRefPair v0 ->+          let ft = Pairs.first v0+              st = Pairs.second v0+          in (Eithers.bind (makeField cx2 "first" ft) (\firstResult ->+            let firstField = Pairs.first firstResult+                cx3 = Pairs.second firstResult+            in (Eithers.bind (makeField cx3 "second" st) (\secondResult ->+              let secondField = Pairs.first secondResult+                  cx4 = Pairs.second secondResult+              in (Right (+                Proto3.DefinitionMessage (Proto3.MessageDefinition {+                  Proto3.messageDefinitionName = (structuralTypeName localNs ref),+                  Proto3.messageDefinitionFields = [+                    firstField,+                    secondField],+                  Proto3.messageDefinitionOptions = []}),+                cx4))))))+-- | Check if a type is an enum definition+isEnumDefinition :: Core.Type -> Bool+isEnumDefinition typ =+    case (simplifyType typ) of+      Core.TypeUnion v0 -> isEnumFields v0+      _ -> False+-- | Check if all fields are unit types (i.e., this is an enum)+isEnumFields :: [Core.FieldType] -> Bool+isEnumFields fts =+    Lists.foldl (\b -> \f -> Logic.and b (Predicates.isUnitType (simplifyType (Core.fieldTypeType f)))) True fts+javaMultipleFilesOptionName :: String+javaMultipleFilesOptionName = "java_multiple_files"+javaPackageOptionName :: String+javaPackageOptionName = "java_package"+key_proto_field_index :: Core.Name+key_proto_field_index = Core.Name "proto_field_index"+-- | Thread context through a list, accumulating results+mapAccumResult :: (t0 -> t1 -> Either t2 (t3, t0)) -> t0 -> [t1] -> Either t2 ([t3], t0)+mapAccumResult f cx0 xs =+    Lists.foldl (\accE -> \x -> Eithers.bind accE (\accPair ->+      let bs = Pairs.first accPair+          cxN = Pairs.second accPair+      in (Eithers.map (\resultPair -> (+        Lists.concat [+          bs,+          [+            Pairs.first resultPair]],+        (Pairs.second resultPair))) (f cxN x)))) (Right ([], cx0)) xs+-- | Convert a Hydra module to Protocol Buffers v3 source files+moduleToProtobuf :: Packaging.Module -> [Packaging.Definition] -> Typing.InferenceContext -> Graph.Graph -> Either Errors.Error (M.Map String String)+moduleToProtobuf mod defs cx g =++      let ns_ = Packaging.moduleName mod+          partitioned = Environment.partitionDefinitions defs+          typeDefs = Pairs.first partitioned+          es =+                  ProtobufEnvironment.EncoderState {+                    ProtobufEnvironment.encoderStateContext = cx,+                    ProtobufEnvironment.encoderStateFieldIndex = 0}+      in (Eithers.bind (constructModule es g mod typeDefs) (\pfile ->+        let content = Serialization.printExpr (Serialization.parenthesize (Serde.protoFileToExpr pfile))+            path = Proto3.unFileReference (namespaceToFileReference ns_)+        in (Right (Maps.singleton path content))))+-- | Convert a Hydra namespace to a Protobuf file reference+namespaceToFileReference :: Packaging.ModuleName -> Proto3.FileReference+namespaceToFileReference ns_ =++      let pns =+              Strings.intercalate "/" (Lists.map (\s -> Formatting.convertCaseCamelToLowerSnake s) (Strings.splitOn "." (Packaging.unModuleName ns_)))+      in (Proto3.FileReference (Strings.cat2 pns ".proto"))+-- | Convert a Hydra namespace to a Protobuf package name+namespaceToPackageName :: Packaging.ModuleName -> Proto3.PackageName+namespaceToPackageName ns_ =+    Proto3.PackageName (Strings.intercalate "." (Lists.map (\s -> Formatting.convertCaseCamelToLowerSnake s) (Optionals.fromOptional [] (Lists.maybeInit (Strings.splitOn "." (Packaging.unModuleName ns_))))))+-- | Read a boolean annotation from a type+readBooleanAnnotation :: t0 -> Graph.Graph -> Core.Name -> Core.Type -> Either Errors.Error Bool+readBooleanAnnotation cx g key typ =+    Optionals.cases (Maps.lookup key (Annotations.typeAnnotationInternal typ)) (Right False) (\term -> ExtractCore.boolean g term)+-- | Simplify a type by removing annotations and unwrapping newtypes+simplifyType :: Core.Type -> Core.Type+simplifyType typ =+    case (Strip.deannotateType typ) of+      Core.TypeWrap v0 -> simplifyType v0+      _ -> Strip.deannotateType typ+-- | Generate a message name for a structural type reference+structuralTypeName :: t0 -> ProtobufEnvironment.StructuralTypeRef -> Proto3.TypeName+structuralTypeName localNs ref =++      let typeSuffix =+              \typ ->+                let st = simplifyType typ+                in case st of+                  Core.TypeLiteral v0 -> case v0 of+                    Core.LiteralTypeBinary -> "bytes"+                    Core.LiteralTypeBoolean -> "bool"+                    Core.LiteralTypeFloat v1 -> case v1 of+                      Core.FloatTypeFloat32 -> "float"+                      Core.FloatTypeFloat64 -> "double"+                      _ -> "float"+                    Core.LiteralTypeInteger v1 -> case v1 of+                      Core.IntegerTypeInt32 -> "int32"+                      Core.IntegerTypeInt64 -> "int64"+                      Core.IntegerTypeUint32 -> "uint32"+                      Core.IntegerTypeUint64 -> "uint64"+                      _ -> "int64"+                    Core.LiteralTypeString -> "string"+                    _ -> "value"+                  Core.TypeRecord _ -> "record"+                  Core.TypeUnion _ -> "union"+                  Core.TypeVariable v0 -> Names.localNameOf v0+                  Core.TypeUnit -> "unit"+                  Core.TypeList _ -> "list"+                  Core.TypeSet _ -> "set"+                  Core.TypeMap _ -> "map"+                  Core.TypeOptional _ -> "maybe"+                  _ -> "value"+      in (Proto3.TypeName (case ref of+        ProtobufEnvironment.StructuralTypeRefEither v0 -> Strings.cat [+          "Either_",+          (typeSuffix (Pairs.first v0)),+          "_",+          (typeSuffix (Pairs.second v0))]+        ProtobufEnvironment.StructuralTypeRefPair v0 -> Strings.cat [+          "Pair_",+          (typeSuffix (Pairs.first v0)),+          "_",+          (typeSuffix (Pairs.second v0))]))+unexpectedE :: t0 -> String -> String -> Either Errors.Error t1+unexpectedE cx expected found =+    err cx (Strings.cat [+      "Expected ",+      expected,+      ", found: ",+      found])
+ src/main/haskell/Hydra/Protobuf/Environment.hs view
@@ -0,0 +1,29 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Type definitions for the Protobuf code generation environment++module Hydra.Protobuf.Environment where+import qualified Hydra.Core as Core+import qualified Hydra.Typing as Typing+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | State threaded through Protobuf encoding: inference context plus field-index counter+data EncoderState =+  EncoderState {+    -- | Inference context used by kernel utilities (annotations, dependency analysis)+    encoderStateContext :: Typing.InferenceContext,+    -- | Counter used to assign the next Protobuf field index within the current message+    encoderStateFieldIndex :: Int}+  deriving (Eq, Ord, Read, Show)+_EncoderState = Core.Name "hydra.protobuf.environment.EncoderState"+_EncoderState_context = Core.Name "context"+_EncoderState_fieldIndex = Core.Name "fieldIndex"+-- | A reference to a structural type (Either or Pair) with its component types+data StructuralTypeRef =+  -- | An Either type with left and right component types+  StructuralTypeRefEither (Core.Type, Core.Type) |+  -- | A Pair type with first and second component types+  StructuralTypeRefPair (Core.Type, Core.Type)+  deriving (Eq, Ord, Read, Show)+_StructuralTypeRef = Core.Name "hydra.protobuf.environment.StructuralTypeRef"+_StructuralTypeRef_either = Core.Name "either"+_StructuralTypeRef_pair = Core.Name "pair"
+ src/main/haskell/Hydra/Protobuf/Language.hs view
@@ -0,0 +1,134 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints for Protobuf v3++module Hydra.Protobuf.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | Language constraints for Protocol Buffers v3+protobufLanguage :: Coders.Language+protobufLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.protobuf"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64,+          Core.IntegerTypeUint32,+          Core.IntegerTypeUint64]+    termVariants =+        Sets.fromList [+          Variants.TermVariantEither,+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantPair,+          Variants.TermVariantRecord,+          Variants.TermVariantSet,+          Variants.TermVariantInject,+          Variants.TermVariantUnit,+          Variants.TermVariantWrap]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantEither,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantPair,+          Variants.TypeVariantRecord,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnion,+          Variants.TypeVariantUnit,+          Variants.TypeVariantVariable,+          Variants.TypeVariantVoid,+          Variants.TypeVariantWrap]+    typePredicate =+        \typ -> case typ of+          Core.TypeMap v0 ->+            let valuesType = Core.mapTypeValues v0+                stripped = Strip.deannotateType valuesType+            in case stripped of+              Core.TypeOptional _ -> False+              _ -> True+          _ -> True+-- | A set of reserved words in Protobuf+protobufReservedWords :: S.Set String+protobufReservedWords = Sets.fromList (Lists.concat [+  fieldNames])+  where+    fieldNames =+        [+          "case",+          "class",+          "data",+          "default",+          "deriving",+          "do",+          "else",+          "foreign",+          "if",+          "import",+          "in",+          "infix",+          "infixl",+          "infixr",+          "instance",+          "let",+          "mdo",+          "module",+          "newtype",+          "of",+          "pattern",+          "proc",+          "rec",+          "then",+          "type",+          "where"]
+ src/main/haskell/Hydra/Protobuf/Proto3.hs view
@@ -0,0 +1,202 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for Protocol Buffers v3 enum and message types, designed as a target for transformations.This model is loosely based on https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/type.proto, as well as the proto3 reference documentation++module Hydra.Protobuf.Proto3 where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+data Definition =+  DefinitionEnum EnumDefinition |+  DefinitionMessage MessageDefinition+  deriving (Eq, Ord, Read, Show)+_Definition = Core.Name "hydra.protobuf.proto3.Definition"+_Definition_enum = Core.Name "enum"+_Definition_message = Core.Name "message"+-- | Enum type definition+data EnumDefinition =+  EnumDefinition {+    -- | Enum type name+    enumDefinitionName :: TypeName,+    -- | Enum value definitions+    enumDefinitionValues :: [EnumValue],+    -- | Protocol buffer options+    enumDefinitionOptions :: [Option]}+  deriving (Eq, Ord, Read, Show)+_EnumDefinition = Core.Name "hydra.protobuf.proto3.EnumDefinition"+_EnumDefinition_name = Core.Name "name"+_EnumDefinition_values = Core.Name "values"+_EnumDefinition_options = Core.Name "options"+-- | Enum value definition+data EnumValue =+  EnumValue {+    -- | Enum value name+    enumValueName :: EnumValueName,+    -- | Enum value number+    enumValueNumber :: Int,+    -- | Protocol buffer options+    enumValueOptions :: [Option]}+  deriving (Eq, Ord, Read, Show)+_EnumValue = Core.Name "hydra.protobuf.proto3.EnumValue"+_EnumValue_name = Core.Name "name"+_EnumValue_number = Core.Name "number"+_EnumValue_options = Core.Name "options"+newtype EnumValueName =+  EnumValueName {+    unEnumValueName :: String}+  deriving (Eq, Ord, Read, Show)+_EnumValueName = Core.Name "hydra.protobuf.proto3.EnumValueName"+-- | A single field of a message type+data Field =+  Field {+    -- | The field name+    fieldName :: FieldName,+    -- | The field JSON name+    fieldJsonName :: (Maybe String),+    -- | The datatype of the field+    fieldType :: FieldType,+    -- | The field number+    fieldNumber :: Int,+    -- | The protocol buffer options+    fieldOptions :: [Option]}+  deriving (Eq, Ord, Read, Show)+_Field = Core.Name "hydra.protobuf.proto3.Field"+_Field_name = Core.Name "name"+_Field_jsonName = Core.Name "jsonName"+_Field_type = Core.Name "type"+_Field_number = Core.Name "number"+_Field_options = Core.Name "options"+-- | The name of a field+newtype FieldName =+  FieldName {+    unFieldName :: String}+  deriving (Eq, Ord, Read, Show)+_FieldName = Core.Name "hydra.protobuf.proto3.FieldName"+data FieldType =+  FieldTypeMap MapType |+  FieldTypeOneof [Field] |+  FieldTypeRepeated SimpleType |+  FieldTypeSimple SimpleType+  deriving (Eq, Ord, Read, Show)+_FieldType = Core.Name "hydra.protobuf.proto3.FieldType"+_FieldType_map = Core.Name "map"+_FieldType_oneof = Core.Name "oneof"+_FieldType_repeated = Core.Name "repeated"+_FieldType_simple = Core.Name "simple"+newtype FileReference =+  FileReference {+    unFileReference :: String}+  deriving (Eq, Ord, Read, Show)+_FileReference = Core.Name "hydra.protobuf.proto3.FileReference"+data MapType =+  MapType {+    mapTypeKeys :: SimpleType,+    mapTypeValues :: SimpleType}+  deriving (Eq, Ord, Read, Show)+_MapType = Core.Name "hydra.protobuf.proto3.MapType"+_MapType_keys = Core.Name "keys"+_MapType_values = Core.Name "values"+-- | A protocol buffer message type+data MessageDefinition =+  MessageDefinition {+    -- | The fully qualified message name+    messageDefinitionName :: TypeName,+    -- | The list of fields+    messageDefinitionFields :: [Field],+    -- | The protocol buffer options+    messageDefinitionOptions :: [Option]}+  deriving (Eq, Ord, Read, Show)+_MessageDefinition = Core.Name "hydra.protobuf.proto3.MessageDefinition"+_MessageDefinition_name = Core.Name "name"+_MessageDefinition_fields = Core.Name "fields"+_MessageDefinition_options = Core.Name "options"+-- | A protocol buffer option, which can be attached to a message, field, enumeration, etc+data Option =+  Option {+    -- | The option's name. For protobuf built-in options (options defined in descriptor.proto), this is the short name. For example, `"map_entry"`. For custom options, it should be the fully-qualified name. For example, `"google.api.http"`.+    optionName :: String,+    -- | The option's value+    optionValue :: Value}+  deriving (Eq, Ord, Read, Show)+_Option = Core.Name "hydra.protobuf.proto3.Option"+_Option_name = Core.Name "name"+_Option_value = Core.Name "value"+newtype PackageName =+  PackageName {+    unPackageName :: String}+  deriving (Eq, Ord, Read, Show)+_PackageName = Core.Name "hydra.protobuf.proto3.PackageName"+-- | A .proto file, usually containing one or more enum or message type definitions+data ProtoFile =+  ProtoFile {+    protoFilePackage :: PackageName,+    protoFileImports :: [FileReference],+    protoFileTypes :: [Definition],+    protoFileOptions :: [Option]}+  deriving (Eq, Ord, Read, Show)+_ProtoFile = Core.Name "hydra.protobuf.proto3.ProtoFile"+_ProtoFile_package = Core.Name "package"+_ProtoFile_imports = Core.Name "imports"+_ProtoFile_types = Core.Name "types"+_ProtoFile_options = Core.Name "options"+-- | One of several Proto3 scalar types+data ScalarType =+  ScalarTypeBool |+  ScalarTypeBytes |+  ScalarTypeDouble |+  ScalarTypeFixed32 |+  ScalarTypeFixed64 |+  ScalarTypeFloat |+  ScalarTypeInt32 |+  ScalarTypeInt64 |+  ScalarTypeSfixed32 |+  ScalarTypeSfixed64 |+  ScalarTypeSint32 |+  ScalarTypeSint64 |+  ScalarTypeString |+  ScalarTypeUint32 |+  ScalarTypeUint64+  deriving (Eq, Ord, Read, Show)+_ScalarType = Core.Name "hydra.protobuf.proto3.ScalarType"+_ScalarType_bool = Core.Name "bool"+_ScalarType_bytes = Core.Name "bytes"+_ScalarType_double = Core.Name "double"+_ScalarType_fixed32 = Core.Name "fixed32"+_ScalarType_fixed64 = Core.Name "fixed64"+_ScalarType_float = Core.Name "float"+_ScalarType_int32 = Core.Name "int32"+_ScalarType_int64 = Core.Name "int64"+_ScalarType_sfixed32 = Core.Name "sfixed32"+_ScalarType_sfixed64 = Core.Name "sfixed64"+_ScalarType_sint32 = Core.Name "sint32"+_ScalarType_sint64 = Core.Name "sint64"+_ScalarType_string = Core.Name "string"+_ScalarType_uint32 = Core.Name "uint32"+_ScalarType_uint64 = Core.Name "uint64"+-- | A scalar type or a reference to an enum type or message type+data SimpleType =+  SimpleTypeReference TypeName |+  SimpleTypeScalar ScalarType+  deriving (Eq, Ord, Read, Show)+_SimpleType = Core.Name "hydra.protobuf.proto3.SimpleType"+_SimpleType_reference = Core.Name "reference"+_SimpleType_scalar = Core.Name "scalar"+-- | The local name of an enum type or message type+newtype TypeName =+  TypeName {+    unTypeName :: String}+  deriving (Eq, Ord, Read, Show)+_TypeName = Core.Name "hydra.protobuf.proto3.TypeName"+-- | A reference to an enum type or message type+newtype TypeReference =+  TypeReference {+    unTypeReference :: String}+  deriving (Eq, Ord, Read, Show)+_TypeReference = Core.Name "hydra.protobuf.proto3.TypeReference"+-- | A scalar value+data Value =+  ValueBoolean Bool |+  ValueString String+  deriving (Eq, Ord, Read, Show)+_Value = Core.Name "hydra.protobuf.proto3.Value"+_Value_boolean = Core.Name "boolean"+_Value_string = Core.Name "string"
+ src/main/haskell/Hydra/Protobuf/Serde.hs view
@@ -0,0 +1,263 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Serialization functions for converting Protocol Buffers v3 AST to abstract expressions++module Hydra.Protobuf.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Protobuf.Proto3 as Proto3+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Convert a definition to an expression+definitionToExpr :: Proto3.Definition -> Ast.Expr+definitionToExpr def =+    case def of+      Proto3.DefinitionEnum v0 -> enumDefinitionToExpr v0+      Proto3.DefinitionMessage v0 -> messageDefinitionToExpr v0+-- | The name of the deprecated option+deprecatedOptionName :: String+deprecatedOptionName = "deprecated"+-- | A special Protobuf option name for descriptions (documentation)+descriptionOptionName :: String+descriptionOptionName = "_description"+-- | Convert an enum definition to an expression+enumDefinitionToExpr :: Proto3.EnumDefinition -> Ast.Expr+enumDefinitionToExpr ed =++      let name = Proto3.enumDefinitionName ed+          values = Proto3.enumDefinitionValues ed+          options = Proto3.enumDefinitionOptions ed+      in (optDesc False options (Serialization.spaceSep [+        Serialization.cst "enum",+        (Serialization.cst (Proto3.unTypeName name)),+        (protoBlock (Lists.map enumValueToExpr values))]))+-- | Convert an enum value to an expression+enumValueToExpr :: Proto3.EnumValue -> Ast.Expr+enumValueToExpr ev =++      let name = Proto3.enumValueName ev+          number = Proto3.enumValueNumber ev+          options = Proto3.enumValueOptions ev+      in (optDesc False options (semi (Serialization.spaceSep [+        Serialization.cst (Proto3.unEnumValueName name),+        (Serialization.cst "="),+        (Serialization.cst (Literals.showInt32 number))])))+-- | Filter out internal options (those whose names start with underscore)+excludeInternalOptions :: [Proto3.Option] -> [Proto3.Option]+excludeInternalOptions opts =+    Lists.filter (\opt -> Logic.not (Equality.equal (Optionals.fromOptional 0 (Strings.maybeCharAt 0 (Proto3.optionName opt))) 95)) opts+-- | Convert a field option to an expression+fieldOptionToExpr :: Proto3.Option -> Ast.Expr+fieldOptionToExpr opt =++      let name = Proto3.optionName opt+          value = Proto3.optionValue opt+      in (Serialization.spaceSep [+        Serialization.cst name,+        (Serialization.cst "="),+        (valueToExpr value)])+-- | Convert field options to an optional bracket-enclosed expression+fieldOptionsToExpr :: [Proto3.Option] -> Maybe Ast.Expr+fieldOptionsToExpr opts0 =++      let opts = excludeInternalOptions opts0+      in (Logic.ifElse (Lists.null opts) Nothing (Optionals.pure (Serialization.bracketList Serialization.inlineStyle (Lists.map fieldOptionToExpr opts))))+-- | Convert a field to an expression+fieldToExpr :: Proto3.Field -> Ast.Expr+fieldToExpr f =++      let name = Proto3.fieldName f+          typ = Proto3.fieldType f+          num = Proto3.fieldNumber f+          options = Proto3.fieldOptions f+      in (optDesc False options (case typ of+        Proto3.FieldTypeOneof v0 -> Serialization.spaceSep [+          Serialization.cst "oneof",+          (Serialization.cst (Proto3.unFieldName name)),+          (protoBlock (Lists.map fieldToExpr v0))]+        Proto3.FieldTypeMap v0 ->+          let kt = Proto3.mapTypeKeys v0+              vt = Proto3.mapTypeValues v0+          in (semi (Serialization.spaceSep (Optionals.cat [+            Optionals.pure (fieldTypeToExpr typ),+            (Optionals.pure (Serialization.cst (Proto3.unFieldName name))),+            (Optionals.pure (Serialization.cst "=")),+            (Optionals.pure (Serialization.cst (Literals.showInt32 num))),+            (fieldOptionsToExpr options)])))+        Proto3.FieldTypeRepeated _ -> semi (Serialization.spaceSep (Optionals.cat [+          Optionals.pure (fieldTypeToExpr typ),+          (Optionals.pure (Serialization.cst (Proto3.unFieldName name))),+          (Optionals.pure (Serialization.cst "=")),+          (Optionals.pure (Serialization.cst (Literals.showInt32 num))),+          (fieldOptionsToExpr options)]))+        Proto3.FieldTypeSimple _ -> semi (Serialization.spaceSep (Optionals.cat [+          Optionals.pure (fieldTypeToExpr typ),+          (Optionals.pure (Serialization.cst (Proto3.unFieldName name))),+          (Optionals.pure (Serialization.cst "=")),+          (Optionals.pure (Serialization.cst (Literals.showInt32 num))),+          (fieldOptionsToExpr options)]))))+-- | Convert a field type to an expression+fieldTypeToExpr :: Proto3.FieldType -> Ast.Expr+fieldTypeToExpr ftyp =+    case ftyp of+      Proto3.FieldTypeMap v0 ->+        let kt = Proto3.mapTypeKeys v0+            vt = Proto3.mapTypeValues v0+        in (Serialization.noSep [+          Serialization.cst "map",+          (Serialization.angleBracesList Serialization.inlineStyle [+            simpleTypeToExpr kt,+            (simpleTypeToExpr vt)])])+      Proto3.FieldTypeRepeated v0 -> Serialization.spaceSep [+        Serialization.cst "repeated",+        (simpleTypeToExpr v0)]+      Proto3.FieldTypeSimple v0 -> simpleTypeToExpr v0+      Proto3.FieldTypeOneof _ -> Serialization.cst "oneof"+-- | Convert a file-level option to an expression+fileOptionToExpr :: Proto3.Option -> Ast.Expr+fileOptionToExpr opt =++      let name = Proto3.optionName opt+          value = Proto3.optionValue opt+      in (semi (Serialization.spaceSep [+        Serialization.cst "option",+        (Serialization.cst name),+        (Serialization.cst "="),+        (valueToExpr value)]))+-- | Convert file-level options to an optional newline-separated expression+fileOptionsToExpr :: [Proto3.Option] -> Maybe Ast.Expr+fileOptionsToExpr opts0 =++      let opts = excludeInternalOptions opts0+      in (Logic.ifElse (Lists.null opts) Nothing (Optionals.pure (Serialization.newlineSep (Lists.map fileOptionToExpr opts))))+-- | Convert a file reference to an import expression+importToExpr :: Proto3.FileReference -> Ast.Expr+importToExpr ref =+    semi (Serialization.spaceSep [+      Serialization.cst "import",+      (Serialization.cst (Literals.showString (Proto3.unFileReference ref)))])+-- | Convert a message definition to an expression+messageDefinitionToExpr :: Proto3.MessageDefinition -> Ast.Expr+messageDefinitionToExpr md =++      let name = Proto3.messageDefinitionName md+          fields = Proto3.messageDefinitionFields md+          options = Proto3.messageDefinitionOptions md+      in (optDesc False options (Serialization.spaceSep [+        Serialization.cst "message",+        (Serialization.cst (Proto3.unTypeName name)),+        (protoBlock (Lists.map fieldToExpr fields))]))+-- | Prepend an optional description comment to an expression+optDesc :: Bool -> [Proto3.Option] -> Ast.Expr -> Ast.Expr+optDesc doubleNewline opts expr =++      let descs = Lists.filter (\opt -> Equality.equal (Proto3.optionName opt) "_description") opts+      in (Optionals.cases (Lists.maybeHead descs) expr (\firstDesc ->+        let descValue = Proto3.optionValue firstDesc+            descStr =+                    case descValue of+                      Proto3.ValueBoolean v0 -> Logic.ifElse v0 "true" "false"+                      Proto3.ValueString v0 -> v0+            commentLines =+                    Lists.map (\line -> Logic.ifElse (Equality.equal line "") "//" (Strings.cat2 "// " line)) (Strings.lines descStr)+            comment = Serialization.cst (Strings.intercalate "\n" commentLines)+            sep =+                    Logic.ifElse doubleNewline (Serialization.doubleNewlineSep [+                      comment,+                      expr]) (Serialization.newlineSep [+                      comment,+                      expr])+        in sep))+-- | Wrap expressions in a curly-braced block with double-newline separation+protoBlock :: [Ast.Expr] -> Ast.Expr+protoBlock exprs =+    Serialization.brackets Serialization.curlyBraces Serialization.fullBlockStyle (Serialization.doubleNewlineSep exprs)+-- | Convert a proto file to an expression+protoFileToExpr :: Proto3.ProtoFile -> Ast.Expr+protoFileToExpr pf =++      let pkg = Proto3.protoFilePackage pf+          imports = Proto3.protoFileImports pf+          defs = Proto3.protoFileTypes pf+          options = Proto3.protoFileOptions pf+          headerSec =+                  Optionals.pure (Serialization.newlineSep [+                    semi (Serialization.cst "syntax = \"proto3\""),+                    (semi (Serialization.spaceSep [+                      Serialization.cst "package",+                      (Serialization.cst (Proto3.unPackageName pkg))]))])+          importsSec =+                  Logic.ifElse (Lists.null imports) Nothing (Optionals.pure (Serialization.newlineSep (Lists.map importToExpr imports)))+          options1 = Lists.filter (\opt -> Logic.not (Equality.equal (Proto3.optionName opt) "_description")) options+          optionsSec = fileOptionsToExpr options1+          defsSec =+                  Logic.ifElse (Lists.null defs) Nothing (Optionals.pure (Serialization.doubleNewlineSep (Lists.map definitionToExpr defs)))+      in (optDesc True options (Serialization.doubleNewlineSep (Optionals.cat [+        headerSec,+        importsSec,+        optionsSec,+        defsSec])))+-- | Convert a scalar type to an expression+scalarTypeToExpr :: Proto3.ScalarType -> Ast.Expr+scalarTypeToExpr sct =+    Serialization.cst (case sct of+      Proto3.ScalarTypeBool -> "bool"+      Proto3.ScalarTypeBytes -> "bytes"+      Proto3.ScalarTypeDouble -> "double"+      Proto3.ScalarTypeFixed32 -> "fixed32"+      Proto3.ScalarTypeFixed64 -> "fixed64"+      Proto3.ScalarTypeFloat -> "float"+      Proto3.ScalarTypeInt32 -> "int32"+      Proto3.ScalarTypeInt64 -> "int64"+      Proto3.ScalarTypeSfixed32 -> "sfixed32"+      Proto3.ScalarTypeSfixed64 -> "sfixed64"+      Proto3.ScalarTypeSint32 -> "sint32"+      Proto3.ScalarTypeSint64 -> "sint64"+      Proto3.ScalarTypeString -> "string"+      Proto3.ScalarTypeUint32 -> "uint32"+      Proto3.ScalarTypeUint64 -> "uint64")+-- | Append a semicolon to an expression+semi :: Ast.Expr -> Ast.Expr+semi e =+    Serialization.noSep [+      e,+      (Serialization.cst ";")]+-- | Convert a simple type to an expression+simpleTypeToExpr :: Proto3.SimpleType -> Ast.Expr+simpleTypeToExpr st =+    case st of+      Proto3.SimpleTypeReference v0 -> Serialization.cst (Proto3.unTypeName v0)+      Proto3.SimpleTypeScalar v0 -> scalarTypeToExpr v0+-- | Convert a value to an expression+valueToExpr :: Proto3.Value -> Ast.Expr+valueToExpr v =+    Serialization.cst (case v of+      Proto3.ValueBoolean v0 -> Logic.ifElse v0 "true" "false"+      Proto3.ValueString v0 -> Literals.showString v0)
+ src/main/haskell/Hydra/Protobuf/SourceContext.hs view
@@ -0,0 +1,15 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Based on https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/source_context.proto++module Hydra.Protobuf.SourceContext where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | `SourceContext` represents information about the source of a protobuf element, like the file in which it is defined.+data SourceContext =+  SourceContext {+    -- | The path-qualified name of the .proto file that contained the associated protobuf element.  For example: `"google/protobuf/source_context.proto"`.+    sourceContextFileName :: String}+  deriving (Eq, Ord, Read, Show)+_SourceContext = Core.Name "hydra.protobuf.sourceContext.SourceContext"+_SourceContext_fileName = Core.Name "fileName"
+ src/main/haskell/Hydra/Rust/Coder.hs view
@@ -0,0 +1,481 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Rust code generator: converts Hydra type and term modules to Rust source code++module Hydra.Rust.Coder where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.File as File+import qualified Hydra.Environment as Environment+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Formatting as Formatting+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Names as Names+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Rust.Language as Language+import qualified Hydra.Rust.Serde as Serde+import qualified Hydra.Rust.Syntax as Syntax+import qualified Hydra.Scoping as Scoping+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variables as Variables+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+encodeEnumVariant :: t0 -> t1 -> Core.FieldType -> Either Errors.Error Syntax.EnumVariant+encodeEnumVariant cx g ft =++      let fname = Core.unName (Core.fieldTypeName ft)+          ftyp = Core.fieldTypeType ft+          dtyp = Strip.deannotateType ftyp+          isUnit =+                  case dtyp of+                    Core.TypeUnit -> True+                    Core.TypeRecord v0 -> Lists.null v0+                    _ -> False+      in (Logic.ifElse isUnit (Right (Syntax.EnumVariant {+        Syntax.enumVariantName = (Formatting.capitalize fname),+        Syntax.enumVariantBody = Syntax.EnumVariantBodyUnit,+        Syntax.enumVariantDoc = Nothing})) (case dtyp of+        Core.TypeRecord v0 -> Eithers.bind (Eithers.mapList (encodeStructField cx g) v0) (\sfields -> Right (Syntax.EnumVariant {+          Syntax.enumVariantName = (Formatting.capitalize fname),+          Syntax.enumVariantBody = (Syntax.EnumVariantBodyStruct sfields),+          Syntax.enumVariantDoc = Nothing}))+        _ -> Eithers.bind (encodeType cx g ftyp) (\sftyp -> Right (Syntax.EnumVariant {+          Syntax.enumVariantName = (Formatting.capitalize fname),+          Syntax.enumVariantBody = (Syntax.EnumVariantBodyTuple [+            sftyp]),+          Syntax.enumVariantDoc = Nothing}))))+encodeLiteral :: Core.Literal -> Syntax.Expression+encodeLiteral lit =+    case lit of+      Core.LiteralBoolean v0 -> Syntax.ExpressionLiteral (Syntax.LiteralBool v0)+      Core.LiteralString v0 -> Syntax.ExpressionLiteral (Syntax.LiteralString v0)+      Core.LiteralFloat v0 -> case v0 of+        Core.FloatValueFloat32 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralFloat (Syntax.FloatLiteral {+          Syntax.floatLiteralValue = (Literals.float32ToFloat64 v1),+          Syntax.floatLiteralSuffix = (Just "f32")}))+        Core.FloatValueFloat64 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralFloat (Syntax.FloatLiteral {+          Syntax.floatLiteralValue = v1,+          Syntax.floatLiteralSuffix = Nothing}))+      Core.LiteralInteger v0 -> case v0 of+        Core.IntegerValueInt8 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.int8ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "i8")}))+        Core.IntegerValueInt16 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.int16ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "i16")}))+        Core.IntegerValueInt32 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.int32ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "i32")}))+        Core.IntegerValueInt64 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.int64ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "i64")}))+        Core.IntegerValueUint8 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.uint8ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "u8")}))+        Core.IntegerValueUint16 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.uint16ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "u16")}))+        Core.IntegerValueUint32 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.uint32ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "u32")}))+        Core.IntegerValueUint64 v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = (Literals.uint64ToBigint v1),+          Syntax.integerLiteralSuffix = (Just "u64")}))+        Core.IntegerValueBigint v1 -> Syntax.ExpressionLiteral (Syntax.LiteralInteger (Syntax.IntegerLiteral {+          Syntax.integerLiteralValue = v1,+          Syntax.integerLiteralSuffix = Nothing}))+encodeLiteralType :: Core.LiteralType -> Syntax.Type+encodeLiteralType lt =+    case lt of+      Core.LiteralTypeBinary -> rustApply1 "Vec" (rustPath "u8")+      Core.LiteralTypeBoolean -> rustPath "bool"+      Core.LiteralTypeFloat v0 -> case v0 of+        Core.FloatTypeFloat32 -> rustPath "f32"+        Core.FloatTypeFloat64 -> rustPath "f64"+      Core.LiteralTypeInteger v0 -> case v0 of+        Core.IntegerTypeBigint -> rustPathSegmented [+          "num",+          "BigInt"]+        Core.IntegerTypeInt8 -> rustPath "i8"+        Core.IntegerTypeInt16 -> rustPath "i16"+        Core.IntegerTypeInt32 -> rustPath "i32"+        Core.IntegerTypeInt64 -> rustPath "i64"+        Core.IntegerTypeUint8 -> rustPath "u8"+        Core.IntegerTypeUint16 -> rustPath "u16"+        Core.IntegerTypeUint32 -> rustPath "u32"+        Core.IntegerTypeUint64 -> rustPath "u64"+      Core.LiteralTypeString -> rustPath "String"+encodeProjectionElim :: t0 -> t1 -> Core.Projection -> Maybe Core.Term -> Either Errors.Error Syntax.Expression+encodeProjectionElim cx g proj marg =++      let fname = Formatting.convertCaseCamelToLowerSnake (Core.unName (Core.projectionFieldName proj))+      in (Optionals.cases marg (Right (rustClosure [+        "v"] (Syntax.ExpressionFieldAccess (Syntax.FieldAccessExpr {+        Syntax.fieldAccessExprObject = (rustExprPath "v"),+        Syntax.fieldAccessExprField = fname})))) (\arg -> Eithers.bind (encodeTerm cx g arg) (\sarg -> Right (Syntax.ExpressionFieldAccess (Syntax.FieldAccessExpr {+        Syntax.fieldAccessExprObject = sarg,+        Syntax.fieldAccessExprField = fname})))))+encodeStructField :: t0 -> t1 -> Core.FieldType -> Either Errors.Error Syntax.StructField+encodeStructField cx g ft =++      let fname = Core.unName (Core.fieldTypeName ft)+          ftyp = Core.fieldTypeType ft+      in (Eithers.bind (encodeType cx g ftyp) (\sftyp -> Right (Syntax.StructField {+        Syntax.structFieldName = (Formatting.convertCaseCamelToLowerSnake (Formatting.sanitizeWithUnderscores Language.rustReservedWords fname)),+        Syntax.structFieldType = sftyp,+        Syntax.structFieldPublic = True,+        Syntax.structFieldDoc = Nothing})))+encodeTerm :: t0 -> t1 -> Core.Term -> Either Errors.Error Syntax.Expression+encodeTerm cx g term =+    case term of+      Core.TermAnnotated v0 -> encodeTerm cx g (Core.annotatedTermBody v0)+      Core.TermApplication v0 -> Eithers.bind (encodeTerm cx g (Core.applicationFunction v0)) (\fun -> Eithers.bind (encodeTerm cx g (Core.applicationArgument v0)) (\arg -> Right (rustCall fun [+        arg])))+      Core.TermEither v0 -> Eithers.either (\l -> Eithers.bind (encodeTerm cx g l) (\sl -> Right (rustCall (rustExprPath "Left") [+        sl]))) (\r -> Eithers.bind (encodeTerm cx g r) (\sr -> Right (rustCall (rustExprPath "Right") [+        sr]))) v0+      Core.TermLambda v0 ->+        let param = Formatting.convertCaseCamelToLowerSnake (Core.unName (Core.lambdaParameter v0))+        in (Eithers.bind (encodeTerm cx g (Core.lambdaBody v0)) (\body -> Right (rustClosure [+          param] body)))+      Core.TermProject v0 -> encodeProjectionElim cx g v0 Nothing+      Core.TermCases v0 -> encodeUnionElim cx g v0 Nothing+      Core.TermUnwrap v0 -> encodeUnwrapElim cx g v0 Nothing+      Core.TermLet v0 ->+        let bindings = Core.letBindings v0+            body = Core.letBody v0+        in (Eithers.bind (Eithers.mapList (\b ->+          let bname = Formatting.convertCaseCamelToLowerSnake (Core.unName (Core.bindingName b))+          in (Eithers.bind (encodeTerm cx g (Core.bindingTerm b)) (\bval -> Right (rustLetStmt bname bval)))) bindings) (\stmts -> Eithers.bind (encodeTerm cx g body) (\bodyExpr -> Right (rustBlock stmts bodyExpr))))+      Core.TermList v0 -> Eithers.bind (Eithers.mapList (encodeTerm cx g) v0) (\sels -> Right (rustCall (rustExprPath "Vec::from") [+        Syntax.ExpressionArray (Syntax.ArrayExprElements sels)]))+      Core.TermLiteral v0 -> Right (encodeLiteral v0)+      Core.TermMap v0 -> Eithers.bind (Eithers.mapList (\entry -> Eithers.bind (encodeTerm cx g (Pairs.first entry)) (\k -> Eithers.bind (encodeTerm cx g (Pairs.second entry)) (\v -> Right (Syntax.ExpressionTuple [+        k,+        v])))) (Maps.toList v0)) (\pairs -> Right (rustCall (rustExprPath "BTreeMap::from") [+        Syntax.ExpressionArray (Syntax.ArrayExprElements pairs)]))+      Core.TermOptional v0 -> Optionals.cases v0 (Right (rustExprPath "None")) (\val -> Eithers.bind (encodeTerm cx g val) (\sval -> Right (rustCall (rustExprPath "Some") [+        sval])))+      Core.TermPair v0 -> Eithers.bind (encodeTerm cx g (Pairs.first v0)) (\f -> Eithers.bind (encodeTerm cx g (Pairs.second v0)) (\s -> Right (Syntax.ExpressionTuple [+        f,+        s])))+      Core.TermRecord v0 ->+        let rname = Core.recordTypeName v0+            fields = Core.recordFields v0+        in (Eithers.bind (Eithers.mapList (\f ->+          let fname = Formatting.convertCaseCamelToLowerSnake (Core.unName (Core.fieldName f))+          in (Eithers.bind (encodeTerm cx g (Core.fieldTerm f)) (\fval -> Right (Syntax.FieldValue {+            Syntax.fieldValueName = fname,+            Syntax.fieldValueValue = (Just fval)})))) fields) (\sfields -> Right (Syntax.ExpressionStruct (Syntax.StructExpr {+          Syntax.structExprPath = Syntax.ExprPath {+            Syntax.exprPathGlobal = False,+            Syntax.exprPathSegments = [+              Syntax.PathSegment {+                Syntax.pathSegmentName = (Formatting.capitalize (Names.localNameOf rname)),+                Syntax.pathSegmentArguments = Syntax.GenericArgumentsNone}]},+          Syntax.structExprFields = sfields,+          Syntax.structExprRest = Nothing}))))+      Core.TermSet v0 -> Eithers.bind (Eithers.mapList (encodeTerm cx g) (Sets.toList v0)) (\sels -> Right (rustCall (rustExprPath "BTreeSet::from") [+        Syntax.ExpressionArray (Syntax.ArrayExprElements sels)]))+      Core.TermInject v0 ->+        let tname = Formatting.capitalize (Names.localNameOf (Core.injectionTypeName v0))+            field = Core.injectionField v0+            fname = Formatting.capitalize (Core.unName (Core.fieldName field))+            fterm = Core.fieldTerm field+            dterm = Strip.deannotateTerm fterm+            isUnit =+                    case dterm of+                      Core.TermUnit -> True+                      Core.TermRecord v1 -> Lists.null (Core.recordFields v1)+                      _ -> False+        in (Logic.ifElse isUnit (Right (rustExprPath (Strings.cat2 (Strings.cat2 tname "::") fname))) (Eithers.bind (encodeTerm cx g fterm) (\sval -> Right (rustCall (rustExprPath (Strings.cat2 (Strings.cat2 tname "::") fname)) [+          sval]))))+      Core.TermUnit -> Right (Syntax.ExpressionTuple [])+      Core.TermVariable v0 -> Right (rustExprPath (Formatting.convertCaseCamelToLowerSnake (Formatting.sanitizeWithUnderscores Language.rustReservedWords (Core.unName v0))))+      Core.TermWrap v0 ->+        let tname = Formatting.capitalize (Names.localNameOf (Core.wrappedTermTypeName v0))+        in (Eithers.bind (encodeTerm cx g (Core.wrappedTermBody v0)) (\inner -> Right (rustCall (rustExprPath tname) [+          inner])))+      _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected term variant"))+encodeTermDefinition :: t0 -> t1 -> Packaging.TermDefinition -> Either Errors.Error Syntax.ItemWithComments+encodeTermDefinition cx g tdef =++      let name = Packaging.termDefinitionName tdef+          term = Packaging.termDefinitionBody tdef+          lname = Formatting.convertCaseCamelToLowerSnake (Names.localNameOf name)+          typ =+                  Optionals.cases (Optionals.map Scoping.termSignatureToTypeScheme (Packaging.termDefinitionSignature tdef)) (Core.TypeVariable (Core.Name "hydra.core.Unit")) Core.typeSchemeBody+      in (Eithers.bind (encodeTerm cx g term) (\body -> Eithers.bind (encodeType cx g typ) (\retType -> Right (Syntax.ItemWithComments {+        Syntax.itemWithCommentsDoc = Nothing,+        Syntax.itemWithCommentsVisibility = Syntax.VisibilityPublic,+        Syntax.itemWithCommentsItem = (Syntax.ItemFn (Syntax.FnDef {+          Syntax.fnDefName = lname,+          Syntax.fnDefGenerics = [],+          Syntax.fnDefWhereClause = Nothing,+          Syntax.fnDefParams = [],+          Syntax.fnDefReturnType = (Just retType),+          Syntax.fnDefBody = Syntax.Block {+            Syntax.blockStatements = [],+            Syntax.blockExpression = (Just body)},+          Syntax.fnDefPublic = True,+          Syntax.fnDefAsync = False,+          Syntax.fnDefConst = False,+          Syntax.fnDefUnsafe = False,+          Syntax.fnDefDoc = Nothing}))}))))+encodeType :: t0 -> t1 -> Core.Type -> Either Errors.Error Syntax.Type+encodeType cx g t =++      let typ = Strip.deannotateType t+      in case typ of+        Core.TypeAnnotated v0 -> encodeType cx g (Core.annotatedTypeBody v0)+        Core.TypeApplication v0 -> encodeType cx g (Core.applicationTypeFunction v0)+        Core.TypeUnit -> Right rustUnit+        Core.TypeVoid -> Right rustUnit+        Core.TypeLiteral v0 -> Right (encodeLiteralType v0)+        Core.TypeList v0 -> Eithers.map (\enc -> rustApply1 "Vec" enc) (encodeType cx g v0)+        Core.TypeSet v0 -> Eithers.map (\enc -> rustApply1 "BTreeSet" enc) (encodeType cx g v0)+        Core.TypeMap v0 -> Eithers.bind (encodeType cx g (Core.mapTypeKeys v0)) (\kt -> Eithers.bind (encodeType cx g (Core.mapTypeValues v0)) (\vt -> Right (rustApply2 "BTreeMap" kt vt)))+        Core.TypeOptional v0 -> Eithers.map (\enc -> rustApply1 "Option" enc) (encodeType cx g v0)+        Core.TypeEither v0 -> Eithers.bind (encodeType cx g (Core.eitherTypeLeft v0)) (\lt -> Eithers.bind (encodeType cx g (Core.eitherTypeRight v0)) (\rt -> Right (rustApply2 "Either" lt rt)))+        Core.TypePair v0 -> Eithers.bind (encodeType cx g (Core.pairTypeFirst v0)) (\ft -> Eithers.bind (encodeType cx g (Core.pairTypeSecond v0)) (\st -> Right (Syntax.TypeTuple [+          ft,+          st])))+        Core.TypeFunction v0 -> Eithers.bind (encodeType cx g (Core.functionTypeDomain v0)) (\dom -> Eithers.bind (encodeType cx g (Core.functionTypeCodomain v0)) (\cod -> Right (rustApply1 "Box" (Syntax.TypeDynTrait [+          Syntax.TypeParamBoundTrait (Syntax.TypePath {+            Syntax.typePathGlobal = False,+            Syntax.typePathSegments = [+              Syntax.PathSegment {+                Syntax.pathSegmentName = "Fn",+                Syntax.pathSegmentArguments = (Syntax.GenericArgumentsParenthesized (Syntax.ParenthesizedArgs {+                  Syntax.parenthesizedArgsInputs = [+                    dom],+                  Syntax.parenthesizedArgsOutput = (Just cod)}))}]})]))))+        Core.TypeRecord _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous record type"))+        Core.TypeUnion _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous union type"))+        Core.TypeWrap _ -> Left (Errors.ErrorOther (Errors.OtherError "unexpected anonymous wrap type"))+        Core.TypeVariable v0 -> Right (rustPath (Formatting.capitalize (Core.unName v0)))+        Core.TypeForall v0 -> encodeType cx g (Core.forallTypeBody v0)+encodeTypeDefinition :: t0 -> t1 -> Packaging.TypeDefinition -> Either Errors.Error Syntax.ItemWithComments+encodeTypeDefinition cx g tdef =++      let name = Packaging.typeDefinitionName tdef+          typ = Core.typeSchemeBody (Packaging.typeDefinitionBody tdef)+          lname = Formatting.capitalize (Names.localNameOf name)+          freeVars =+                  Lists.filter (\v -> Equality.equal (Lists.length (Strings.splitOn "." (Core.unName v))) 1) (Sets.toList (Variables.freeVariablesInType typ))+          generics =+                  Lists.map (\v -> Syntax.GenericParam {+                    Syntax.genericParamName = (Formatting.capitalize (Core.unName v)),+                    Syntax.genericParamBounds = []}) freeVars+          dtyp = Strip.deannotateType typ+      in (Eithers.bind (case dtyp of+        Core.TypeRecord v0 -> Eithers.bind (Eithers.mapList (encodeStructField cx g) v0) (\sfields -> Right (Syntax.ItemStruct (Syntax.StructDef {+          Syntax.structDefName = lname,+          Syntax.structDefGenerics = generics,+          Syntax.structDefWhereClause = Nothing,+          Syntax.structDefBody = (Syntax.StructBodyNamed sfields),+          Syntax.structDefDerives = standardDerives,+          Syntax.structDefPublic = True,+          Syntax.structDefDoc = Nothing})))+        Core.TypeUnion v0 -> Eithers.bind (Eithers.mapList (encodeEnumVariant cx g) v0) (\variants -> Right (Syntax.ItemEnum (Syntax.EnumDef {+          Syntax.enumDefName = lname,+          Syntax.enumDefGenerics = generics,+          Syntax.enumDefWhereClause = Nothing,+          Syntax.enumDefVariants = variants,+          Syntax.enumDefDerives = standardDerives,+          Syntax.enumDefPublic = True,+          Syntax.enumDefDoc = Nothing})))+        Core.TypeWrap v0 -> Eithers.bind (encodeType cx g v0) (\styp -> Right (Syntax.ItemStruct (Syntax.StructDef {+          Syntax.structDefName = lname,+          Syntax.structDefGenerics = generics,+          Syntax.structDefWhereClause = Nothing,+          Syntax.structDefBody = (Syntax.StructBodyTuple [+            Syntax.TupleField {+              Syntax.tupleFieldType = styp,+              Syntax.tupleFieldPublic = True}]),+          Syntax.structDefDerives = standardDerives,+          Syntax.structDefPublic = True,+          Syntax.structDefDoc = Nothing})))+        _ -> Eithers.bind (encodeType cx g typ) (\styp -> Right (Syntax.ItemTypeAlias (Syntax.TypeAlias {+          Syntax.typeAliasName = lname,+          Syntax.typeAliasGenerics = generics,+          Syntax.typeAliasType = styp,+          Syntax.typeAliasPublic = True,+          Syntax.typeAliasDoc = Nothing})))) (\item -> Right (Syntax.ItemWithComments {+        Syntax.itemWithCommentsDoc = Nothing,+        Syntax.itemWithCommentsVisibility = Syntax.VisibilityPublic,+        Syntax.itemWithCommentsItem = item})))+encodeUnionElim :: t0 -> t1 -> Core.CaseStatement -> Maybe Core.Term -> Either Errors.Error Syntax.Expression+encodeUnionElim cx g cs marg =++      let tname = Formatting.capitalize (Names.localNameOf (Core.caseStatementTypeName cs))+          caseFields = Core.caseStatementCases cs+          defCase = Core.caseStatementDefault cs+      in (Eithers.bind (Eithers.mapList (\cf ->+        let cfname = Formatting.capitalize (Core.unName (Core.caseAlternativeName cf))+            cfterm = Core.caseAlternativeHandler cf+        in (Eithers.bind (encodeTerm cx g (Core.TermApplication (Core.Application {+          Core.applicationFunction = cfterm,+          Core.applicationArgument = (Core.TermVariable (Core.Name "v"))}))) (\armBody -> Right (Syntax.MatchArm {+          Syntax.matchArmPattern = (Syntax.PatternTupleStruct (Syntax.TupleStructPattern {+            Syntax.tupleStructPatternPath = Syntax.ExprPath {+              Syntax.exprPathGlobal = False,+              Syntax.exprPathSegments = [+                Syntax.PathSegment {+                  Syntax.pathSegmentName = (Strings.cat2 (Strings.cat2 tname "::") cfname),+                  Syntax.pathSegmentArguments = Syntax.GenericArgumentsNone}]},+            Syntax.tupleStructPatternElements = [+              Syntax.PatternIdentifier (Syntax.IdentifierPattern {+                Syntax.identifierPatternName = "v",+                Syntax.identifierPatternMutable = False,+                Syntax.identifierPatternAtPattern = Nothing})]})),+          Syntax.matchArmGuard = Nothing,+          Syntax.matchArmBody = armBody})))) caseFields) (\arms -> Eithers.bind (Optionals.cases defCase (Right arms) (\dt -> Eithers.bind (encodeTerm cx g (Core.TermApplication (Core.Application {+        Core.applicationFunction = dt,+        Core.applicationArgument = (Core.TermVariable (Core.Name "v"))}))) (\defBody -> Right (Lists.concat2 arms [+        Syntax.MatchArm {+          Syntax.matchArmPattern = Syntax.PatternWildcard,+          Syntax.matchArmGuard = Nothing,+          Syntax.matchArmBody = defBody}])))) (\allArms -> Optionals.cases marg (Right (rustClosure [+        "v"] (Syntax.ExpressionMatch (Syntax.MatchExpr {+        Syntax.matchExprScrutinee = (rustExprPath "v"),+        Syntax.matchExprArms = allArms})))) (\arg -> Eithers.bind (encodeTerm cx g arg) (\sarg -> Right (Syntax.ExpressionMatch (Syntax.MatchExpr {+        Syntax.matchExprScrutinee = sarg,+        Syntax.matchExprArms = allArms})))))))+encodeUnwrapElim :: t0 -> t1 -> Core.Name -> Maybe Core.Term -> Either Errors.Error Syntax.Expression+encodeUnwrapElim cx g name marg =+    Optionals.cases marg (Right (rustClosure [+      "v"] (Syntax.ExpressionTupleIndex (Syntax.TupleIndexExpr {+      Syntax.tupleIndexExprTuple = (rustExprPath "v"),+      Syntax.tupleIndexExprIndex = 0})))) (\arg -> Eithers.bind (encodeTerm cx g arg) (\sarg -> Right (Syntax.ExpressionTupleIndex (Syntax.TupleIndexExpr {+      Syntax.tupleIndexExprTuple = sarg,+      Syntax.tupleIndexExprIndex = 0}))))+moduleToRust :: Packaging.Module -> [Packaging.Definition] -> t0 -> t1 -> Either Errors.Error (M.Map String String)+moduleToRust mod defs cx g =++      let partitioned = Environment.partitionDefinitions defs+          typeDefs = Pairs.first partitioned+          termDefs = Pairs.second partitioned+      in (Eithers.bind (Eithers.mapList (encodeTypeDefinition cx g) typeDefs) (\typeItems -> Eithers.bind (Eithers.mapList (encodeTermDefinition cx g) termDefs) (\termItems ->+        let allItems = Lists.concat2 typeItems termItems+            crate = Syntax.Crate {+                  Syntax.crateItems = allItems}+            code = Serialization.printExpr (Serialization.parenthesize (Serde.crateToExpr crate))+            filePath = Names.moduleNameToFilePath Util.CaseConventionLowerSnake (File.FileExtension "rs") (Packaging.moduleName mod)+        in (Right (Maps.singleton filePath code)))))+rustApply1 :: String -> Syntax.Type -> Syntax.Type+rustApply1 name arg =+    Syntax.TypePath_ (Syntax.TypePath {+      Syntax.typePathGlobal = False,+      Syntax.typePathSegments = [+        Syntax.PathSegment {+          Syntax.pathSegmentName = name,+          Syntax.pathSegmentArguments = (Syntax.GenericArgumentsAngleBracketed (Syntax.AngleBracketedArgs {+            Syntax.angleBracketedArgsArgs = [+              Syntax.GenericArgType arg]}))}]})+rustApply2 :: String -> Syntax.Type -> Syntax.Type -> Syntax.Type+rustApply2 name arg1 arg2 =+    Syntax.TypePath_ (Syntax.TypePath {+      Syntax.typePathGlobal = False,+      Syntax.typePathSegments = [+        Syntax.PathSegment {+          Syntax.pathSegmentName = name,+          Syntax.pathSegmentArguments = (Syntax.GenericArgumentsAngleBracketed (Syntax.AngleBracketedArgs {+            Syntax.angleBracketedArgsArgs = [+              Syntax.GenericArgType arg1,+              (Syntax.GenericArgType arg2)]}))}]})+rustBlock :: [Syntax.Statement] -> Syntax.Expression -> Syntax.Expression+rustBlock stmts expr =+    Syntax.ExpressionBlock (Syntax.Block {+      Syntax.blockStatements = stmts,+      Syntax.blockExpression = (Just expr)})+rustCall :: Syntax.Expression -> [Syntax.Expression] -> Syntax.Expression+rustCall fun args =+    Syntax.ExpressionCall (Syntax.CallExpr {+      Syntax.callExprFunction = fun,+      Syntax.callExprArgs = args})+rustClosure :: [String] -> Syntax.Expression -> Syntax.Expression+rustClosure params body =+    Syntax.ExpressionClosure (Syntax.ClosureExpr {+      Syntax.closureExprMove = False,+      Syntax.closureExprParams = (Lists.map (\p -> Syntax.ClosureParam {+        Syntax.closureParamPattern = (Syntax.PatternIdentifier (Syntax.IdentifierPattern {+          Syntax.identifierPatternName = p,+          Syntax.identifierPatternMutable = False,+          Syntax.identifierPatternAtPattern = Nothing})),+        Syntax.closureParamType = Nothing}) params),+      Syntax.closureExprReturnType = Nothing,+      Syntax.closureExprBody = body})+rustExprPath :: String -> Syntax.Expression+rustExprPath name =+    Syntax.ExpressionPath (Syntax.ExprPath {+      Syntax.exprPathGlobal = False,+      Syntax.exprPathSegments = [+        Syntax.PathSegment {+          Syntax.pathSegmentName = name,+          Syntax.pathSegmentArguments = Syntax.GenericArgumentsNone}]})+rustLetStmt :: String -> Syntax.Expression -> Syntax.Statement+rustLetStmt name expr =+    Syntax.StatementLet (Syntax.LetStatement {+      Syntax.letStatementPattern = (Syntax.PatternIdentifier (Syntax.IdentifierPattern {+        Syntax.identifierPatternName = name,+        Syntax.identifierPatternMutable = False,+        Syntax.identifierPatternAtPattern = Nothing})),+      Syntax.letStatementMutable = False,+      Syntax.letStatementType = Nothing,+      Syntax.letStatementInit = (Just expr)})+rustPath :: String -> Syntax.Type+rustPath name =+    Syntax.TypePath_ (Syntax.TypePath {+      Syntax.typePathGlobal = False,+      Syntax.typePathSegments = [+        Syntax.PathSegment {+          Syntax.pathSegmentName = name,+          Syntax.pathSegmentArguments = Syntax.GenericArgumentsNone}]})+rustPathSegmented :: [String] -> Syntax.Type+rustPathSegmented segs =+    Syntax.TypePath_ (Syntax.TypePath {+      Syntax.typePathGlobal = False,+      Syntax.typePathSegments = (Lists.map (\s -> Syntax.PathSegment {+        Syntax.pathSegmentName = s,+        Syntax.pathSegmentArguments = Syntax.GenericArgumentsNone}) segs)})+rustUnit :: Syntax.Type+rustUnit = Syntax.TypeUnit+standardDerives :: [String]+standardDerives =+    [+      "Clone",+      "Debug",+      "PartialEq",+      "Eq",+      "PartialOrd",+      "Ord"]
+ src/main/haskell/Hydra/Rust/Language.hs view
@@ -0,0 +1,236 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints and reserved words for Rust++module Hydra.Rust.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Lexical as Lexical+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Set as S+-- | Language constraints for Rust+rustLanguage :: Coders.Language+rustLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.rust"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBinary,+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes =+        Sets.fromList [+          Core.FloatTypeFloat32,+          Core.FloatTypeFloat64]+    integerTypes =+        Sets.fromList [+          Core.IntegerTypeInt8,+          Core.IntegerTypeInt16,+          Core.IntegerTypeInt32,+          Core.IntegerTypeInt64,+          Core.IntegerTypeUint8,+          Core.IntegerTypeUint16,+          Core.IntegerTypeUint32,+          Core.IntegerTypeUint64]+    termVariants =+        Sets.fromList [+          Variants.TermVariantAnnotated,+          Variants.TermVariantApplication,+          Variants.TermVariantEither,+          Variants.TermVariantCases,+          Variants.TermVariantLambda,+          Variants.TermVariantProject,+          Variants.TermVariantUnwrap,+          Variants.TermVariantTypeApplication,+          Variants.TermVariantTypeLambda,+          Variants.TermVariantLet,+          Variants.TermVariantList,+          Variants.TermVariantLiteral,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantPair,+          Variants.TermVariantRecord,+          Variants.TermVariantSet,+          Variants.TermVariantInject,+          Variants.TermVariantUnit,+          Variants.TermVariantVariable,+          Variants.TermVariantWrap]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantAnnotated,+          Variants.TypeVariantApplication,+          Variants.TypeVariantEither,+          Variants.TypeVariantFunction,+          Variants.TypeVariantForall,+          Variants.TypeVariantList,+          Variants.TypeVariantLiteral,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantPair,+          Variants.TypeVariantRecord,+          Variants.TypeVariantSet,+          Variants.TypeVariantUnion,+          Variants.TypeVariantUnit,+          Variants.TypeVariantVariable,+          Variants.TypeVariantVoid,+          Variants.TypeVariantWrap]+    typePredicate = \_ -> True+-- | A set of reserved words in Rust+rustReservedWords :: S.Set String+rustReservedWords =+    Sets.fromList (Lists.concat [+      strictKeywords,+      reservedKeywords,+      weakKeywords,+      primitiveTypes,+      stdPreludeTypes,+      hydraRustKeywords])+  where+    strictKeywords =+        [+          "as",+          "async",+          "await",+          "break",+          "const",+          "continue",+          "crate",+          "dyn",+          "else",+          "enum",+          "extern",+          "false",+          "fn",+          "for",+          "if",+          "impl",+          "in",+          "let",+          "loop",+          "match",+          "mod",+          "move",+          "mut",+          "pub",+          "ref",+          "return",+          "self",+          "Self",+          "static",+          "struct",+          "super",+          "trait",+          "true",+          "type",+          "unsafe",+          "use",+          "where",+          "while"]+    reservedKeywords =+        [+          "abstract",+          "become",+          "box",+          "do",+          "final",+          "macro",+          "override",+          "priv",+          "try",+          "typeof",+          "unsized",+          "virtual",+          "yield"]+    weakKeywords =+        [+          "macro_rules",+          "union",+          "'static"]+    primitiveTypes =+        [+          "bool",+          "char",+          "str",+          "u8",+          "u16",+          "u32",+          "u64",+          "u128",+          "usize",+          "i8",+          "i16",+          "i32",+          "i64",+          "i128",+          "isize",+          "f32",+          "f64"]+    stdPreludeTypes =+        [+          "Option",+          "Some",+          "None",+          "Result",+          "Ok",+          "Err",+          "Box",+          "String",+          "Vec",+          "Clone",+          "Copy",+          "Default",+          "Drop",+          "Eq",+          "PartialEq",+          "Ord",+          "PartialOrd",+          "Hash",+          "Debug",+          "Display",+          "Iterator",+          "IntoIterator",+          "From",+          "Into",+          "AsRef",+          "AsMut",+          "Send",+          "Sync",+          "Sized",+          "Unpin",+          "Fn",+          "FnMut",+          "FnOnce"]+    hydraRustKeywords = [+      "Node"]
+ src/main/haskell/Hydra/Rust/Operators.hs view
@@ -0,0 +1,217 @@+-- Note: this is an automatically generated file. Do not edit.+-- | AST operators for Rust serialization++module Hydra.Rust.Operators where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Add-assign operator (+=)+addAssignOp :: Ast.Op+addAssignOp = Serialization.op "+=" 1 Ast.AssociativityRight+-- | Addition operator (+)+addOp :: Ast.Op+addOp = Serialization.op "+" 10 Ast.AssociativityLeft+-- | Logical AND operator (&&)+andOp :: Ast.Op+andOp = Serialization.op "&&" 4 Ast.AssociativityLeft+-- | Function application operator (whitespace)+appOp :: Ast.Op+appOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol ""),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsSpace},+      Ast.opPrecedence = (Ast.Precedence 0),+      Ast.opAssociativity = Ast.AssociativityLeft}+-- | Return type arrow (->)+arrowOp :: Ast.Op+arrowOp = Serialization.op "->" 0 Ast.AssociativityRight+-- | Type cast operator (as)+asOp :: Ast.Op+asOp = Serialization.op "as" 12 Ast.AssociativityLeft+-- | Assignment operator (=)+assignOp :: Ast.Op+assignOp = Serialization.op "=" 1 Ast.AssociativityRight+-- | Bitwise and-assign operator (&=)+bitAndAssignOp :: Ast.Op+bitAndAssignOp = Serialization.op "&=" 1 Ast.AssociativityRight+-- | Bitwise AND operator (&)+bitAndOp :: Ast.Op+bitAndOp = Serialization.op "&" 8 Ast.AssociativityLeft+-- | Bitwise or-assign operator (|=)+bitOrAssignOp :: Ast.Op+bitOrAssignOp = Serialization.op "|=" 1 Ast.AssociativityRight+-- | Bitwise OR operator (|)+bitOrOp :: Ast.Op+bitOrOp = Serialization.op "|" 6 Ast.AssociativityLeft+-- | Bitwise xor-assign operator (^=)+bitXorAssignOp :: Ast.Op+bitXorAssignOp = Serialization.op "^=" 1 Ast.AssociativityRight+-- | Bitwise XOR operator (^)+bitXorOp :: Ast.Op+bitXorOp = Serialization.op "^" 7 Ast.AssociativityLeft+-- | Type annotation (::) for let statements+colonColonOp :: Ast.Op+colonColonOp = Serialization.op ":" 0 Ast.AssociativityNone+-- | Type ascription operator (:)+colonOp :: Ast.Op+colonOp = Serialization.op ":" 12 Ast.AssociativityLeft+-- | Dereference operator (*)+derefOp :: Ast.Op+derefOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "*"),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 13),+      Ast.opAssociativity = Ast.AssociativityNone}+-- | Div-assign operator (/=)+divAssignOp :: Ast.Op+divAssignOp = Serialization.op "/=" 1 Ast.AssociativityRight+-- | Division operator (/)+divOp :: Ast.Op+divOp = Serialization.op "/" 11 Ast.AssociativityLeft+-- | Path separator (::)+doubleColonOp :: Ast.Op+doubleColonOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "::"),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 15),+      Ast.opAssociativity = Ast.AssociativityLeft}+-- | Equality operator (==)+eqOp :: Ast.Op+eqOp = Serialization.op "==" 5 Ast.AssociativityNone+-- | Match arm arrow (=>)+fatArrowOp :: Ast.Op+fatArrowOp = Serialization.op "=>" 0 Ast.AssociativityNone+-- | Field access operator (.)+fieldOp :: Ast.Op+fieldOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "."),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 14),+      Ast.opAssociativity = Ast.AssociativityLeft}+-- | Greater-than-or-equal operator (>=)+geOp :: Ast.Op+geOp = Serialization.op ">=" 5 Ast.AssociativityNone+-- | Greater-than operator (>)+gtOp :: Ast.Op+gtOp = Serialization.op ">" 5 Ast.AssociativityNone+-- | Less-than-or-equal operator (<=)+leOp :: Ast.Op+leOp = Serialization.op "<=" 5 Ast.AssociativityNone+-- | Less-than operator (<)+ltOp :: Ast.Op+ltOp = Serialization.op "<" 5 Ast.AssociativityNone+-- | Method call operator (.)+methodOp :: Ast.Op+methodOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "."),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 14),+      Ast.opAssociativity = Ast.AssociativityLeft}+-- | Mul-assign operator (*=)+mulAssignOp :: Ast.Op+mulAssignOp = Serialization.op "*=" 1 Ast.AssociativityRight+-- | Multiplication operator (*)+mulOp :: Ast.Op+mulOp = Serialization.op "*" 11 Ast.AssociativityLeft+-- | Not-equal operator (!=)+neOp :: Ast.Op+neOp = Serialization.op "!=" 5 Ast.AssociativityNone+-- | Unary negation operator (-)+negOp :: Ast.Op+negOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "-"),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 13),+      Ast.opAssociativity = Ast.AssociativityNone}+-- | Unary logical not operator (!)+notOp :: Ast.Op+notOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "!"),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 13),+      Ast.opAssociativity = Ast.AssociativityNone}+-- | Logical OR operator (||)+orOp :: Ast.Op+orOp = Serialization.op "||" 3 Ast.AssociativityLeft+-- | Inclusive range operator (..=)+rangeInclusiveOp :: Ast.Op+rangeInclusiveOp = Serialization.op "..=" 2 Ast.AssociativityNone+-- | Range operator (..)+rangeOp :: Ast.Op+rangeOp = Serialization.op ".." 2 Ast.AssociativityNone+-- | Reference operator (&)+refOp :: Ast.Op+refOp =+    Ast.Op {+      Ast.opSymbol = (Ast.Symbol "&"),+      Ast.opPadding = Ast.Padding {+        Ast.paddingLeft = Ast.WsNone,+        Ast.paddingRight = Ast.WsNone},+      Ast.opPrecedence = (Ast.Precedence 13),+      Ast.opAssociativity = Ast.AssociativityNone}+-- | Rem-assign operator (%=)+remAssignOp :: Ast.Op+remAssignOp = Serialization.op "%=" 1 Ast.AssociativityRight+-- | Remainder operator (%)+remOp :: Ast.Op+remOp = Serialization.op "%" 11 Ast.AssociativityLeft+-- | Shift-left assign operator (<<=)+shlAssignOp :: Ast.Op+shlAssignOp = Serialization.op "<<=" 1 Ast.AssociativityRight+-- | Shift-left operator (<<)+shlOp :: Ast.Op+shlOp = Serialization.op "<<" 9 Ast.AssociativityLeft+-- | Shift-right assign operator (>>=)+shrAssignOp :: Ast.Op+shrAssignOp = Serialization.op ">>=" 1 Ast.AssociativityRight+-- | Shift-right operator (>>)+shrOp :: Ast.Op+shrOp = Serialization.op ">>" 9 Ast.AssociativityLeft+-- | Sub-assign operator (-=)+subAssignOp :: Ast.Op+subAssignOp = Serialization.op "-=" 1 Ast.AssociativityRight+-- | Subtraction operator (-)+subOp :: Ast.Op+subOp = Serialization.op "-" 10 Ast.AssociativityLeft
+ src/main/haskell/Hydra/Rust/Serde.hs view
@@ -0,0 +1,1309 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Rust serializer: converts Rust AST to concrete syntax++module Hydra.Rust.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Constants as Constants+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Rust.Operators as Operators+import qualified Hydra.Rust.Syntax as Syntax+import qualified Hydra.Serialization as Serialization+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Serialize an array expression+arrayExprToExpr :: Syntax.ArrayExpr -> Ast.Expr+arrayExprToExpr a =+    case a of+      Syntax.ArrayExprElements v0 -> Serialization.bracketList Serialization.halfBlockStyle (Lists.map expressionToExpr v0)+      Syntax.ArrayExprRepeat v0 ->+        let elem = Syntax.arrayRepeatElement v0+            len = Syntax.arrayRepeatLength v0+        in (Serialization.cst (Strings.cat [+          "[",+          (Serialization.printExpr (expressionToExpr elem)),+          "; ",+          (Serialization.printExpr (expressionToExpr len)),+          "]"]))+-- | Serialize an assignment expression+assignExprToExpr :: Syntax.AssignExpr -> Ast.Expr+assignExprToExpr a =++      let target = Syntax.assignExprTarget a+          val = Syntax.assignExprValue a+      in (Serialization.spaceSep [+        expressionToExpr target,+        (Serialization.cst "="),+        (expressionToExpr val)])+-- | Serialize an attribute+attributeToExpr :: Syntax.Attribute -> Ast.Expr+attributeToExpr attr =++      let inner = Syntax.attributeInner attr+          path = Syntax.attributePath attr+          tokens = Syntax.attributeTokens attr+          prefix = Logic.ifElse inner "#![" "#["+          pathStr = Strings.intercalate "::" path+          tokensPart =+                  Optionals.cases tokens "" (\t -> Strings.cat [+                    "(",+                    t,+                    ")"])+      in (Serialization.cst (Strings.cat [+        prefix,+        pathStr,+        tokensPart,+        "]"]))+-- | Serialize a binary expression+binaryExprToExpr :: Syntax.BinaryExpr -> Ast.Expr+binaryExprToExpr b =++      let left = Syntax.binaryExprLeft b+          op = Syntax.binaryExprOp b+          right = Syntax.binaryExprRight b+      in (Serialization.spaceSep [+        expressionToExpr left,+        (binaryOpToExpr op),+        (expressionToExpr right)])+-- | Serialize a binary operator+binaryOpToExpr :: Syntax.BinaryOp -> Ast.Expr+binaryOpToExpr op =+    Serialization.cst (case op of+      Syntax.BinaryOpAdd -> "+"+      Syntax.BinaryOpSub -> "-"+      Syntax.BinaryOpMul -> "*"+      Syntax.BinaryOpDiv -> "/"+      Syntax.BinaryOpRem -> "%"+      Syntax.BinaryOpAnd -> "&&"+      Syntax.BinaryOpOr -> "||"+      Syntax.BinaryOpBitAnd -> "&"+      Syntax.BinaryOpBitOr -> "|"+      Syntax.BinaryOpBitXor -> "^"+      Syntax.BinaryOpShl -> "<<"+      Syntax.BinaryOpShr -> ">>"+      Syntax.BinaryOpEq -> "=="+      Syntax.BinaryOpNe -> "!="+      Syntax.BinaryOpLt -> "<"+      Syntax.BinaryOpLe -> "<="+      Syntax.BinaryOpGt -> ">"+      Syntax.BinaryOpGe -> ">=")+-- | Serialize a block+blockToExpr :: Syntax.Block -> Ast.Expr+blockToExpr b =++      let stmts = Syntax.blockStatements b+          expr = Syntax.blockExpression b+          stmtExprs = Lists.map statementToExpr stmts+          exprPart = Optionals.cases expr [] (\e -> [+                expressionToExpr e])+          allParts = Lists.concat2 stmtExprs exprPart+      in (Serialization.curlyBracesList Nothing Serialization.halfBlockStyle allParts)+-- | Serialize a function call expression+callExprToExpr :: Syntax.CallExpr -> Ast.Expr+callExprToExpr c =++      let func = Syntax.callExprFunction c+          args = Syntax.callExprArgs c+      in (Serialization.spaceSep [+        expressionToExpr func,+        (Serialization.parenListAdaptive (Lists.map expressionToExpr args))])+-- | Serialize a cast expression+castExprToExpr :: Syntax.CastExpr -> Ast.Expr+castExprToExpr c =++      let expr = Syntax.castExprExpr c+          typ = Syntax.castExprType c+      in (Serialization.spaceSep [+        expressionToExpr expr,+        (Serialization.cst "as"),+        (typeToExpr typ)])+-- | Serialize a closure expression+closureExprToExpr :: Syntax.ClosureExpr -> Ast.Expr+closureExprToExpr c =++      let move = Syntax.closureExprMove c+          params = Syntax.closureExprParams c+          retType = Syntax.closureExprReturnType c+          body = Syntax.closureExprBody c+          moveKw = Logic.ifElse move (Just (Serialization.cst "move")) Nothing+          paramsStr =+                  Strings.cat [+                    "|",+                    (Strings.intercalate ", " (Lists.map closureParamToStr params)),+                    "|"]+          retPart =+                  Optionals.cases retType Nothing (\t -> Just (Serialization.spaceSep [+                    Serialization.cst "->",+                    (typeToExpr t)]))+      in (Serialization.spaceSep (Optionals.cat [+        moveKw,+        (Just (Serialization.cst paramsStr)),+        retPart,+        (Just (expressionToExpr body))]))+-- | Serialize a closure parameter to string+closureParamToStr :: Syntax.ClosureParam -> String+closureParamToStr cp =++      let pat = Syntax.closureParamPattern cp+          typ = Syntax.closureParamType cp+          patStr = Serialization.printExpr (patternToExpr pat)+      in (Optionals.cases typ patStr (\t -> Strings.cat [+        patStr,+        ": ",+        (Serialization.printExpr (typeToExpr t))]))+-- | Serialize a compound assignment expression+compoundAssignExprToExpr :: Syntax.CompoundAssignExpr -> Ast.Expr+compoundAssignExprToExpr c =++      let target = Syntax.compoundAssignExprTarget c+          op = Syntax.compoundAssignExprOp c+          val = Syntax.compoundAssignExprValue c+          opStr =+                  case op of+                    Syntax.CompoundAssignOpAddAssign -> "+="+                    Syntax.CompoundAssignOpSubAssign -> "-="+                    Syntax.CompoundAssignOpMulAssign -> "*="+                    Syntax.CompoundAssignOpDivAssign -> "/="+                    Syntax.CompoundAssignOpRemAssign -> "%="+                    Syntax.CompoundAssignOpBitAndAssign -> "&="+                    Syntax.CompoundAssignOpBitOrAssign -> "|="+                    Syntax.CompoundAssignOpBitXorAssign -> "^="+                    Syntax.CompoundAssignOpShlAssign -> "<<="+                    Syntax.CompoundAssignOpShrAssign -> ">>="+      in (Serialization.spaceSep [+        expressionToExpr target,+        (Serialization.cst opStr),+        (expressionToExpr val)])+-- | Serialize a const definition+constDefToExpr :: Syntax.ConstDef -> Ast.Expr+constDefToExpr c =++      let name = Syntax.constDefName c+          typ = Syntax.constDefType c+          val = Syntax.constDefValue c+      in (Serialization.spaceSep [+        Serialization.cst "const",+        (Serialization.cst (Strings.cat2 name ":")),+        (typeToExpr typ),+        (Serialization.cst "="),+        (expressionToExpr val),+        (Serialization.cst ";")])+-- | Serialize a Rust crate to an AST expression+crateToExpr :: Syntax.Crate -> Ast.Expr+crateToExpr crate = Serialization.doubleNewlineSep (Lists.map itemWithCommentsToExpr (Syntax.crateItems crate))+-- | Serialize derive macros to an attribute expression+derivesToExpr :: [String] -> Maybe Ast.Expr+derivesToExpr derives =+    Logic.ifElse (Lists.null derives) Nothing (Just (Serialization.cst (Strings.cat [+      "#[derive(",+      (Strings.intercalate ", " derives),+      ")]"])))+-- | Serialize an enum definition+enumDefToExpr :: Syntax.EnumDef -> Ast.Expr+enumDefToExpr e =++      let name = Syntax.enumDefName e+          generics = Syntax.enumDefGenerics e+          whereC = Syntax.enumDefWhereClause e+          variants = Syntax.enumDefVariants e+          derives = Syntax.enumDefDerives e+          docC = Syntax.enumDefDoc e+          derivesAttr = derivesToExpr derives+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          header =+                  Serialization.spaceSep (Optionals.cat [+                    Just (Serialization.cst "enum"),+                    (Just (Serialization.cst name)),+                    (genericParamsToExpr generics)])+          wherePart = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+          body = Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map enumVariantToExpr variants)+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        (Optionals.cases derivesAttr [] (\d -> [+          d])),+        [+          Serialization.spaceSep (Optionals.cat [+            Just header,+            wherePart,+            (Just body)])]]))+-- | Serialize an enum variant body+enumVariantBodyToExpr :: Syntax.EnumVariantBody -> Ast.Expr+enumVariantBodyToExpr body =+    case body of+      Syntax.EnumVariantBodyUnit -> Serialization.cst ""+      Syntax.EnumVariantBodyTuple v0 -> Serialization.parenListAdaptive (Lists.map typeToExpr v0)+      Syntax.EnumVariantBodyStruct v0 -> Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map structFieldToExpr v0)+-- | Serialize an enum variant+enumVariantToExpr :: Syntax.EnumVariant -> Ast.Expr+enumVariantToExpr v =++      let name = Syntax.enumVariantName v+          body = Syntax.enumVariantBody v+          docC = Syntax.enumVariantDoc v+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep [+            Serialization.cst name,+            (enumVariantBodyToExpr body)]]]))+-- | Serialize an expression path+exprPathToExpr :: Syntax.ExprPath -> Ast.Expr+exprPathToExpr ep =++      let global = Syntax.exprPathGlobal ep+          segs = Syntax.exprPathSegments ep+          prefix = Logic.ifElse global "::" ""+          segStrs = Lists.map (\s -> Serialization.printExpr (pathSegmentToExpr s)) segs+      in (Serialization.cst (Strings.cat2 prefix (Strings.intercalate "::" segStrs)))+-- | Serialize a Rust expression+expressionToExpr :: Syntax.Expression -> Ast.Expr+expressionToExpr expr =+    case expr of+      Syntax.ExpressionLiteral v0 -> literalToExpr v0+      Syntax.ExpressionPath v0 -> exprPathToExpr v0+      Syntax.ExpressionBlock v0 -> blockToExpr v0+      Syntax.ExpressionCall v0 -> callExprToExpr v0+      Syntax.ExpressionMethodCall v0 -> methodCallExprToExpr v0+      Syntax.ExpressionFieldAccess v0 -> fieldAccessExprToExpr v0+      Syntax.ExpressionTupleIndex v0 -> tupleIndexExprToExpr v0+      Syntax.ExpressionClosure v0 -> closureExprToExpr v0+      Syntax.ExpressionIf v0 -> ifExprToExpr v0+      Syntax.ExpressionMatch v0 -> matchExprToExpr v0+      Syntax.ExpressionLoop v0 -> loopExprToExpr v0+      Syntax.ExpressionWhile v0 -> whileExprToExpr v0+      Syntax.ExpressionFor v0 -> forExprToExpr v0+      Syntax.ExpressionBinary v0 -> binaryExprToExpr v0+      Syntax.ExpressionUnary v0 -> unaryExprToExpr v0+      Syntax.ExpressionReference v0 -> refExprToExpr v0+      Syntax.ExpressionDereference v0 -> Serialization.prefix "*" (expressionToExpr v0)+      Syntax.ExpressionStruct v0 -> structExprToExpr v0+      Syntax.ExpressionTuple v0 -> Serialization.parenListAdaptive (Lists.map expressionToExpr v0)+      Syntax.ExpressionArray v0 -> arrayExprToExpr v0+      Syntax.ExpressionIndex v0 -> indexExprToExpr v0+      Syntax.ExpressionRange v0 -> rangeExprToExpr v0+      Syntax.ExpressionReturn v0 -> Optionals.cases v0 (Serialization.cst "return") (\e -> Serialization.spaceSep [+        Serialization.cst "return",+        (expressionToExpr e)])+      Syntax.ExpressionBreak v0 -> Optionals.cases v0 (Serialization.cst "break") (\e -> Serialization.spaceSep [+        Serialization.cst "break",+        (expressionToExpr e)])+      Syntax.ExpressionContinue -> Serialization.cst "continue"+      Syntax.ExpressionTry v0 -> Serialization.cst (Strings.cat2 (Serialization.printExpr (expressionToExpr v0)) "?")+      Syntax.ExpressionCast v0 -> castExprToExpr v0+      Syntax.ExpressionTypeAscription v0 -> typeAscriptionExprToExpr v0+      Syntax.ExpressionAwait v0 -> Serialization.cst (Strings.cat2 (Serialization.printExpr (expressionToExpr v0)) ".await")+      Syntax.ExpressionAssign v0 -> assignExprToExpr v0+      Syntax.ExpressionCompoundAssign v0 -> compoundAssignExprToExpr v0+      Syntax.ExpressionMacro v0 -> macroInvocationToExpr v0+      Syntax.ExpressionParen v0 -> Serialization.parenthesize (expressionToExpr v0)+-- | Serialize a field access expression+fieldAccessExprToExpr :: Syntax.FieldAccessExpr -> Ast.Expr+fieldAccessExprToExpr f =++      let obj = Syntax.fieldAccessExprObject f+          field = Syntax.fieldAccessExprField f+      in (Serialization.cst (Strings.cat [+        Serialization.printExpr (expressionToExpr obj),+        ".",+        field]))+-- | Serialize a field pattern+fieldPatternToExpr :: Syntax.FieldPattern -> Ast.Expr+fieldPatternToExpr fp =++      let name = Syntax.fieldPatternName fp+          pat = Syntax.fieldPatternPattern fp+      in (Optionals.cases pat (Serialization.cst name) (\p -> Serialization.spaceSep [+        Serialization.cst (Strings.cat2 name ":"),+        (patternToExpr p)]))+-- | Serialize a field-value pair+fieldValueToExpr :: Syntax.FieldValue -> Ast.Expr+fieldValueToExpr fv =++      let name = Syntax.fieldValueName fv+          val = Syntax.fieldValueValue fv+      in (Optionals.cases val (Serialization.cst name) (\v -> Serialization.spaceSep [+        Serialization.cst (Strings.cat2 name ":"),+        (expressionToExpr v)]))+-- | Serialize a float literal+floatLiteralToExpr :: Syntax.FloatLiteral -> Ast.Expr+floatLiteralToExpr fl =++      let val = Syntax.floatLiteralValue fl+          suf = Syntax.floatLiteralSuffix fl+          valStr = Literals.showFloat64 val+          sufStr = Optionals.cases suf "" (\s -> s)+      in (Serialization.cst (Strings.cat2 valStr sufStr))+-- | Serialize a function definition+fnDefToExpr :: Syntax.FnDef -> Ast.Expr+fnDefToExpr f =++      let name = Syntax.fnDefName f+          generics = Syntax.fnDefGenerics f+          whereC = Syntax.fnDefWhereClause f+          params = Syntax.fnDefParams f+          retType = Syntax.fnDefReturnType f+          body = Syntax.fnDefBody f+          isAsync = Syntax.fnDefAsync f+          isConst = Syntax.fnDefConst f+          isUnsafe = Syntax.fnDefUnsafe f+          docC = Syntax.fnDefDoc f+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          asyncKw = Logic.ifElse isAsync (Just (Serialization.cst "async")) Nothing+          constKw = Logic.ifElse isConst (Just (Serialization.cst "const")) Nothing+          unsafeKw = Logic.ifElse isUnsafe (Just (Serialization.cst "unsafe")) Nothing+          fnKw = Serialization.cst "fn"+          nameExpr = Serialization.cst name+          genericsExpr = genericParamsToExpr generics+          paramsExpr = Serialization.parenListAdaptive (Lists.map fnParamToExpr params)+          retTypeExpr =+                  Optionals.cases retType Nothing (\t -> Just (Serialization.spaceSep [+                    Serialization.cst "->",+                    (typeToExpr t)]))+          whereExpr = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+          header =+                  Serialization.spaceSep (Optionals.cat [+                    asyncKw,+                    constKw,+                    unsafeKw,+                    (Just fnKw),+                    (Just nameExpr),+                    genericsExpr,+                    (Just paramsExpr),+                    retTypeExpr,+                    whereExpr])+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep [+            header,+            (blockToExpr body)]]]))+-- | Serialize a function parameter+fnParamToExpr :: Syntax.FnParam -> Ast.Expr+fnParamToExpr param =++      let pat = Syntax.fnParamPattern param+          typ = Syntax.fnParamType param+      in (Serialization.spaceSep [+        Serialization.cst (Strings.cat2 (Serialization.printExpr (patternToExpr pat)) ":"),+        (typeToExpr typ)])+-- | Serialize a for expression+forExprToExpr :: Syntax.ForExpr -> Ast.Expr+forExprToExpr f =++      let label = Syntax.forExprLabel f+          pat = Syntax.forExprPattern f+          iter = Syntax.forExprIter f+          body = Syntax.forExprBody f+          labelPart = Optionals.cases label Nothing (\lbl -> Just (Serialization.cst (Strings.cat2 "'" (Strings.cat2 lbl ":"))))+      in (Serialization.spaceSep (Optionals.cat [+        labelPart,+        (Just (Serialization.cst "for")),+        (Just (patternToExpr pat)),+        (Just (Serialization.cst "in")),+        (Just (expressionToExpr iter)),+        (Just (blockToExpr body))]))+-- | Serialize a generic argument+genericArgToExpr :: Syntax.GenericArg -> Ast.Expr+genericArgToExpr arg =+    case arg of+      Syntax.GenericArgType v0 -> typeToExpr v0+      Syntax.GenericArgLifetime v0 -> Serialization.cst (Strings.cat2 "'" (Syntax.lifetimeName v0))+      Syntax.GenericArgConst v0 -> expressionToExpr v0+      Syntax.GenericArgBinding v0 ->+        let name = Syntax.typeBindingName v0+            typ = Syntax.typeBindingType v0+        in (Serialization.spaceSep [+          Serialization.cst name,+          (Serialization.cst "="),+          (typeToExpr typ)])+-- | Serialize generic arguments+genericArgumentsToExpr :: Syntax.GenericArguments -> Maybe Ast.Expr+genericArgumentsToExpr args =+    case args of+      Syntax.GenericArgumentsNone -> Nothing+      Syntax.GenericArgumentsAngleBracketed v0 ->+        let args = Syntax.angleBracketedArgsArgs v0+        in (Just (Serialization.angleBracesList Serialization.inlineStyle (Lists.map genericArgToExpr args)))+      Syntax.GenericArgumentsParenthesized v0 ->+        let inputs = Syntax.parenthesizedArgsInputs v0+            output = Syntax.parenthesizedArgsOutput v0+            inputPart = Serialization.parenListAdaptive (Lists.map typeToExpr inputs)+            outputPart =+                    Optionals.cases output Nothing (\t -> Just (Serialization.spaceSep [+                      Serialization.cst "->",+                      (typeToExpr t)]))+        in (Just (Serialization.spaceSep (Optionals.cat [+          Just inputPart,+          outputPart])))+-- | Serialize a generic parameter+genericParamToExpr :: Syntax.GenericParam -> Ast.Expr+genericParamToExpr gp =++      let name = Syntax.genericParamName gp+          bounds = Syntax.genericParamBounds gp+      in (Logic.ifElse (Lists.null bounds) (Serialization.cst name) (Serialization.spaceSep [+        Serialization.cst (Strings.cat2 name ":"),+        (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) bounds)))]))+-- | Serialize a list of generic parameters+genericParamsToExpr :: [Syntax.GenericParam] -> Maybe Ast.Expr+genericParamsToExpr gps =+    Logic.ifElse (Lists.null gps) Nothing (Just (Serialization.angleBracesList Serialization.inlineStyle (Lists.map genericParamToExpr gps)))+-- | Serialize an identifier pattern+identifierPatternToExpr :: Syntax.IdentifierPattern -> Ast.Expr+identifierPatternToExpr ip =++      let name = Syntax.identifierPatternName ip+          mut = Syntax.identifierPatternMutable ip+          atPat = Syntax.identifierPatternAtPattern ip+          mutKw = Logic.ifElse mut (Just (Serialization.cst "mut")) Nothing+          atPart =+                  Optionals.cases atPat Nothing (\p -> Just (Serialization.spaceSep [+                    Serialization.cst "@",+                    (patternToExpr p)]))+      in (Serialization.spaceSep (Optionals.cat [+        mutKw,+        (Just (Serialization.cst name)),+        atPart]))+-- | Serialize an if expression+ifExprToExpr :: Syntax.IfExpr -> Ast.Expr+ifExprToExpr i =++      let cond = Syntax.ifExprCondition i+          thenB = Syntax.ifExprThenBlock i+          elseB = Syntax.ifExprElseBranch i+          condExpr =+                  case cond of+                    Syntax.IfConditionBool v0 -> expressionToExpr v0+                    Syntax.IfConditionLet v0 ->+                      let pat = Syntax.letConditionPattern v0+                          expr = Syntax.letConditionExpr v0+                      in (Serialization.spaceSep [+                        Serialization.cst "let",+                        (patternToExpr pat),+                        (Serialization.cst "="),+                        (expressionToExpr expr)])+          elsePart =+                  Optionals.cases elseB Nothing (\e -> Just (Serialization.spaceSep [+                    Serialization.cst "else",+                    (expressionToExpr e)]))+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst "if"),+        (Just condExpr),+        (Just (blockToExpr thenB)),+        elsePart]))+-- | Serialize an impl block+implBlockToExpr :: Syntax.ImplBlock -> Ast.Expr+implBlockToExpr i =++      let generics = Syntax.implBlockGenerics i+          whereC = Syntax.implBlockWhereClause i+          trait = Syntax.implBlockTrait i+          selfType = Syntax.implBlockSelfType i+          items = Syntax.implBlockItems i+          genericsExpr = genericParamsToExpr generics+          traitPart =+                  Optionals.cases trait Nothing (\t -> Just (Serialization.spaceSep [+                    typePathToExpr t,+                    (Serialization.cst "for")]))+          wherePart = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+          header =+                  Serialization.spaceSep (Optionals.cat [+                    Just (Serialization.cst "impl"),+                    genericsExpr,+                    traitPart,+                    (Just (typeToExpr selfType)),+                    wherePart])+          body = Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map implItemToExpr items)+      in (Serialization.spaceSep [+        header,+        body])+-- | Serialize an impl item+implItemToExpr :: Syntax.ImplItem -> Ast.Expr+implItemToExpr item =+    case item of+      Syntax.ImplItemMethod v0 -> implMethodToExpr v0+      Syntax.ImplItemType v0 -> typeAliasToExpr v0+      Syntax.ImplItemConst v0 -> constDefToExpr v0+-- | Serialize an impl method+implMethodToExpr :: Syntax.ImplMethod -> Ast.Expr+implMethodToExpr m =++      let name = Syntax.implMethodName m+          generics = Syntax.implMethodGenerics m+          whereC = Syntax.implMethodWhereClause m+          params = Syntax.implMethodParams m+          retType = Syntax.implMethodReturnType m+          body = Syntax.implMethodBody m+          pub = Syntax.implMethodPublic m+          docC = Syntax.implMethodDoc m+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          pubKw = Logic.ifElse pub (Just (Serialization.cst "pub")) Nothing+          genericsExpr = genericParamsToExpr generics+          paramsExpr = Serialization.parenListAdaptive (Lists.map methodParamToExpr params)+          retTypeExpr =+                  Optionals.cases retType Nothing (\t -> Just (Serialization.spaceSep [+                    Serialization.cst "->",+                    (typeToExpr t)]))+          whereExpr = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+          header =+                  Serialization.spaceSep (Optionals.cat [+                    pubKw,+                    (Just (Serialization.cst "fn")),+                    (Just (Serialization.cst name)),+                    genericsExpr,+                    (Just paramsExpr),+                    retTypeExpr,+                    whereExpr])+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep [+            header,+            (blockToExpr body)]]]))+-- | Serialize an index expression+indexExprToExpr :: Syntax.IndexExpr -> Ast.Expr+indexExprToExpr i =++      let obj = Syntax.indexExprObject i+          idx = Syntax.indexExprIndex i+      in (Serialization.cst (Strings.cat [+        Serialization.printExpr (expressionToExpr obj),+        "[",+        (Serialization.printExpr (expressionToExpr idx)),+        "]"]))+-- | Serialize an integer literal+integerLiteralToExpr :: Syntax.IntegerLiteral -> Ast.Expr+integerLiteralToExpr il =++      let val = Syntax.integerLiteralValue il+          suf = Syntax.integerLiteralSuffix il+          valStr = Literals.showBigint val+          sufStr = Optionals.cases suf "" (\s -> s)+      in (Serialization.cst (Strings.cat2 valStr sufStr))+-- | Serialize a Rust item to an AST expression+itemToExpr :: Syntax.Item -> Ast.Expr+itemToExpr item =+    case item of+      Syntax.ItemUse v0 -> useDeclarationToExpr v0+      Syntax.ItemStruct v0 -> structDefToExpr v0+      Syntax.ItemEnum v0 -> enumDefToExpr v0+      Syntax.ItemFn v0 -> fnDefToExpr v0+      Syntax.ItemTypeAlias v0 -> typeAliasToExpr v0+      Syntax.ItemImpl v0 -> implBlockToExpr v0+      Syntax.ItemTrait v0 -> traitDefToExpr v0+      Syntax.ItemMod v0 -> modDefToExpr v0+      Syntax.ItemConst v0 -> constDefToExpr v0+      Syntax.ItemStatic v0 -> staticDefToExpr v0+      Syntax.ItemMacro v0 -> macroInvocationToExpr v0+-- | Serialize an item with optional doc comments and visibility+itemWithCommentsToExpr :: Syntax.ItemWithComments -> Ast.Expr+itemWithCommentsToExpr iwc =++      let doc = Syntax.itemWithCommentsDoc iwc+          vis = Syntax.itemWithCommentsVisibility iwc+          item = Syntax.itemWithCommentsItem iwc+          docPart = Optionals.cases doc [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          visPart = visibilityToExpr vis+          itemPart = itemToExpr item+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep (Optionals.cat [+            visPart,+            (Just itemPart)])]]))+-- | Serialize a let statement+letStatementToExpr :: Syntax.LetStatement -> Ast.Expr+letStatementToExpr l =++      let pat = Syntax.letStatementPattern l+          mut = Syntax.letStatementMutable l+          typ = Syntax.letStatementType l+          init = Syntax.letStatementInit l+          mutKw = Logic.ifElse mut (Just (Serialization.cst "mut")) Nothing+          typPart =+                  Optionals.cases typ Nothing (\t -> Just (Serialization.spaceSep [+                    Serialization.cst ":",+                    (typeToExpr t)]))+          initPart =+                  Optionals.cases init Nothing (\e -> Just (Serialization.spaceSep [+                    Serialization.cst "=",+                    (expressionToExpr e)]))+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst "let"),+        mutKw,+        (Just (patternToExpr pat)),+        typPart,+        initPart,+        (Just (Serialization.cst ";"))]))+-- | Serialize a literal+literalToExpr :: Syntax.Literal -> Ast.Expr+literalToExpr lit =+    case lit of+      Syntax.LiteralInteger v0 -> integerLiteralToExpr v0+      Syntax.LiteralFloat v0 -> floatLiteralToExpr v0+      Syntax.LiteralString v0 -> Serialization.cst (Literals.showString v0)+      Syntax.LiteralRawString v0 -> Serialization.cst (Strings.cat [+        "r\"",+        v0,+        "\""])+      Syntax.LiteralByteString _ -> Serialization.cst "b\"...\""+      Syntax.LiteralChar v0 -> Serialization.cst (Strings.cat [+        "'",+        (Literals.showUint32 v0),+        "'"])+      Syntax.LiteralByte v0 -> Serialization.cst (Strings.cat [+        "b'",+        (Literals.showUint8 v0),+        "'"])+      Syntax.LiteralBool v0 -> Serialization.cst (Logic.ifElse v0 "true" "false")+-- | Serialize a loop expression+loopExprToExpr :: Syntax.LoopExpr -> Ast.Expr+loopExprToExpr l =++      let label = Syntax.loopExprLabel l+          body = Syntax.loopExprBody l+          labelPart = Optionals.cases label Nothing (\lbl -> Just (Serialization.cst (Strings.cat2 "'" (Strings.cat2 lbl ":"))))+      in (Serialization.spaceSep (Optionals.cat [+        labelPart,+        (Just (Serialization.cst "loop")),+        (Just (blockToExpr body))]))+-- | Serialize a macro invocation+macroInvocationToExpr :: Syntax.MacroInvocation -> Ast.Expr+macroInvocationToExpr m =++      let path = Syntax.macroInvocationPath m+          delim = Syntax.macroInvocationDelimiter m+          tokens = Syntax.macroInvocationTokens m+          pathStr = Strings.intercalate "::" path+          open =+                  case delim of+                    Syntax.MacroDelimiterParen -> "("+                    Syntax.MacroDelimiterBracket -> "["+                    Syntax.MacroDelimiterBrace -> "{"+          close =+                  case delim of+                    Syntax.MacroDelimiterParen -> ")"+                    Syntax.MacroDelimiterBracket -> "]"+                    Syntax.MacroDelimiterBrace -> "}"+      in (Serialization.cst (Strings.cat [+        pathStr,+        "!",+        open,+        tokens,+        close]))+-- | Serialize a match arm+matchArmToExpr :: Syntax.MatchArm -> Ast.Expr+matchArmToExpr arm =++      let pat = Syntax.matchArmPattern arm+          guard = Syntax.matchArmGuard arm+          body = Syntax.matchArmBody arm+          guardPart =+                  Optionals.cases guard Nothing (\g -> Just (Serialization.spaceSep [+                    Serialization.cst "if",+                    (expressionToExpr g)]))+      in (Serialization.spaceSep (Optionals.cat [+        Just (patternToExpr pat),+        guardPart,+        (Just (Serialization.cst "=>")),+        (Just (expressionToExpr body)),+        (Just (Serialization.cst ","))]))+-- | Serialize a match expression+matchExprToExpr :: Syntax.MatchExpr -> Ast.Expr+matchExprToExpr m =++      let scrut = Syntax.matchExprScrutinee m+          arms = Syntax.matchExprArms m+      in (Serialization.spaceSep [+        Serialization.cst "match",+        (expressionToExpr scrut),+        (Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map matchArmToExpr arms))])+-- | Serialize a method call expression+methodCallExprToExpr :: Syntax.MethodCallExpr -> Ast.Expr+methodCallExprToExpr m =++      let recv = Syntax.methodCallExprReceiver m+          method = Syntax.methodCallExprMethod m+          turbo = Syntax.methodCallExprTurbofish m+          args = Syntax.methodCallExprArgs m+          turboPart =+                  Logic.ifElse (Lists.null turbo) "" (Strings.cat [+                    "::<",+                    (Strings.intercalate ", " (Lists.map (\t -> Serialization.printExpr (typeToExpr t)) turbo)),+                    ">"])+      in (Serialization.cst (Strings.cat [+        Serialization.printExpr (expressionToExpr recv),+        ".",+        method,+        turboPart,+        "(",+        (Strings.intercalate ", " (Lists.map (\a -> Serialization.printExpr (expressionToExpr a)) args)),+        ")"]))+-- | Serialize a method parameter+methodParamToExpr :: Syntax.MethodParam -> Ast.Expr+methodParamToExpr param =+    case param of+      Syntax.MethodParamSelf v0 -> case v0 of+        Syntax.SelfParamOwned -> Serialization.cst "self"+        Syntax.SelfParamRef -> Serialization.cst "&self"+        Syntax.SelfParamRefMut -> Serialization.cst "&mut self"+      Syntax.MethodParamRegular v0 -> fnParamToExpr v0+-- | Serialize a module definition+modDefToExpr :: Syntax.ModDef -> Ast.Expr+modDefToExpr m =++      let name = Syntax.modDefName m+          body = Syntax.modDefBody m+      in (Optionals.cases body (Serialization.spaceSep [+        Serialization.cst "mod",+        (Serialization.cst name),+        (Serialization.cst ";")]) (\items -> Serialization.spaceSep [+        Serialization.cst "mod",+        (Serialization.cst name),+        (Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map itemToExpr items))]))+-- | Serialize a path segment+pathSegmentToExpr :: Syntax.PathSegment -> Ast.Expr+pathSegmentToExpr seg =++      let name = Syntax.pathSegmentName seg+          args = Syntax.pathSegmentArguments seg+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst name),+        (genericArgumentsToExpr args)]))+-- | Serialize a pattern+patternToExpr :: Syntax.Pattern -> Ast.Expr+patternToExpr pat =+    case pat of+      Syntax.PatternWildcard -> Serialization.cst "_"+      Syntax.PatternIdentifier v0 -> identifierPatternToExpr v0+      Syntax.PatternLiteral v0 -> literalToExpr v0+      Syntax.PatternReference v0 -> refPatternToExpr v0+      Syntax.PatternStruct v0 -> structPatternToExpr v0+      Syntax.PatternTupleStruct v0 -> tupleStructPatternToExpr v0+      Syntax.PatternTuple v0 -> Serialization.parenListAdaptive (Lists.map patternToExpr v0)+      Syntax.PatternSlice v0 -> Serialization.bracketList Serialization.halfBlockStyle (Lists.map patternToExpr v0)+      Syntax.PatternOr v0 -> Serialization.cst (Strings.intercalate " | " (Lists.map (\p -> Serialization.printExpr (patternToExpr p)) v0))+      Syntax.PatternPath v0 -> exprPathToExpr v0+      Syntax.PatternRange v0 -> rangePatternToExpr v0+      Syntax.PatternRest -> Serialization.cst ".."+      Syntax.PatternParen v0 -> Serialization.parenthesize (patternToExpr v0)+-- | Serialize a range expression+rangeExprToExpr :: Syntax.RangeExpr -> Ast.Expr+rangeExprToExpr r =++      let from = Syntax.rangeExprFrom r+          to = Syntax.rangeExprTo r+          incl = Syntax.rangeExprInclusive r+          fromStr = Optionals.cases from "" (\f -> Serialization.printExpr (expressionToExpr f))+          toStr = Optionals.cases to "" (\t -> Serialization.printExpr (expressionToExpr t))+          op = Logic.ifElse incl "..=" ".."+      in (Serialization.cst (Strings.cat [+        fromStr,+        op,+        toStr]))+-- | Serialize a range pattern+rangePatternToExpr :: Syntax.RangePattern -> Ast.Expr+rangePatternToExpr rp =++      let from = Syntax.rangePatternFrom rp+          to = Syntax.rangePatternTo rp+          incl = Syntax.rangePatternInclusive rp+          fromStr = Optionals.cases from "" (\p -> Serialization.printExpr (patternToExpr p))+          toStr = Optionals.cases to "" (\p -> Serialization.printExpr (patternToExpr p))+          op = Logic.ifElse incl "..=" ".."+      in (Serialization.cst (Strings.cat [+        fromStr,+        op,+        toStr]))+-- | Serialize a reference expression+refExprToExpr :: Syntax.RefExpr -> Ast.Expr+refExprToExpr r =++      let mut = Syntax.refExprMutable r+          expr = Syntax.refExprExpr r+          prefix = Logic.ifElse mut "&mut " "&"+      in (Serialization.cst (Strings.cat2 prefix (Serialization.printExpr (expressionToExpr expr))))+-- | Serialize a reference pattern+refPatternToExpr :: Syntax.RefPattern -> Ast.Expr+refPatternToExpr rp =++      let mut = Syntax.refPatternMutable rp+          pat = Syntax.refPatternPattern rp+          prefix = Logic.ifElse mut "&mut " "&"+      in (Serialization.cst (Strings.cat2 prefix (Serialization.printExpr (patternToExpr pat))))+-- | Serialize a reference type+referenceTypeToExpr :: Syntax.ReferenceType -> Ast.Expr+referenceTypeToExpr rt =++      let lt = Syntax.referenceTypeLifetime rt+          mut = Syntax.referenceTypeMutable rt+          t = Syntax.referenceTypeType rt+          ltPart = Optionals.cases lt "" (\l -> Strings.cat2 "'" (Strings.cat2 (Syntax.lifetimeName l) " "))+          mutPart = Logic.ifElse mut "mut " ""+      in (Serialization.cst (Strings.cat [+        "&",+        ltPart,+        mutPart,+        (Serialization.printExpr (typeToExpr t))]))+-- | Serialize a statement+statementToExpr :: Syntax.Statement -> Ast.Expr+statementToExpr stmt =+    case stmt of+      Syntax.StatementLet v0 -> letStatementToExpr v0+      Syntax.StatementExpression v0 -> Serialization.spaceSep [+        expressionToExpr v0,+        (Serialization.cst ";")]+      Syntax.StatementItem v0 -> itemToExpr v0+      Syntax.StatementEmpty -> Serialization.cst ";"+-- | Serialize a static definition+staticDefToExpr :: Syntax.StaticDef -> Ast.Expr+staticDefToExpr s =++      let name = Syntax.staticDefName s+          typ = Syntax.staticDefType s+          val = Syntax.staticDefValue s+          mut = Syntax.staticDefMutable s+          mutKw = Logic.ifElse mut (Just (Serialization.cst "mut")) Nothing+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst "static"),+        mutKw,+        (Just (Serialization.cst (Strings.cat2 name ":"))),+        (Just (typeToExpr typ)),+        (Just (Serialization.cst "=")),+        (Just (expressionToExpr val)),+        (Just (Serialization.cst ";"))]))+-- | Serialize a struct body+structBodyToExpr :: Syntax.StructBody -> Ast.Expr+structBodyToExpr body =+    case body of+      Syntax.StructBodyNamed v0 -> Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map structFieldToExpr v0)+      Syntax.StructBodyTuple v0 -> Serialization.spaceSep [+        Serialization.parenListAdaptive (Lists.map (\f -> typeToExpr (Syntax.tupleFieldType f)) v0),+        (Serialization.cst ";")]+      Syntax.StructBodyUnit -> Serialization.cst ";"+-- | Serialize a struct definition+structDefToExpr :: Syntax.StructDef -> Ast.Expr+structDefToExpr s =++      let name = Syntax.structDefName s+          generics = Syntax.structDefGenerics s+          whereC = Syntax.structDefWhereClause s+          body = Syntax.structDefBody s+          derives = Syntax.structDefDerives s+          docC = Syntax.structDefDoc s+          derivesAttr = derivesToExpr derives+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          header =+                  Serialization.spaceSep (Optionals.cat [+                    Just (Serialization.cst "struct"),+                    (Just (Serialization.cst name)),+                    (genericParamsToExpr generics)])+          wherePart = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        (Optionals.cases derivesAttr [] (\d -> [+          d])),+        [+          Serialization.spaceSep (Optionals.cat [+            Just header,+            wherePart,+            (Just (structBodyToExpr body))])]]))+-- | Serialize a struct literal expression+structExprToExpr :: Syntax.StructExpr -> Ast.Expr+structExprToExpr s =++      let path = Syntax.structExprPath s+          fields = Syntax.structExprFields s+          rest = Syntax.structExprRest s+          fieldExprs = Lists.map fieldValueToExpr fields+          restExpr =+                  Optionals.cases rest [] (\r -> [+                    Serialization.spaceSep [+                      Serialization.cst "..",+                      (expressionToExpr r)]])+          allFields = Lists.concat2 fieldExprs restExpr+      in (Serialization.spaceSep [+        exprPathToExpr path,+        (Serialization.curlyBracesList Nothing Serialization.halfBlockStyle allFields)])+-- | Serialize a struct field+structFieldToExpr :: Syntax.StructField -> Ast.Expr+structFieldToExpr field =++      let name = Syntax.structFieldName field+          typ = Syntax.structFieldType field+          pub = Syntax.structFieldPublic field+          docC = Syntax.structFieldDoc field+          pubKw = Logic.ifElse pub (Just (Serialization.cst "pub")) Nothing+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep (Optionals.cat [+            pubKw,+            (Just (Serialization.cst (Strings.cat2 name ":"))),+            (Just (typeToExpr typ))])]]))+-- | Serialize a struct pattern+structPatternToExpr :: Syntax.StructPattern -> Ast.Expr+structPatternToExpr sp =++      let path = Syntax.structPatternPath sp+          fields = Syntax.structPatternFields sp+          rest = Syntax.structPatternRest sp+          fieldExprs = Lists.map fieldPatternToExpr fields+          restExpr = Logic.ifElse rest [+                Serialization.cst ".."] []+          allFields = Lists.concat2 fieldExprs restExpr+      in (Serialization.spaceSep [+        exprPathToExpr path,+        (Serialization.curlyBracesList Nothing Serialization.halfBlockStyle allFields)])+-- | Convert a string to Rust line comments. Empty source lines emit `//` (no trailing space).+toRustComment :: String -> String+toRustComment c =+    Strings.intercalate "\n" (Lists.map (\s -> Logic.ifElse (Equality.equal s "") "//" (Strings.cat2 "// " s)) (Strings.lines c))+-- | Convert a string to Rust doc comments. Empty source lines emit `///` (no trailing space) so blank doc lines don't carry trailing whitespace.+toRustDocComment :: String -> String+toRustDocComment c =+    Strings.intercalate "\n" (Lists.map (\s -> Logic.ifElse (Equality.equal s "") "///" (Strings.cat2 "/// " s)) (Strings.lines c))+-- | Serialize a trait associated constant+traitConstToExpr :: Syntax.TraitConst -> Ast.Expr+traitConstToExpr c =++      let name = Syntax.traitConstName c+          typ = Syntax.traitConstType c+          def = Syntax.traitConstDefault c+          defPart =+                  Optionals.cases def Nothing (\d -> Just (Serialization.spaceSep [+                    Serialization.cst "=",+                    (expressionToExpr d)]))+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst "const"),+        (Just (Serialization.cst (Strings.cat2 name ":"))),+        (Just (typeToExpr typ)),+        defPart,+        (Just (Serialization.cst ";"))]))+-- | Serialize a trait definition+traitDefToExpr :: Syntax.TraitDef -> Ast.Expr+traitDefToExpr t =++      let name = Syntax.traitDefName t+          generics = Syntax.traitDefGenerics t+          whereC = Syntax.traitDefWhereClause t+          supers = Syntax.traitDefSuperTraits t+          items = Syntax.traitDefItems t+          isUnsafe = Syntax.traitDefUnsafe t+          docC = Syntax.traitDefDoc t+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+          unsafeKw = Logic.ifElse isUnsafe (Just (Serialization.cst "unsafe")) Nothing+          genericsExpr = genericParamsToExpr generics+          superPart =+                  Logic.ifElse (Lists.null supers) Nothing (Just (Serialization.spaceSep [+                    Serialization.cst ":",+                    (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) supers)))]))+          wherePart = Optionals.cases whereC Nothing (\w -> Just (whereClauseToExpr w))+          header =+                  Serialization.spaceSep (Optionals.cat [+                    unsafeKw,+                    (Just (Serialization.cst "trait")),+                    (Just (Serialization.cst name)),+                    genericsExpr,+                    superPart,+                    wherePart])+          body = Serialization.curlyBracesList Nothing Serialization.halfBlockStyle (Lists.map traitItemToExpr items)+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep [+            header,+            body]]]))+-- | Serialize a trait item+traitItemToExpr :: Syntax.TraitItem -> Ast.Expr+traitItemToExpr item =+    case item of+      Syntax.TraitItemMethod v0 -> traitMethodToExpr v0+      Syntax.TraitItemType v0 -> traitTypeToExpr v0+      Syntax.TraitItemConst v0 -> traitConstToExpr v0+-- | Serialize a trait method+traitMethodToExpr :: Syntax.TraitMethod -> Ast.Expr+traitMethodToExpr m =++      let name = Syntax.traitMethodName m+          generics = Syntax.traitMethodGenerics m+          params = Syntax.traitMethodParams m+          retType = Syntax.traitMethodReturnType m+          defBody = Syntax.traitMethodDefaultBody m+          genericsExpr = genericParamsToExpr generics+          paramsExpr = Serialization.parenListAdaptive (Lists.map methodParamToExpr params)+          retTypeExpr =+                  Optionals.cases retType Nothing (\t -> Just (Serialization.spaceSep [+                    Serialization.cst "->",+                    (typeToExpr t)]))+          header =+                  Serialization.spaceSep (Optionals.cat [+                    Just (Serialization.cst "fn"),+                    (Just (Serialization.cst name)),+                    genericsExpr,+                    (Just paramsExpr),+                    retTypeExpr])+      in (Optionals.cases defBody (Serialization.spaceSep [+        header,+        (Serialization.cst ";")]) (\body -> Serialization.spaceSep [+        header,+        (blockToExpr body)]))+-- | Serialize a trait associated type+traitTypeToExpr :: Syntax.TraitType -> Ast.Expr+traitTypeToExpr t =++      let name = Syntax.traitTypeName t+          bounds = Syntax.traitTypeBounds t+          def = Syntax.traitTypeDefault t+          boundsPart =+                  Logic.ifElse (Lists.null bounds) Nothing (Just (Serialization.spaceSep [+                    Serialization.cst ":",+                    (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) bounds)))]))+          defPart =+                  Optionals.cases def Nothing (\d -> Just (Serialization.spaceSep [+                    Serialization.cst "=",+                    (typeToExpr d)]))+      in (Serialization.spaceSep (Optionals.cat [+        Just (Serialization.cst "type"),+        (Just (Serialization.cst name)),+        boundsPart,+        defPart,+        (Just (Serialization.cst ";"))]))+-- | Serialize a tuple index expression+tupleIndexExprToExpr :: Syntax.TupleIndexExpr -> Ast.Expr+tupleIndexExprToExpr t =++      let tuple = Syntax.tupleIndexExprTuple t+          idx = Syntax.tupleIndexExprIndex t+      in (Serialization.cst (Strings.cat [+        Serialization.printExpr (expressionToExpr tuple),+        ".",+        (Literals.showInt32 idx)]))+-- | Serialize a tuple struct pattern+tupleStructPatternToExpr :: Syntax.TupleStructPattern -> Ast.Expr+tupleStructPatternToExpr tsp =++      let path = Syntax.tupleStructPatternPath tsp+          elems = Syntax.tupleStructPatternElements tsp+      in (Serialization.spaceSep [+        exprPathToExpr path,+        (Serialization.parenListAdaptive (Lists.map patternToExpr elems))])+-- | Serialize a type alias+typeAliasToExpr :: Syntax.TypeAlias -> Ast.Expr+typeAliasToExpr ta =++      let name = Syntax.typeAliasName ta+          generics = Syntax.typeAliasGenerics ta+          typ = Syntax.typeAliasType ta+          docC = Syntax.typeAliasDoc ta+          docPart = Optionals.cases docC [] (\d -> [+                Serialization.cst (toRustDocComment d)])+      in (Serialization.newlineSep (Lists.concat [+        docPart,+        [+          Serialization.spaceSep (Optionals.cat [+            Just (Serialization.cst "type"),+            (Just (Serialization.cst name)),+            (genericParamsToExpr generics),+            (Just (Serialization.cst "=")),+            (Just (typeToExpr typ)),+            (Just (Serialization.cst ";"))])]]))+-- | Serialize a type ascription expression+typeAscriptionExprToExpr :: Syntax.TypeAscriptionExpr -> Ast.Expr+typeAscriptionExprToExpr t =++      let expr = Syntax.typeAscriptionExprExpr t+          typ = Syntax.typeAscriptionExprType t+      in (Serialization.spaceSep [+        expressionToExpr expr,+        (Serialization.cst ":"),+        (typeToExpr typ)])+-- | Serialize a type parameter bound+typeParamBoundToExpr :: Syntax.TypeParamBound -> Ast.Expr+typeParamBoundToExpr bound =+    case bound of+      Syntax.TypeParamBoundTrait v0 -> typePathToExpr v0+      Syntax.TypeParamBoundLifetime v0 -> Serialization.cst (Strings.cat2 "'" (Syntax.lifetimeName v0))+-- | Serialize a type path+typePathToExpr :: Syntax.TypePath -> Ast.Expr+typePathToExpr tp =++      let global = Syntax.typePathGlobal tp+          segs = Syntax.typePathSegments tp+          prefix = Logic.ifElse global "::" ""+          segStrs = Lists.map (\s -> Serialization.printExpr (pathSegmentToExpr s)) segs+      in (Serialization.cst (Strings.cat2 prefix (Strings.intercalate "::" segStrs)))+-- | Serialize a Rust type+typeToExpr :: Syntax.Type -> Ast.Expr+typeToExpr typ =+    case typ of+      Syntax.TypePath_ v0 -> typePathToExpr v0+      Syntax.TypeReference v0 -> referenceTypeToExpr v0+      Syntax.TypeSlice v0 -> Serialization.bracketList Serialization.inlineStyle [+        typeToExpr v0]+      Syntax.TypeArray v0 ->+        let elem = Syntax.arrayTypeElement v0+            len = Syntax.arrayTypeLength v0+        in (Serialization.cst (Strings.cat [+          "[",+          (Serialization.printExpr (typeToExpr elem)),+          "; ",+          (Serialization.printExpr (expressionToExpr len)),+          "]"]))+      Syntax.TypeTuple v0 -> Serialization.parenListAdaptive (Lists.map typeToExpr v0)+      Syntax.TypeFnPointer v0 ->+        let params = Syntax.fnPointerTypeParams v0+            ret = Syntax.fnPointerTypeReturnType v0+        in (Serialization.spaceSep [+          Serialization.cst "fn",+          (Serialization.parenListAdaptive (Lists.map typeToExpr params)),+          (Serialization.cst "->"),+          (typeToExpr ret)])+      Syntax.TypeImplTrait v0 -> Serialization.spaceSep [+        Serialization.cst "impl",+        (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) v0)))]+      Syntax.TypeDynTrait v0 -> Serialization.spaceSep [+        Serialization.cst "dyn",+        (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) v0)))]+      Syntax.TypeInferred -> Serialization.cst "_"+      Syntax.TypeUnit -> Serialization.cst "()"+      Syntax.TypeNever -> Serialization.cst "!"+      Syntax.TypeRawPointer v0 ->+        let mut = Syntax.rawPointerTypeMutable v0+            t = Syntax.rawPointerTypeType v0+            kw = Logic.ifElse mut "*mut" "*const"+        in (Serialization.spaceSep [+          Serialization.cst kw,+          (typeToExpr t)])+      Syntax.TypeMacro v0 -> macroInvocationToExpr v0+-- | Serialize a unary expression+unaryExprToExpr :: Syntax.UnaryExpr -> Ast.Expr+unaryExprToExpr u =++      let op = Syntax.unaryExprOp u+          operand = Syntax.unaryExprOperand u+          opStr =+                  case op of+                    Syntax.UnaryOpNeg -> "-"+                    Syntax.UnaryOpNot -> "!"+      in (Serialization.cst (Strings.cat2 opStr (Serialization.printExpr (expressionToExpr operand))))+-- | Serialize a use declaration+useDeclarationToExpr :: Syntax.UseDeclaration -> Ast.Expr+useDeclarationToExpr use =++      let pub = Syntax.useDeclarationPublic use+          tree = Syntax.useDeclarationTree use+          pubKw = Logic.ifElse pub (Just (Serialization.cst "pub")) Nothing+      in (Serialization.spaceSep (Optionals.cat [+        pubKw,+        (Just (Serialization.cst "use")),+        (Just (useTreeToExpr tree)),+        (Just (Serialization.cst ";"))]))+-- | Serialize a use tree+useTreeToExpr :: Syntax.UseTree -> Ast.Expr+useTreeToExpr tree =+    case tree of+      Syntax.UseTreePath v0 -> Serialization.cst (Strings.intercalate "::" (Syntax.usePathSegments v0))+      Syntax.UseTreeRename v0 ->+        let path = Syntax.useRenamePath v0+            alias = Syntax.useRenameAlias v0+        in (Serialization.spaceSep [+          Serialization.cst (Strings.intercalate "::" path),+          (Serialization.cst "as"),+          (Serialization.cst alias)])+      Syntax.UseTreeGlob v0 -> Serialization.cst (Strings.cat2 (Strings.intercalate "::" v0) "::*")+      Syntax.UseTreeGroup v0 ->+        let prefix = Syntax.useGroupPrefix v0+            trees = Syntax.useGroupTrees v0+            prefixStr = Logic.ifElse (Lists.null prefix) "" (Strings.cat2 (Strings.intercalate "::" prefix) "::")+        in (Serialization.cst (Strings.cat [+          prefixStr,+          "{",+          (Strings.intercalate ", " (Lists.map (\t -> Serialization.printExpr (useTreeToExpr t)) trees)),+          "}"]))+-- | Serialize visibility to an optional expression+visibilityToExpr :: Syntax.Visibility -> Maybe Ast.Expr+visibilityToExpr vis =+    case vis of+      Syntax.VisibilityPublic -> Just (Serialization.cst "pub")+      Syntax.VisibilityCrate -> Just (Serialization.cst "pub(crate)")+      Syntax.VisibilityRestricted v0 -> Just (Serialization.cst (Strings.cat [+        "pub(in ",+        (Strings.intercalate "::" v0),+        ")"]))+      Syntax.VisibilityPrivate -> Nothing+-- | Serialize a where clause+whereClauseToExpr :: Syntax.WhereClause -> Ast.Expr+whereClauseToExpr wc =++      let preds = Syntax.whereClausePredicates wc+          predExprs =+                  Lists.map (\p ->+                    let typ = Syntax.wherePredicateType p+                        bounds = Syntax.wherePredicateBounds p+                    in (Serialization.spaceSep [+                      typeToExpr typ,+                      (Serialization.cst ":"),+                      (Serialization.cst (Strings.intercalate " + " (Lists.map (\b -> Serialization.printExpr (typeParamBoundToExpr b)) bounds)))])) preds+      in (Serialization.spaceSep [+        Serialization.cst "where",+        (Serialization.commaSep Serialization.inlineStyle predExprs)])+-- | Serialize a while expression+whileExprToExpr :: Syntax.WhileExpr -> Ast.Expr+whileExprToExpr w =++      let label = Syntax.whileExprLabel w+          cond = Syntax.whileExprCondition w+          body = Syntax.whileExprBody w+          labelPart = Optionals.cases label Nothing (\lbl -> Just (Serialization.cst (Strings.cat2 "'" (Strings.cat2 lbl ":"))))+          condExpr =+                  case cond of+                    Syntax.IfConditionBool v0 -> expressionToExpr v0+                    Syntax.IfConditionLet v0 ->+                      let pat = Syntax.letConditionPattern v0+                          expr = Syntax.letConditionExpr v0+                      in (Serialization.spaceSep [+                        Serialization.cst "let",+                        (patternToExpr pat),+                        (Serialization.cst "="),+                        (expressionToExpr expr)])+      in (Serialization.spaceSep (Optionals.cat [+        labelPart,+        (Just (Serialization.cst "while")),+        (Just condExpr),+        (Just (blockToExpr body))]))
+ src/main/haskell/Hydra/Rust/Syntax.hs view
@@ -0,0 +1,1569 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A Rust syntax model, based on the Rust Reference grammar (https://doc.rust-lang.org/reference/), retrieved 2025-01-29++module Hydra.Rust.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.ByteString as B+import qualified Data.Int as I+-- | A Rust crate, represented as a collection of top-level items+data Crate =+  Crate {+    -- | The top-level items in the crate+    crateItems :: [ItemWithComments]}+  deriving (Eq, Ord, Read, Show)+_Crate = Core.Name "hydra.rust.syntax.Crate"+_Crate_items = Core.Name "items"+-- | A top-level item in a Rust module or crate+data Item =+  -- | A use declaration+  ItemUse UseDeclaration |+  -- | A struct definition+  ItemStruct StructDef |+  -- | An enum definition+  ItemEnum EnumDef |+  -- | A function definition+  ItemFn FnDef |+  -- | A type alias+  ItemTypeAlias TypeAlias |+  -- | An impl block+  ItemImpl ImplBlock |+  -- | A trait definition+  ItemTrait TraitDef |+  -- | A module definition+  ItemMod ModDef |+  -- | A constant item+  ItemConst ConstDef |+  -- | A static item+  ItemStatic StaticDef |+  -- | A macro invocation as an item+  ItemMacro MacroInvocation+  deriving (Eq, Ord, Read, Show)+_Item = Core.Name "hydra.rust.syntax.Item"+_Item_use = Core.Name "use"+_Item_struct = Core.Name "struct"+_Item_enum = Core.Name "enum"+_Item_fn = Core.Name "fn"+_Item_typeAlias = Core.Name "typeAlias"+_Item_impl = Core.Name "impl"+_Item_trait = Core.Name "trait"+_Item_mod = Core.Name "mod"+_Item_const = Core.Name "const"+_Item_static = Core.Name "static"+_Item_macro = Core.Name "macro"+-- | An item together with optional doc comments and visibility+data ItemWithComments =+  ItemWithComments {+    -- | Optional documentation comment+    itemWithCommentsDoc :: (Maybe String),+    -- | The item's visibility+    itemWithCommentsVisibility :: Visibility,+    -- | The item itself+    itemWithCommentsItem :: Item}+  deriving (Eq, Ord, Read, Show)+_ItemWithComments = Core.Name "hydra.rust.syntax.ItemWithComments"+_ItemWithComments_doc = Core.Name "doc"+_ItemWithComments_visibility = Core.Name "visibility"+_ItemWithComments_item = Core.Name "item"+-- | A use declaration (e.g., use std::collections::BTreeMap;)+data UseDeclaration =+  UseDeclaration {+    -- | Whether the use is public (pub use)+    useDeclarationPublic :: Bool,+    -- | The use tree describing what is imported+    useDeclarationTree :: UseTree}+  deriving (Eq, Ord, Read, Show)+_UseDeclaration = Core.Name "hydra.rust.syntax.UseDeclaration"+_UseDeclaration_public = Core.Name "public"+_UseDeclaration_tree = Core.Name "tree"+-- | A use tree, representing the structure of a use path+data UseTree =+  -- | A simple path import+  UseTreePath UsePath |+  -- | A renamed import (e.g., BTreeMap as Map)+  UseTreeRename UseRename |+  -- | A glob import (e.g., std::collections::*)+  UseTreeGlob [String] |+  -- | A grouped import (e.g., {BTreeMap, BTreeSet})+  UseTreeGroup UseGroup+  deriving (Eq, Ord, Read, Show)+_UseTree = Core.Name "hydra.rust.syntax.UseTree"+_UseTree_path = Core.Name "path"+_UseTree_rename = Core.Name "rename"+_UseTree_glob = Core.Name "glob"+_UseTree_group = Core.Name "group"+-- | A simple path import within a use tree+data UsePath =+  UsePath {+    -- | The path segments+    usePathSegments :: [String]}+  deriving (Eq, Ord, Read, Show)+_UsePath = Core.Name "hydra.rust.syntax.UsePath"+_UsePath_segments = Core.Name "segments"+-- | A renamed import (e.g., BTreeMap as Map)+data UseRename =+  UseRename {+    -- | The original path segments+    useRenamePath :: [String],+    -- | The alias name+    useRenameAlias :: String}+  deriving (Eq, Ord, Read, Show)+_UseRename = Core.Name "hydra.rust.syntax.UseRename"+_UseRename_path = Core.Name "path"+_UseRename_alias = Core.Name "alias"+-- | A grouped import (e.g., std::collections::{BTreeMap, BTreeSet})+data UseGroup =+  UseGroup {+    -- | The common prefix path segments+    useGroupPrefix :: [String],+    -- | The individual subtrees within the group+    useGroupTrees :: [UseTree]}+  deriving (Eq, Ord, Read, Show)+_UseGroup = Core.Name "hydra.rust.syntax.UseGroup"+_UseGroup_prefix = Core.Name "prefix"+_UseGroup_trees = Core.Name "trees"+-- | A struct definition (e.g., struct Foo<T> { bar: T })+data StructDef =+  StructDef {+    -- | The struct name+    structDefName :: String,+    -- | Generic type parameters+    structDefGenerics :: [GenericParam],+    -- | Optional where clause+    structDefWhereClause :: (Maybe WhereClause),+    -- | The struct body (named fields, tuple fields, or unit)+    structDefBody :: StructBody,+    -- | Derive macros to apply+    structDefDerives :: [String],+    -- | Whether the struct is public+    structDefPublic :: Bool,+    -- | Optional doc comment+    structDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_StructDef = Core.Name "hydra.rust.syntax.StructDef"+_StructDef_name = Core.Name "name"+_StructDef_generics = Core.Name "generics"+_StructDef_whereClause = Core.Name "whereClause"+_StructDef_body = Core.Name "body"+_StructDef_derives = Core.Name "derives"+_StructDef_public = Core.Name "public"+_StructDef_doc = Core.Name "doc"+-- | The body of a struct definition+data StructBody =+  -- | A struct with named fields+  StructBodyNamed [StructField] |+  -- | A tuple struct+  StructBodyTuple [TupleField] |+  -- | A unit struct+  StructBodyUnit+  deriving (Eq, Ord, Read, Show)+_StructBody = Core.Name "hydra.rust.syntax.StructBody"+_StructBody_named = Core.Name "named"+_StructBody_tuple = Core.Name "tuple"+_StructBody_unit = Core.Name "unit"+-- | A named field within a struct definition+data StructField =+  StructField {+    -- | The field name+    structFieldName :: String,+    -- | The field type+    structFieldType :: Type,+    -- | Whether the field is public+    structFieldPublic :: Bool,+    -- | Optional doc comment for the field+    structFieldDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_StructField = Core.Name "hydra.rust.syntax.StructField"+_StructField_name = Core.Name "name"+_StructField_type = Core.Name "type"+_StructField_public = Core.Name "public"+_StructField_doc = Core.Name "doc"+-- | A positional field within a tuple struct+data TupleField =+  TupleField {+    -- | The field type+    tupleFieldType :: Type,+    -- | Whether the field is public+    tupleFieldPublic :: Bool}+  deriving (Eq, Ord, Read, Show)+_TupleField = Core.Name "hydra.rust.syntax.TupleField"+_TupleField_type = Core.Name "type"+_TupleField_public = Core.Name "public"+-- | An enum definition (e.g., enum Foo<T> { Bar(T), Baz { x: i32 } })+data EnumDef =+  EnumDef {+    -- | The enum name+    enumDefName :: String,+    -- | Generic type parameters+    enumDefGenerics :: [GenericParam],+    -- | Optional where clause+    enumDefWhereClause :: (Maybe WhereClause),+    -- | The enum variants+    enumDefVariants :: [EnumVariant],+    -- | Derive macros to apply+    enumDefDerives :: [String],+    -- | Whether the enum is public+    enumDefPublic :: Bool,+    -- | Optional doc comment+    enumDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_EnumDef = Core.Name "hydra.rust.syntax.EnumDef"+_EnumDef_name = Core.Name "name"+_EnumDef_generics = Core.Name "generics"+_EnumDef_whereClause = Core.Name "whereClause"+_EnumDef_variants = Core.Name "variants"+_EnumDef_derives = Core.Name "derives"+_EnumDef_public = Core.Name "public"+_EnumDef_doc = Core.Name "doc"+-- | A variant of an enum definition+data EnumVariant =+  EnumVariant {+    -- | The variant name+    enumVariantName :: String,+    -- | The variant body+    enumVariantBody :: EnumVariantBody,+    -- | Optional doc comment for the variant+    enumVariantDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_EnumVariant = Core.Name "hydra.rust.syntax.EnumVariant"+_EnumVariant_name = Core.Name "name"+_EnumVariant_body = Core.Name "body"+_EnumVariant_doc = Core.Name "doc"+-- | The body of an enum variant+data EnumVariantBody =+  -- | A unit variant (e.g., Foo)+  EnumVariantBodyUnit |+  -- | A tuple variant (e.g., Foo(i32, String))+  EnumVariantBodyTuple [Type] |+  -- | A struct variant (e.g., Foo { x: i32 })+  EnumVariantBodyStruct [StructField]+  deriving (Eq, Ord, Read, Show)+_EnumVariantBody = Core.Name "hydra.rust.syntax.EnumVariantBody"+_EnumVariantBody_unit = Core.Name "unit"+_EnumVariantBody_tuple = Core.Name "tuple"+_EnumVariantBody_struct = Core.Name "struct"+-- | A function definition (e.g., fn foo<T>(x: T) -> String { ... })+data FnDef =+  FnDef {+    -- | The function name+    fnDefName :: String,+    -- | Generic type parameters+    fnDefGenerics :: [GenericParam],+    -- | Optional where clause+    fnDefWhereClause :: (Maybe WhereClause),+    -- | The function parameters+    fnDefParams :: [FnParam],+    -- | The return type (None means ())+    fnDefReturnType :: (Maybe Type),+    -- | The function body+    fnDefBody :: Block,+    -- | Whether the function is public+    fnDefPublic :: Bool,+    -- | Whether the function is async+    fnDefAsync :: Bool,+    -- | Whether the function is const+    fnDefConst :: Bool,+    -- | Whether the function is unsafe+    fnDefUnsafe :: Bool,+    -- | Optional doc comment+    fnDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_FnDef = Core.Name "hydra.rust.syntax.FnDef"+_FnDef_name = Core.Name "name"+_FnDef_generics = Core.Name "generics"+_FnDef_whereClause = Core.Name "whereClause"+_FnDef_params = Core.Name "params"+_FnDef_returnType = Core.Name "returnType"+_FnDef_body = Core.Name "body"+_FnDef_public = Core.Name "public"+_FnDef_async = Core.Name "async"+_FnDef_const = Core.Name "const"+_FnDef_unsafe = Core.Name "unsafe"+_FnDef_doc = Core.Name "doc"+-- | A function parameter+data FnParam =+  FnParam {+    -- | The parameter pattern+    fnParamPattern :: Pattern,+    -- | The parameter type+    fnParamType :: Type}+  deriving (Eq, Ord, Read, Show)+_FnParam = Core.Name "hydra.rust.syntax.FnParam"+_FnParam_pattern = Core.Name "pattern"+_FnParam_type = Core.Name "type"+-- | A self parameter in a method+data SelfParam =+  SelfParamOwned |+  SelfParamRef |+  SelfParamRefMut+  deriving (Eq, Ord, Read, Show)+_SelfParam = Core.Name "hydra.rust.syntax.SelfParam"+_SelfParam_owned = Core.Name "owned"+_SelfParam_ref = Core.Name "ref"+_SelfParam_refMut = Core.Name "refMut"+-- | A method parameter, which may be self or a regular parameter+data MethodParam =+  -- | A self parameter+  MethodParamSelf SelfParam |+  -- | A regular function parameter+  MethodParamRegular FnParam+  deriving (Eq, Ord, Read, Show)+_MethodParam = Core.Name "hydra.rust.syntax.MethodParam"+_MethodParam_self = Core.Name "self"+_MethodParam_regular = Core.Name "regular"+-- | A type alias definition (e.g., type Foo<T> = Bar<T>;)+data TypeAlias =+  TypeAlias {+    -- | The alias name+    typeAliasName :: String,+    -- | Generic type parameters+    typeAliasGenerics :: [GenericParam],+    -- | The aliased type+    typeAliasType :: Type,+    -- | Whether the alias is public+    typeAliasPublic :: Bool,+    -- | Optional doc comment+    typeAliasDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_TypeAlias = Core.Name "hydra.rust.syntax.TypeAlias"+_TypeAlias_name = Core.Name "name"+_TypeAlias_generics = Core.Name "generics"+_TypeAlias_type = Core.Name "type"+_TypeAlias_public = Core.Name "public"+_TypeAlias_doc = Core.Name "doc"+-- | A constant item (e.g., const FOO: u32 = 42;)+data ConstDef =+  ConstDef {+    -- | The constant name+    constDefName :: String,+    -- | The constant type+    constDefType :: Type,+    -- | The constant value expression+    constDefValue :: Expression,+    -- | Whether the constant is public+    constDefPublic :: Bool,+    -- | Optional doc comment+    constDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_ConstDef = Core.Name "hydra.rust.syntax.ConstDef"+_ConstDef_name = Core.Name "name"+_ConstDef_type = Core.Name "type"+_ConstDef_value = Core.Name "value"+_ConstDef_public = Core.Name "public"+_ConstDef_doc = Core.Name "doc"+-- | A static item (e.g., static FOO: u32 = 42;)+data StaticDef =+  StaticDef {+    -- | The static name+    staticDefName :: String,+    -- | The static type+    staticDefType :: Type,+    -- | The static value expression+    staticDefValue :: Expression,+    -- | Whether the static is mutable+    staticDefMutable :: Bool,+    -- | Whether the static is public+    staticDefPublic :: Bool,+    -- | Optional doc comment+    staticDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_StaticDef = Core.Name "hydra.rust.syntax.StaticDef"+_StaticDef_name = Core.Name "name"+_StaticDef_type = Core.Name "type"+_StaticDef_value = Core.Name "value"+_StaticDef_mutable = Core.Name "mutable"+_StaticDef_public = Core.Name "public"+_StaticDef_doc = Core.Name "doc"+-- | A module definition (either inline or external)+data ModDef =+  ModDef {+    -- | The module name+    modDefName :: String,+    -- | The module body (None for external file)+    modDefBody :: (Maybe [Item]),+    -- | Whether the module is public+    modDefPublic :: Bool,+    -- | Optional doc comment+    modDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_ModDef = Core.Name "hydra.rust.syntax.ModDef"+_ModDef_name = Core.Name "name"+_ModDef_body = Core.Name "body"+_ModDef_public = Core.Name "public"+_ModDef_doc = Core.Name "doc"+-- | An impl block (e.g., impl<T> Trait for Foo<T> { ... })+data ImplBlock =+  ImplBlock {+    -- | Generic type parameters+    implBlockGenerics :: [GenericParam],+    -- | Optional where clause+    implBlockWhereClause :: (Maybe WhereClause),+    -- | The trait being implemented, if any+    implBlockTrait :: (Maybe TypePath),+    -- | Whether this is a negative impl+    implBlockNegative :: Bool,+    -- | The type being implemented for+    implBlockSelfType :: Type,+    -- | The items within the impl block+    implBlockItems :: [ImplItem]}+  deriving (Eq, Ord, Read, Show)+_ImplBlock = Core.Name "hydra.rust.syntax.ImplBlock"+_ImplBlock_generics = Core.Name "generics"+_ImplBlock_whereClause = Core.Name "whereClause"+_ImplBlock_trait = Core.Name "trait"+_ImplBlock_negative = Core.Name "negative"+_ImplBlock_selfType = Core.Name "selfType"+_ImplBlock_items = Core.Name "items"+-- | An item within an impl block+data ImplItem =+  -- | A method definition+  ImplItemMethod ImplMethod |+  -- | An associated type definition+  ImplItemType TypeAlias |+  -- | An associated constant+  ImplItemConst ConstDef+  deriving (Eq, Ord, Read, Show)+_ImplItem = Core.Name "hydra.rust.syntax.ImplItem"+_ImplItem_method = Core.Name "method"+_ImplItem_type = Core.Name "type"+_ImplItem_const = Core.Name "const"+-- | A method within an impl block+data ImplMethod =+  ImplMethod {+    -- | The method name+    implMethodName :: String,+    -- | Generic type parameters+    implMethodGenerics :: [GenericParam],+    -- | Optional where clause+    implMethodWhereClause :: (Maybe WhereClause),+    -- | The method parameters (including self)+    implMethodParams :: [MethodParam],+    -- | The return type (None means ())+    implMethodReturnType :: (Maybe Type),+    -- | The method body+    implMethodBody :: Block,+    -- | Whether the method is public+    implMethodPublic :: Bool,+    -- | Whether the method has a default implementation+    implMethodDefault :: Bool,+    -- | Optional doc comment+    implMethodDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_ImplMethod = Core.Name "hydra.rust.syntax.ImplMethod"+_ImplMethod_name = Core.Name "name"+_ImplMethod_generics = Core.Name "generics"+_ImplMethod_whereClause = Core.Name "whereClause"+_ImplMethod_params = Core.Name "params"+_ImplMethod_returnType = Core.Name "returnType"+_ImplMethod_body = Core.Name "body"+_ImplMethod_public = Core.Name "public"+_ImplMethod_default = Core.Name "default"+_ImplMethod_doc = Core.Name "doc"+-- | A trait definition (e.g., trait Foo<T>: Bar + Baz { ... })+data TraitDef =+  TraitDef {+    -- | The trait name+    traitDefName :: String,+    -- | Generic type parameters+    traitDefGenerics :: [GenericParam],+    -- | Optional where clause+    traitDefWhereClause :: (Maybe WhereClause),+    -- | Supertraits+    traitDefSuperTraits :: [TypeParamBound],+    -- | The items within the trait+    traitDefItems :: [TraitItem],+    -- | Whether the trait is public+    traitDefPublic :: Bool,+    -- | Whether the trait is unsafe+    traitDefUnsafe :: Bool,+    -- | Optional doc comment+    traitDefDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_TraitDef = Core.Name "hydra.rust.syntax.TraitDef"+_TraitDef_name = Core.Name "name"+_TraitDef_generics = Core.Name "generics"+_TraitDef_whereClause = Core.Name "whereClause"+_TraitDef_superTraits = Core.Name "superTraits"+_TraitDef_items = Core.Name "items"+_TraitDef_public = Core.Name "public"+_TraitDef_unsafe = Core.Name "unsafe"+_TraitDef_doc = Core.Name "doc"+-- | An item within a trait definition+data TraitItem =+  -- | A method signature or default method+  TraitItemMethod TraitMethod |+  -- | An associated type+  TraitItemType TraitType |+  -- | An associated constant+  TraitItemConst TraitConst+  deriving (Eq, Ord, Read, Show)+_TraitItem = Core.Name "hydra.rust.syntax.TraitItem"+_TraitItem_method = Core.Name "method"+_TraitItem_type = Core.Name "type"+_TraitItem_const = Core.Name "const"+-- | A method signature or default method within a trait+data TraitMethod =+  TraitMethod {+    -- | The method name+    traitMethodName :: String,+    -- | Generic type parameters+    traitMethodGenerics :: [GenericParam],+    -- | Optional where clause+    traitMethodWhereClause :: (Maybe WhereClause),+    -- | The method parameters (including self)+    traitMethodParams :: [MethodParam],+    -- | The return type+    traitMethodReturnType :: (Maybe Type),+    -- | Optional default body+    traitMethodDefaultBody :: (Maybe Block),+    -- | Optional doc comment+    traitMethodDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_TraitMethod = Core.Name "hydra.rust.syntax.TraitMethod"+_TraitMethod_name = Core.Name "name"+_TraitMethod_generics = Core.Name "generics"+_TraitMethod_whereClause = Core.Name "whereClause"+_TraitMethod_params = Core.Name "params"+_TraitMethod_returnType = Core.Name "returnType"+_TraitMethod_defaultBody = Core.Name "defaultBody"+_TraitMethod_doc = Core.Name "doc"+-- | An associated type within a trait+data TraitType =+  TraitType {+    -- | The associated type name+    traitTypeName :: String,+    -- | Type parameter bounds+    traitTypeBounds :: [TypeParamBound],+    -- | Optional default type+    traitTypeDefault :: (Maybe Type),+    -- | Optional doc comment+    traitTypeDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_TraitType = Core.Name "hydra.rust.syntax.TraitType"+_TraitType_name = Core.Name "name"+_TraitType_bounds = Core.Name "bounds"+_TraitType_default = Core.Name "default"+_TraitType_doc = Core.Name "doc"+-- | An associated constant within a trait+data TraitConst =+  TraitConst {+    -- | The constant name+    traitConstName :: String,+    -- | The constant type+    traitConstType :: Type,+    -- | Optional default value+    traitConstDefault :: (Maybe Expression),+    -- | Optional doc comment+    traitConstDoc :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_TraitConst = Core.Name "hydra.rust.syntax.TraitConst"+_TraitConst_name = Core.Name "name"+_TraitConst_type = Core.Name "type"+_TraitConst_default = Core.Name "default"+_TraitConst_doc = Core.Name "doc"+-- | A generic type parameter (e.g., T: Clone + Debug)+data GenericParam =+  GenericParam {+    -- | The parameter name+    genericParamName :: String,+    -- | Trait bounds on the parameter+    genericParamBounds :: [TypeParamBound]}+  deriving (Eq, Ord, Read, Show)+_GenericParam = Core.Name "hydra.rust.syntax.GenericParam"+_GenericParam_name = Core.Name "name"+_GenericParam_bounds = Core.Name "bounds"+-- | A bound on a type parameter+data TypeParamBound =+  -- | A trait bound+  TypeParamBoundTrait TypePath |+  -- | A lifetime bound+  TypeParamBoundLifetime Lifetime+  deriving (Eq, Ord, Read, Show)+_TypeParamBound = Core.Name "hydra.rust.syntax.TypeParamBound"+_TypeParamBound_trait = Core.Name "trait"+_TypeParamBound_lifetime = Core.Name "lifetime"+-- | A lifetime (e.g., 'a, 'static)+data Lifetime =+  Lifetime {+    -- | The lifetime name (without the leading quote)+    lifetimeName :: String}+  deriving (Eq, Ord, Read, Show)+_Lifetime = Core.Name "hydra.rust.syntax.Lifetime"+_Lifetime_name = Core.Name "name"+-- | A where clause (e.g., where T: Clone, U: Debug)+data WhereClause =+  WhereClause {+    -- | The predicates in the where clause+    whereClausePredicates :: [WherePredicate]}+  deriving (Eq, Ord, Read, Show)+_WhereClause = Core.Name "hydra.rust.syntax.WhereClause"+_WhereClause_predicates = Core.Name "predicates"+-- | A single predicate in a where clause+data WherePredicate =+  WherePredicate {+    -- | The type being constrained+    wherePredicateType :: Type,+    -- | The bounds on the type+    wherePredicateBounds :: [TypeParamBound]}+  deriving (Eq, Ord, Read, Show)+_WherePredicate = Core.Name "hydra.rust.syntax.WherePredicate"+_WherePredicate_type = Core.Name "type"+_WherePredicate_bounds = Core.Name "bounds"+-- | A Rust type expression+data Type =+  -- | A path type, possibly with generic arguments+  TypePath_ TypePath |+  -- | A reference type+  TypeReference ReferenceType |+  -- | A slice type+  TypeSlice Type |+  -- | An array type with a fixed size+  TypeArray ArrayType |+  -- | A tuple type+  TypeTuple [Type] |+  -- | A function pointer type+  TypeFnPointer FnPointerType |+  -- | An impl Trait type+  TypeImplTrait [TypeParamBound] |+  -- | A dyn Trait type+  TypeDynTrait [TypeParamBound] |+  -- | The inferred type placeholder (_)+  TypeInferred |+  -- | The unit type (())+  TypeUnit |+  -- | The never type (!)+  TypeNever |+  -- | A raw pointer type+  TypeRawPointer RawPointerType |+  -- | A macro invocation in type position+  TypeMacro MacroInvocation+  deriving (Eq, Ord, Read, Show)+_Type = Core.Name "hydra.rust.syntax.Type"+_Type_path = Core.Name "path"+_Type_reference = Core.Name "reference"+_Type_slice = Core.Name "slice"+_Type_array = Core.Name "array"+_Type_tuple = Core.Name "tuple"+_Type_fnPointer = Core.Name "fnPointer"+_Type_implTrait = Core.Name "implTrait"+_Type_dynTrait = Core.Name "dynTrait"+_Type_inferred = Core.Name "inferred"+_Type_unit = Core.Name "unit"+_Type_never = Core.Name "never"+_Type_rawPointer = Core.Name "rawPointer"+_Type_macro = Core.Name "macro"+-- | A path-based type, possibly with generic arguments+data TypePath =+  TypePath {+    -- | Whether the path is absolute (starts with ::)+    typePathGlobal :: Bool,+    -- | The segments of the path+    typePathSegments :: [PathSegment]}+  deriving (Eq, Ord, Read, Show)+_TypePath = Core.Name "hydra.rust.syntax.TypePath"+_TypePath_global = Core.Name "global"+_TypePath_segments = Core.Name "segments"+-- | A segment within a type path+data PathSegment =+  PathSegment {+    -- | The segment name+    pathSegmentName :: String,+    -- | Generic arguments, if any+    pathSegmentArguments :: GenericArguments}+  deriving (Eq, Ord, Read, Show)+_PathSegment = Core.Name "hydra.rust.syntax.PathSegment"+_PathSegment_name = Core.Name "name"+_PathSegment_arguments = Core.Name "arguments"+-- | Generic arguments to a path segment+data GenericArguments =+  -- | No generic arguments+  GenericArgumentsNone |+  -- | Angle-bracketed arguments+  GenericArgumentsAngleBracketed AngleBracketedArgs |+  -- | Parenthesized arguments for Fn traits+  GenericArgumentsParenthesized ParenthesizedArgs+  deriving (Eq, Ord, Read, Show)+_GenericArguments = Core.Name "hydra.rust.syntax.GenericArguments"+_GenericArguments_none = Core.Name "none"+_GenericArguments_angleBracketed = Core.Name "angleBracketed"+_GenericArguments_parenthesized = Core.Name "parenthesized"+-- | Angle-bracketed generic arguments+data AngleBracketedArgs =+  AngleBracketedArgs {+    -- | The generic arguments+    angleBracketedArgsArgs :: [GenericArg]}+  deriving (Eq, Ord, Read, Show)+_AngleBracketedArgs = Core.Name "hydra.rust.syntax.AngleBracketedArgs"+_AngleBracketedArgs_args = Core.Name "args"+-- | A single generic argument+data GenericArg =+  -- | A type argument+  GenericArgType Type |+  -- | A lifetime argument+  GenericArgLifetime Lifetime |+  -- | A const expression argument+  GenericArgConst Expression |+  -- | An associated type binding+  GenericArgBinding TypeBinding+  deriving (Eq, Ord, Read, Show)+_GenericArg = Core.Name "hydra.rust.syntax.GenericArg"+_GenericArg_type = Core.Name "type"+_GenericArg_lifetime = Core.Name "lifetime"+_GenericArg_const = Core.Name "const"+_GenericArg_binding = Core.Name "binding"+-- | An associated type binding within generic arguments+data TypeBinding =+  TypeBinding {+    -- | The associated type name+    typeBindingName :: String,+    -- | The bound type+    typeBindingType :: Type}+  deriving (Eq, Ord, Read, Show)+_TypeBinding = Core.Name "hydra.rust.syntax.TypeBinding"+_TypeBinding_name = Core.Name "name"+_TypeBinding_type = Core.Name "type"+-- | Parenthesized generic arguments for Fn traits+data ParenthesizedArgs =+  ParenthesizedArgs {+    -- | The input types+    parenthesizedArgsInputs :: [Type],+    -- | The output type+    parenthesizedArgsOutput :: (Maybe Type)}+  deriving (Eq, Ord, Read, Show)+_ParenthesizedArgs = Core.Name "hydra.rust.syntax.ParenthesizedArgs"+_ParenthesizedArgs_inputs = Core.Name "inputs"+_ParenthesizedArgs_output = Core.Name "output"+-- | A reference type (e.g., &T, &mut T, &'a T)+data ReferenceType =+  ReferenceType {+    -- | Optional lifetime annotation+    referenceTypeLifetime :: (Maybe Lifetime),+    -- | Whether the reference is mutable+    referenceTypeMutable :: Bool,+    -- | The referenced type+    referenceTypeType :: Type}+  deriving (Eq, Ord, Read, Show)+_ReferenceType = Core.Name "hydra.rust.syntax.ReferenceType"+_ReferenceType_lifetime = Core.Name "lifetime"+_ReferenceType_mutable = Core.Name "mutable"+_ReferenceType_type = Core.Name "type"+-- | An array type with a fixed size (e.g., [T; 3])+data ArrayType =+  ArrayType {+    -- | The element type+    arrayTypeElement :: Type,+    -- | The array length (as a constant expression)+    arrayTypeLength :: Expression}+  deriving (Eq, Ord, Read, Show)+_ArrayType = Core.Name "hydra.rust.syntax.ArrayType"+_ArrayType_element = Core.Name "element"+_ArrayType_length = Core.Name "length"+-- | A function pointer type (e.g., fn(i32, i32) -> i32)+data FnPointerType =+  FnPointerType {+    -- | The parameter types+    fnPointerTypeParams :: [Type],+    -- | The return type+    fnPointerTypeReturnType :: Type}+  deriving (Eq, Ord, Read, Show)+_FnPointerType = Core.Name "hydra.rust.syntax.FnPointerType"+_FnPointerType_params = Core.Name "params"+_FnPointerType_returnType = Core.Name "returnType"+-- | A raw pointer type (e.g., *const T, *mut T)+data RawPointerType =+  RawPointerType {+    -- | Whether the pointer is mutable (*mut vs *const)+    rawPointerTypeMutable :: Bool,+    -- | The pointed-to type+    rawPointerTypeType :: Type}+  deriving (Eq, Ord, Read, Show)+_RawPointerType = Core.Name "hydra.rust.syntax.RawPointerType"+_RawPointerType_mutable = Core.Name "mutable"+_RawPointerType_type = Core.Name "type"+-- | A Rust expression+data Expression =+  -- | A literal value+  ExpressionLiteral Literal |+  -- | A path expression+  ExpressionPath ExprPath |+  -- | A block expression+  ExpressionBlock Block |+  -- | A function call expression+  ExpressionCall CallExpr |+  -- | A method call expression+  ExpressionMethodCall MethodCallExpr |+  -- | A field access expression+  ExpressionFieldAccess FieldAccessExpr |+  -- | A tuple index expression+  ExpressionTupleIndex TupleIndexExpr |+  -- | A closure expression+  ExpressionClosure ClosureExpr |+  -- | An if expression, including if let+  ExpressionIf IfExpr |+  -- | A match expression+  ExpressionMatch MatchExpr |+  -- | A loop expression+  ExpressionLoop LoopExpr |+  -- | A while expression, including while let+  ExpressionWhile WhileExpr |+  -- | A for expression+  ExpressionFor ForExpr |+  -- | A binary operation+  ExpressionBinary BinaryExpr |+  -- | A unary operation+  ExpressionUnary UnaryExpr |+  -- | A reference expression+  ExpressionReference RefExpr |+  -- | A dereference expression+  ExpressionDereference Expression |+  -- | A struct literal expression+  ExpressionStruct StructExpr |+  -- | A tuple expression+  ExpressionTuple [Expression] |+  -- | An array expression+  ExpressionArray ArrayExpr |+  -- | An index expression+  ExpressionIndex IndexExpr |+  -- | A range expression+  ExpressionRange RangeExpr |+  -- | A return expression+  ExpressionReturn (Maybe Expression) |+  -- | A break expression+  ExpressionBreak (Maybe Expression) |+  -- | A continue expression+  ExpressionContinue |+  -- | A try expression (expr?)+  ExpressionTry Expression |+  -- | A type cast expression+  ExpressionCast CastExpr |+  -- | A type ascription expression+  ExpressionTypeAscription TypeAscriptionExpr |+  -- | An await expression+  ExpressionAwait Expression |+  -- | An assignment expression+  ExpressionAssign AssignExpr |+  -- | A compound assignment expression+  ExpressionCompoundAssign CompoundAssignExpr |+  -- | A macro invocation expression+  ExpressionMacro MacroInvocation |+  -- | A parenthesized expression+  ExpressionParen Expression+  deriving (Eq, Ord, Read, Show)+_Expression = Core.Name "hydra.rust.syntax.Expression"+_Expression_literal = Core.Name "literal"+_Expression_path = Core.Name "path"+_Expression_block = Core.Name "block"+_Expression_call = Core.Name "call"+_Expression_methodCall = Core.Name "methodCall"+_Expression_fieldAccess = Core.Name "fieldAccess"+_Expression_tupleIndex = Core.Name "tupleIndex"+_Expression_closure = Core.Name "closure"+_Expression_if = Core.Name "if"+_Expression_match = Core.Name "match"+_Expression_loop = Core.Name "loop"+_Expression_while = Core.Name "while"+_Expression_for = Core.Name "for"+_Expression_binary = Core.Name "binary"+_Expression_unary = Core.Name "unary"+_Expression_reference = Core.Name "reference"+_Expression_dereference = Core.Name "dereference"+_Expression_struct = Core.Name "struct"+_Expression_tuple = Core.Name "tuple"+_Expression_array = Core.Name "array"+_Expression_index = Core.Name "index"+_Expression_range = Core.Name "range"+_Expression_return = Core.Name "return"+_Expression_break = Core.Name "break"+_Expression_continue = Core.Name "continue"+_Expression_try = Core.Name "try"+_Expression_cast = Core.Name "cast"+_Expression_typeAscription = Core.Name "typeAscription"+_Expression_await = Core.Name "await"+_Expression_assign = Core.Name "assign"+_Expression_compoundAssign = Core.Name "compoundAssign"+_Expression_macro = Core.Name "macro"+_Expression_paren = Core.Name "paren"+-- | A path used as an expression+data ExprPath =+  ExprPath {+    -- | Whether the path is global+    exprPathGlobal :: Bool,+    -- | The path segments+    exprPathSegments :: [PathSegment]}+  deriving (Eq, Ord, Read, Show)+_ExprPath = Core.Name "hydra.rust.syntax.ExprPath"+_ExprPath_global = Core.Name "global"+_ExprPath_segments = Core.Name "segments"+-- | A function call expression+data CallExpr =+  CallExpr {+    -- | The function being called+    callExprFunction :: Expression,+    -- | The arguments+    callExprArgs :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_CallExpr = Core.Name "hydra.rust.syntax.CallExpr"+_CallExpr_function = Core.Name "function"+_CallExpr_args = Core.Name "args"+-- | A method call expression+data MethodCallExpr =+  MethodCallExpr {+    -- | The receiver expression+    methodCallExprReceiver :: Expression,+    -- | The method name+    methodCallExprMethod :: String,+    -- | Optional turbofish generic arguments+    methodCallExprTurbofish :: [Type],+    -- | The arguments (excluding the receiver)+    methodCallExprArgs :: [Expression]}+  deriving (Eq, Ord, Read, Show)+_MethodCallExpr = Core.Name "hydra.rust.syntax.MethodCallExpr"+_MethodCallExpr_receiver = Core.Name "receiver"+_MethodCallExpr_method = Core.Name "method"+_MethodCallExpr_turbofish = Core.Name "turbofish"+_MethodCallExpr_args = Core.Name "args"+-- | A field access expression+data FieldAccessExpr =+  FieldAccessExpr {+    -- | The expression being accessed+    fieldAccessExprObject :: Expression,+    -- | The field name+    fieldAccessExprField :: String}+  deriving (Eq, Ord, Read, Show)+_FieldAccessExpr = Core.Name "hydra.rust.syntax.FieldAccessExpr"+_FieldAccessExpr_object = Core.Name "object"+_FieldAccessExpr_field = Core.Name "field"+-- | A tuple index expression+data TupleIndexExpr =+  TupleIndexExpr {+    -- | The tuple expression+    tupleIndexExprTuple :: Expression,+    -- | The index (0-based)+    tupleIndexExprIndex :: Int}+  deriving (Eq, Ord, Read, Show)+_TupleIndexExpr = Core.Name "hydra.rust.syntax.TupleIndexExpr"+_TupleIndexExpr_tuple = Core.Name "tuple"+_TupleIndexExpr_index = Core.Name "index"+-- | A closure expression+data ClosureExpr =+  ClosureExpr {+    -- | Whether the closure captures by move+    closureExprMove :: Bool,+    -- | The closure parameters+    closureExprParams :: [ClosureParam],+    -- | Optional return type annotation+    closureExprReturnType :: (Maybe Type),+    -- | The closure body+    closureExprBody :: Expression}+  deriving (Eq, Ord, Read, Show)+_ClosureExpr = Core.Name "hydra.rust.syntax.ClosureExpr"+_ClosureExpr_move = Core.Name "move"+_ClosureExpr_params = Core.Name "params"+_ClosureExpr_returnType = Core.Name "returnType"+_ClosureExpr_body = Core.Name "body"+-- | A closure parameter+data ClosureParam =+  ClosureParam {+    -- | The parameter pattern+    closureParamPattern :: Pattern,+    -- | Optional type annotation+    closureParamType :: (Maybe Type)}+  deriving (Eq, Ord, Read, Show)+_ClosureParam = Core.Name "hydra.rust.syntax.ClosureParam"+_ClosureParam_pattern = Core.Name "pattern"+_ClosureParam_type = Core.Name "type"+-- | An if expression, optionally with if let+data IfExpr =+  IfExpr {+    -- | The condition+    ifExprCondition :: IfCondition,+    -- | The then block+    ifExprThenBlock :: Block,+    -- | An optional else branch+    ifExprElseBranch :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_IfExpr = Core.Name "hydra.rust.syntax.IfExpr"+_IfExpr_condition = Core.Name "condition"+_IfExpr_thenBlock = Core.Name "thenBlock"+_IfExpr_elseBranch = Core.Name "elseBranch"+-- | The condition of an if expression+data IfCondition =+  -- | A boolean condition+  IfConditionBool Expression |+  -- | A let condition+  IfConditionLet LetCondition+  deriving (Eq, Ord, Read, Show)+_IfCondition = Core.Name "hydra.rust.syntax.IfCondition"+_IfCondition_bool = Core.Name "bool"+_IfCondition_let = Core.Name "let"+-- | A match expression+data MatchExpr =+  MatchExpr {+    -- | The expression being matched+    matchExprScrutinee :: Expression,+    -- | The match arms+    matchExprArms :: [MatchArm]}+  deriving (Eq, Ord, Read, Show)+_MatchExpr = Core.Name "hydra.rust.syntax.MatchExpr"+_MatchExpr_scrutinee = Core.Name "scrutinee"+_MatchExpr_arms = Core.Name "arms"+-- | A single arm in a match expression+data MatchArm =+  MatchArm {+    -- | The pattern to match+    matchArmPattern :: Pattern,+    -- | Optional guard expression+    matchArmGuard :: (Maybe Expression),+    -- | The body expression+    matchArmBody :: Expression}+  deriving (Eq, Ord, Read, Show)+_MatchArm = Core.Name "hydra.rust.syntax.MatchArm"+_MatchArm_pattern = Core.Name "pattern"+_MatchArm_guard = Core.Name "guard"+_MatchArm_body = Core.Name "body"+-- | A loop expression+data LoopExpr =+  LoopExpr {+    -- | Optional loop label+    loopExprLabel :: (Maybe String),+    -- | The loop body+    loopExprBody :: Block}+  deriving (Eq, Ord, Read, Show)+_LoopExpr = Core.Name "hydra.rust.syntax.LoopExpr"+_LoopExpr_label = Core.Name "label"+_LoopExpr_body = Core.Name "body"+-- | A while expression, optionally with while let+data WhileExpr =+  WhileExpr {+    -- | Optional loop label+    whileExprLabel :: (Maybe String),+    -- | The condition+    whileExprCondition :: IfCondition,+    -- | The loop body+    whileExprBody :: Block}+  deriving (Eq, Ord, Read, Show)+_WhileExpr = Core.Name "hydra.rust.syntax.WhileExpr"+_WhileExpr_label = Core.Name "label"+_WhileExpr_condition = Core.Name "condition"+_WhileExpr_body = Core.Name "body"+-- | A for expression+data ForExpr =+  ForExpr {+    -- | Optional loop label+    forExprLabel :: (Maybe String),+    -- | The loop variable pattern+    forExprPattern :: Pattern,+    -- | The iterator expression+    forExprIter :: Expression,+    -- | The loop body+    forExprBody :: Block}+  deriving (Eq, Ord, Read, Show)+_ForExpr = Core.Name "hydra.rust.syntax.ForExpr"+_ForExpr_label = Core.Name "label"+_ForExpr_pattern = Core.Name "pattern"+_ForExpr_iter = Core.Name "iter"+_ForExpr_body = Core.Name "body"+-- | A binary operation+data BinaryExpr =+  BinaryExpr {+    -- | The left-hand operand+    binaryExprLeft :: Expression,+    -- | The binary operator+    binaryExprOp :: BinaryOp,+    -- | The right-hand operand+    binaryExprRight :: Expression}+  deriving (Eq, Ord, Read, Show)+_BinaryExpr = Core.Name "hydra.rust.syntax.BinaryExpr"+_BinaryExpr_left = Core.Name "left"+_BinaryExpr_op = Core.Name "op"+_BinaryExpr_right = Core.Name "right"+-- | A binary operator+data BinaryOp =+  BinaryOpAdd |+  BinaryOpSub |+  BinaryOpMul |+  BinaryOpDiv |+  BinaryOpRem |+  BinaryOpAnd |+  BinaryOpOr |+  BinaryOpBitAnd |+  BinaryOpBitOr |+  BinaryOpBitXor |+  BinaryOpShl |+  BinaryOpShr |+  BinaryOpEq |+  BinaryOpNe |+  BinaryOpLt |+  BinaryOpLe |+  BinaryOpGt |+  BinaryOpGe+  deriving (Eq, Ord, Read, Show)+_BinaryOp = Core.Name "hydra.rust.syntax.BinaryOp"+_BinaryOp_add = Core.Name "add"+_BinaryOp_sub = Core.Name "sub"+_BinaryOp_mul = Core.Name "mul"+_BinaryOp_div = Core.Name "div"+_BinaryOp_rem = Core.Name "rem"+_BinaryOp_and = Core.Name "and"+_BinaryOp_or = Core.Name "or"+_BinaryOp_bitAnd = Core.Name "bitAnd"+_BinaryOp_bitOr = Core.Name "bitOr"+_BinaryOp_bitXor = Core.Name "bitXor"+_BinaryOp_shl = Core.Name "shl"+_BinaryOp_shr = Core.Name "shr"+_BinaryOp_eq = Core.Name "eq"+_BinaryOp_ne = Core.Name "ne"+_BinaryOp_lt = Core.Name "lt"+_BinaryOp_le = Core.Name "le"+_BinaryOp_gt = Core.Name "gt"+_BinaryOp_ge = Core.Name "ge"+-- | A unary operation+data UnaryExpr =+  UnaryExpr {+    -- | The unary operator+    unaryExprOp :: UnaryOp,+    -- | The operand+    unaryExprOperand :: Expression}+  deriving (Eq, Ord, Read, Show)+_UnaryExpr = Core.Name "hydra.rust.syntax.UnaryExpr"+_UnaryExpr_op = Core.Name "op"+_UnaryExpr_operand = Core.Name "operand"+-- | A unary operator+data UnaryOp =+  UnaryOpNeg |+  UnaryOpNot+  deriving (Eq, Ord, Read, Show)+_UnaryOp = Core.Name "hydra.rust.syntax.UnaryOp"+_UnaryOp_neg = Core.Name "neg"+_UnaryOp_not = Core.Name "not"+-- | A reference expression+data RefExpr =+  RefExpr {+    -- | Whether the reference is mutable+    refExprMutable :: Bool,+    -- | The expression being referenced+    refExprExpr :: Expression}+  deriving (Eq, Ord, Read, Show)+_RefExpr = Core.Name "hydra.rust.syntax.RefExpr"+_RefExpr_mutable = Core.Name "mutable"+_RefExpr_expr = Core.Name "expr"+-- | A struct literal expression+data StructExpr =+  StructExpr {+    -- | The struct path+    structExprPath :: ExprPath,+    -- | The field assignments+    structExprFields :: [FieldValue],+    -- | Optional base expression for struct update syntax+    structExprRest :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_StructExpr = Core.Name "hydra.rust.syntax.StructExpr"+_StructExpr_path = Core.Name "path"+_StructExpr_fields = Core.Name "fields"+_StructExpr_rest = Core.Name "rest"+-- | A field-value pair in a struct literal+data FieldValue =+  FieldValue {+    -- | The field name+    fieldValueName :: String,+    -- | The field value (None for shorthand syntax)+    fieldValueValue :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_FieldValue = Core.Name "hydra.rust.syntax.FieldValue"+_FieldValue_name = Core.Name "name"+_FieldValue_value = Core.Name "value"+-- | An array expression+data ArrayExpr =+  -- | An array literal+  ArrayExprElements [Expression] |+  -- | An array repeat expression+  ArrayExprRepeat ArrayRepeat+  deriving (Eq, Ord, Read, Show)+_ArrayExpr = Core.Name "hydra.rust.syntax.ArrayExpr"+_ArrayExpr_elements = Core.Name "elements"+_ArrayExpr_repeat = Core.Name "repeat"+-- | An index expression+data IndexExpr =+  IndexExpr {+    -- | The expression being indexed+    indexExprObject :: Expression,+    -- | The index expression+    indexExprIndex :: Expression}+  deriving (Eq, Ord, Read, Show)+_IndexExpr = Core.Name "hydra.rust.syntax.IndexExpr"+_IndexExpr_object = Core.Name "object"+_IndexExpr_index = Core.Name "index"+-- | A range expression+data RangeExpr =+  RangeExpr {+    -- | The lower bound (optional)+    rangeExprFrom :: (Maybe Expression),+    -- | The upper bound (optional)+    rangeExprTo :: (Maybe Expression),+    -- | Whether the range is inclusive+    rangeExprInclusive :: Bool}+  deriving (Eq, Ord, Read, Show)+_RangeExpr = Core.Name "hydra.rust.syntax.RangeExpr"+_RangeExpr_from = Core.Name "from"+_RangeExpr_to = Core.Name "to"+_RangeExpr_inclusive = Core.Name "inclusive"+-- | A type cast expression+data CastExpr =+  CastExpr {+    -- | The expression being cast+    castExprExpr :: Expression,+    -- | The target type+    castExprType :: Type}+  deriving (Eq, Ord, Read, Show)+_CastExpr = Core.Name "hydra.rust.syntax.CastExpr"+_CastExpr_expr = Core.Name "expr"+_CastExpr_type = Core.Name "type"+-- | A type ascription expression+data TypeAscriptionExpr =+  TypeAscriptionExpr {+    -- | The expression+    typeAscriptionExprExpr :: Expression,+    -- | The ascribed type+    typeAscriptionExprType :: Type}+  deriving (Eq, Ord, Read, Show)+_TypeAscriptionExpr = Core.Name "hydra.rust.syntax.TypeAscriptionExpr"+_TypeAscriptionExpr_expr = Core.Name "expr"+_TypeAscriptionExpr_type = Core.Name "type"+-- | An assignment expression+data AssignExpr =+  AssignExpr {+    -- | The left-hand side (target)+    assignExprTarget :: Expression,+    -- | The right-hand side (value)+    assignExprValue :: Expression}+  deriving (Eq, Ord, Read, Show)+_AssignExpr = Core.Name "hydra.rust.syntax.AssignExpr"+_AssignExpr_target = Core.Name "target"+_AssignExpr_value = Core.Name "value"+-- | A compound assignment expression+data CompoundAssignExpr =+  CompoundAssignExpr {+    -- | The left-hand side (target)+    compoundAssignExprTarget :: Expression,+    -- | The compound assignment operator+    compoundAssignExprOp :: CompoundAssignOp,+    -- | The right-hand side (value)+    compoundAssignExprValue :: Expression}+  deriving (Eq, Ord, Read, Show)+_CompoundAssignExpr = Core.Name "hydra.rust.syntax.CompoundAssignExpr"+_CompoundAssignExpr_target = Core.Name "target"+_CompoundAssignExpr_op = Core.Name "op"+_CompoundAssignExpr_value = Core.Name "value"+-- | A compound assignment operator+data CompoundAssignOp =+  CompoundAssignOpAddAssign |+  CompoundAssignOpSubAssign |+  CompoundAssignOpMulAssign |+  CompoundAssignOpDivAssign |+  CompoundAssignOpRemAssign |+  CompoundAssignOpBitAndAssign |+  CompoundAssignOpBitOrAssign |+  CompoundAssignOpBitXorAssign |+  CompoundAssignOpShlAssign |+  CompoundAssignOpShrAssign+  deriving (Eq, Ord, Read, Show)+_CompoundAssignOp = Core.Name "hydra.rust.syntax.CompoundAssignOp"+_CompoundAssignOp_addAssign = Core.Name "addAssign"+_CompoundAssignOp_subAssign = Core.Name "subAssign"+_CompoundAssignOp_mulAssign = Core.Name "mulAssign"+_CompoundAssignOp_divAssign = Core.Name "divAssign"+_CompoundAssignOp_remAssign = Core.Name "remAssign"+_CompoundAssignOp_bitAndAssign = Core.Name "bitAndAssign"+_CompoundAssignOp_bitOrAssign = Core.Name "bitOrAssign"+_CompoundAssignOp_bitXorAssign = Core.Name "bitXorAssign"+_CompoundAssignOp_shlAssign = Core.Name "shlAssign"+_CompoundAssignOp_shrAssign = Core.Name "shrAssign"+-- | A macro invocation+data MacroInvocation =+  MacroInvocation {+    -- | The macro path+    macroInvocationPath :: [String],+    -- | The delimiter style used+    macroInvocationDelimiter :: MacroDelimiter,+    -- | The token stream as a raw string+    macroInvocationTokens :: String}+  deriving (Eq, Ord, Read, Show)+_MacroInvocation = Core.Name "hydra.rust.syntax.MacroInvocation"+_MacroInvocation_path = Core.Name "path"+_MacroInvocation_delimiter = Core.Name "delimiter"+_MacroInvocation_tokens = Core.Name "tokens"+-- | The delimiter style for a macro invocation+data MacroDelimiter =+  MacroDelimiterParen |+  MacroDelimiterBracket |+  MacroDelimiterBrace+  deriving (Eq, Ord, Read, Show)+_MacroDelimiter = Core.Name "hydra.rust.syntax.MacroDelimiter"+_MacroDelimiter_paren = Core.Name "paren"+_MacroDelimiter_bracket = Core.Name "bracket"+_MacroDelimiter_brace = Core.Name "brace"+-- | A statement within a block+data Statement =+  -- | A let binding+  StatementLet LetStatement |+  -- | An expression statement+  StatementExpression Expression |+  -- | An item declaration within a block+  StatementItem Item |+  -- | An empty statement+  StatementEmpty+  deriving (Eq, Ord, Read, Show)+_Statement = Core.Name "hydra.rust.syntax.Statement"+_Statement_let = Core.Name "let"+_Statement_expression = Core.Name "expression"+_Statement_item = Core.Name "item"+_Statement_empty = Core.Name "empty"+-- | A let statement+data LetStatement =+  LetStatement {+    -- | The binding pattern+    letStatementPattern :: Pattern,+    -- | Whether the binding is mutable+    letStatementMutable :: Bool,+    -- | Optional type annotation+    letStatementType :: (Maybe Type),+    -- | Optional initializer expression+    letStatementInit :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_LetStatement = Core.Name "hydra.rust.syntax.LetStatement"+_LetStatement_pattern = Core.Name "pattern"+_LetStatement_mutable = Core.Name "mutable"+_LetStatement_type = Core.Name "type"+_LetStatement_init = Core.Name "init"+-- | A block expression+data Block =+  Block {+    -- | The statements in the block+    blockStatements :: [Statement],+    -- | An optional trailing expression+    blockExpression :: (Maybe Expression)}+  deriving (Eq, Ord, Read, Show)+_Block = Core.Name "hydra.rust.syntax.Block"+_Block_statements = Core.Name "statements"+_Block_expression = Core.Name "expression"+-- | A Rust pattern (used in let, match, function parameters, etc.)+data Pattern =+  -- | A wildcard pattern (_)+  PatternWildcard |+  -- | An identifier pattern+  PatternIdentifier IdentifierPattern |+  -- | A literal pattern+  PatternLiteral Literal |+  -- | A reference pattern+  PatternReference RefPattern |+  -- | A struct pattern+  PatternStruct StructPattern |+  -- | A tuple struct pattern+  PatternTupleStruct TupleStructPattern |+  -- | A tuple pattern+  PatternTuple [Pattern] |+  -- | A slice pattern+  PatternSlice [Pattern] |+  -- | An or-pattern+  PatternOr [Pattern] |+  -- | A path pattern+  PatternPath ExprPath |+  -- | A range pattern+  PatternRange RangePattern |+  -- | A rest pattern (..)+  PatternRest |+  -- | A parenthesized pattern+  PatternParen Pattern+  deriving (Eq, Ord, Read, Show)+_Pattern = Core.Name "hydra.rust.syntax.Pattern"+_Pattern_wildcard = Core.Name "wildcard"+_Pattern_identifier = Core.Name "identifier"+_Pattern_literal = Core.Name "literal"+_Pattern_reference = Core.Name "reference"+_Pattern_struct = Core.Name "struct"+_Pattern_tupleStruct = Core.Name "tupleStruct"+_Pattern_tuple = Core.Name "tuple"+_Pattern_slice = Core.Name "slice"+_Pattern_or = Core.Name "or"+_Pattern_path = Core.Name "path"+_Pattern_range = Core.Name "range"+_Pattern_rest = Core.Name "rest"+_Pattern_paren = Core.Name "paren"+-- | An identifier pattern+data IdentifierPattern =+  IdentifierPattern {+    -- | The identifier name+    identifierPatternName :: String,+    -- | Whether the binding is mutable+    identifierPatternMutable :: Bool,+    -- | Optional sub-pattern (e.g., x @ Some(_))+    identifierPatternAtPattern :: (Maybe Pattern)}+  deriving (Eq, Ord, Read, Show)+_IdentifierPattern = Core.Name "hydra.rust.syntax.IdentifierPattern"+_IdentifierPattern_name = Core.Name "name"+_IdentifierPattern_mutable = Core.Name "mutable"+_IdentifierPattern_atPattern = Core.Name "atPattern"+-- | A reference pattern+data RefPattern =+  RefPattern {+    -- | Whether the reference is mutable+    refPatternMutable :: Bool,+    -- | The inner pattern+    refPatternPattern :: Pattern}+  deriving (Eq, Ord, Read, Show)+_RefPattern = Core.Name "hydra.rust.syntax.RefPattern"+_RefPattern_mutable = Core.Name "mutable"+_RefPattern_pattern = Core.Name "pattern"+-- | A struct pattern+data StructPattern =+  StructPattern {+    -- | The struct path+    structPatternPath :: ExprPath,+    -- | The field patterns+    structPatternFields :: [FieldPattern],+    -- | Whether the pattern has a rest (..) at the end+    structPatternRest :: Bool}+  deriving (Eq, Ord, Read, Show)+_StructPattern = Core.Name "hydra.rust.syntax.StructPattern"+_StructPattern_path = Core.Name "path"+_StructPattern_fields = Core.Name "fields"+_StructPattern_rest = Core.Name "rest"+-- | A field pattern within a struct pattern+data FieldPattern =+  FieldPattern {+    -- | The field name+    fieldPatternName :: String,+    -- | The field pattern (None for shorthand)+    fieldPatternPattern :: (Maybe Pattern)}+  deriving (Eq, Ord, Read, Show)+_FieldPattern = Core.Name "hydra.rust.syntax.FieldPattern"+_FieldPattern_name = Core.Name "name"+_FieldPattern_pattern = Core.Name "pattern"+-- | A tuple struct pattern+data TupleStructPattern =+  TupleStructPattern {+    -- | The path to the tuple struct or variant+    tupleStructPatternPath :: ExprPath,+    -- | The element patterns+    tupleStructPatternElements :: [Pattern]}+  deriving (Eq, Ord, Read, Show)+_TupleStructPattern = Core.Name "hydra.rust.syntax.TupleStructPattern"+_TupleStructPattern_path = Core.Name "path"+_TupleStructPattern_elements = Core.Name "elements"+-- | A range pattern+data RangePattern =+  RangePattern {+    -- | The lower bound+    rangePatternFrom :: (Maybe Pattern),+    -- | The upper bound+    rangePatternTo :: (Maybe Pattern),+    -- | Whether the range is inclusive+    rangePatternInclusive :: Bool}+  deriving (Eq, Ord, Read, Show)+_RangePattern = Core.Name "hydra.rust.syntax.RangePattern"+_RangePattern_from = Core.Name "from"+_RangePattern_to = Core.Name "to"+_RangePattern_inclusive = Core.Name "inclusive"+-- | A literal value+data Literal =+  -- | An integer literal+  LiteralInteger IntegerLiteral |+  -- | A floating-point literal+  LiteralFloat FloatLiteral |+  -- | A string literal+  LiteralString String |+  -- | A raw string literal+  LiteralRawString String |+  -- | A byte string literal+  LiteralByteString B.ByteString |+  -- | A character literal+  LiteralChar I.Int64 |+  -- | A byte literal+  LiteralByte I.Int16 |+  -- | A boolean literal+  LiteralBool Bool+  deriving (Eq, Ord, Read, Show)+_Literal = Core.Name "hydra.rust.syntax.Literal"+_Literal_integer = Core.Name "integer"+_Literal_float = Core.Name "float"+_Literal_string = Core.Name "string"+_Literal_rawString = Core.Name "rawString"+_Literal_byteString = Core.Name "byteString"+_Literal_char = Core.Name "char"+_Literal_byte = Core.Name "byte"+_Literal_bool = Core.Name "bool"+-- | An integer literal with optional suffix+data IntegerLiteral =+  IntegerLiteral {+    -- | The integer value+    integerLiteralValue :: Integer,+    -- | Optional type suffix+    integerLiteralSuffix :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_IntegerLiteral = Core.Name "hydra.rust.syntax.IntegerLiteral"+_IntegerLiteral_value = Core.Name "value"+_IntegerLiteral_suffix = Core.Name "suffix"+-- | A floating-point literal with optional suffix+data FloatLiteral =+  FloatLiteral {+    -- | The float value+    floatLiteralValue :: Double,+    -- | Optional type suffix+    floatLiteralSuffix :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_FloatLiteral = Core.Name "hydra.rust.syntax.FloatLiteral"+_FloatLiteral_value = Core.Name "value"+_FloatLiteral_suffix = Core.Name "suffix"+-- | An attribute (e.g., #[derive(Clone)], #[cfg(test)])+data Attribute =+  Attribute {+    -- | Whether the attribute is an inner attribute (#![...] vs #[...])+    attributeInner :: Bool,+    -- | The attribute path+    attributePath :: [String],+    -- | The attribute arguments as a raw token string+    attributeTokens :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Attribute = Core.Name "hydra.rust.syntax.Attribute"+_Attribute_inner = Core.Name "inner"+_Attribute_path = Core.Name "path"+_Attribute_tokens = Core.Name "tokens"+-- | A visibility qualifier+data Visibility =+  -- | Public (pub)+  VisibilityPublic |+  -- | Crate-visible (pub(crate))+  VisibilityCrate |+  -- | Visible to a specific path (pub(in path))+  VisibilityRestricted [String] |+  -- | Private (default)+  VisibilityPrivate+  deriving (Eq, Ord, Read, Show)+_Visibility = Core.Name "hydra.rust.syntax.Visibility"+_Visibility_public = Core.Name "public"+_Visibility_crate = Core.Name "crate"+_Visibility_restricted = Core.Name "restricted"+_Visibility_private = Core.Name "private"+-- | A let condition (e.g., let Some(x) = opt)+data LetCondition =+  LetCondition {+    -- | The pattern+    letConditionPattern :: Pattern,+    -- | The expression being matched+    letConditionExpr :: Expression}+  deriving (Eq, Ord, Read, Show)+_LetCondition = Core.Name "hydra.rust.syntax.LetCondition"+_LetCondition_pattern = Core.Name "pattern"+_LetCondition_expr = Core.Name "expr"+-- | An array repeat expression (e.g., [0; 10])+data ArrayRepeat =+  ArrayRepeat {+    -- | The element expression+    arrayRepeatElement :: Expression,+    -- | The length expression+    arrayRepeatLength :: Expression}+  deriving (Eq, Ord, Read, Show)+_ArrayRepeat = Core.Name "hydra.rust.syntax.ArrayRepeat"+_ArrayRepeat_element = Core.Name "element"+_ArrayRepeat_length = Core.Name "length"
+ src/main/haskell/Hydra/Sql/Syntax.hs view
@@ -0,0 +1,976 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A subset of ANSI SQL:2003, capturing selected productions of the BNF grammar provided at https://ronsavage.github.io/SQL/sql-2003-2.bnf.html, which is based on the Final Committee Draft (FCD) of ISO/IEC 9075-2:2003++module Hydra.Sql.Syntax where+import qualified Hydra.Core as Core+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+newtype ApproximateNumericLiteral =+  ApproximateNumericLiteral {+    unApproximateNumericLiteral :: String}+  deriving (Eq, Ord, Read, Show)+_ApproximateNumericLiteral = Core.Name "hydra.sql.syntax.ApproximateNumericLiteral"+newtype BinaryStringLiteral =+  BinaryStringLiteral {+    unBinaryStringLiteral :: ()}+  deriving (Eq, Ord, Read, Show)+_BinaryStringLiteral = Core.Name "hydra.sql.syntax.BinaryStringLiteral"+newtype CharacterStringLiteral =+  CharacterStringLiteral {+    unCharacterStringLiteral :: String}+  deriving (Eq, Ord, Read, Show)+_CharacterStringLiteral = Core.Name "hydra.sql.syntax.CharacterStringLiteral"+newtype ColumnName =+  ColumnName {+    unColumnName :: String}+  deriving (Eq, Ord, Read, Show)+_ColumnName = Core.Name "hydra.sql.syntax.ColumnName"+newtype DateString =+  DateString {+    unDateString :: ()}+  deriving (Eq, Ord, Read, Show)+_DateString = Core.Name "hydra.sql.syntax.DateString"+newtype DomainName =+  DomainName {+    unDomainName :: String}+  deriving (Eq, Ord, Read, Show)+_DomainName = Core.Name "hydra.sql.syntax.DomainName"+newtype ExactNumericLiteral =+  ExactNumericLiteral {+    unExactNumericLiteral :: String}+  deriving (Eq, Ord, Read, Show)+_ExactNumericLiteral = Core.Name "hydra.sql.syntax.ExactNumericLiteral"+newtype LeftBracketOrTrigraph =+  LeftBracketOrTrigraph {+    unLeftBracketOrTrigraph :: String}+  deriving (Eq, Ord, Read, Show)+_LeftBracketOrTrigraph = Core.Name "hydra.sql.syntax.LeftBracketOrTrigraph"+newtype RightBracketOrTrigraph =+  RightBracketOrTrigraph {+    unRightBracketOrTrigraph :: String}+  deriving (Eq, Ord, Read, Show)+_RightBracketOrTrigraph = Core.Name "hydra.sql.syntax.RightBracketOrTrigraph"+newtype NationalCharacterStringLiteral =+  NationalCharacterStringLiteral {+    unNationalCharacterStringLiteral :: ()}+  deriving (Eq, Ord, Read, Show)+_NationalCharacterStringLiteral = Core.Name "hydra.sql.syntax.NationalCharacterStringLiteral"+newtype PathResolvedUserDefinedTypeName =+  PathResolvedUserDefinedTypeName {+    unPathResolvedUserDefinedTypeName :: String}+  deriving (Eq, Ord, Read, Show)+_PathResolvedUserDefinedTypeName = Core.Name "hydra.sql.syntax.PathResolvedUserDefinedTypeName"+newtype TableName =+  TableName {+    unTableName :: String}+  deriving (Eq, Ord, Read, Show)+_TableName = Core.Name "hydra.sql.syntax.TableName"+newtype TimeString =+  TimeString {+    unTimeString :: ()}+  deriving (Eq, Ord, Read, Show)+_TimeString = Core.Name "hydra.sql.syntax.TimeString"+newtype TimestampLiteral =+  TimestampLiteral {+    unTimestampLiteral :: ()}+  deriving (Eq, Ord, Read, Show)+_TimestampLiteral = Core.Name "hydra.sql.syntax.TimestampLiteral"+newtype UnicodeCharacterStringLiteral =+  UnicodeCharacterStringLiteral {+    unUnicodeCharacterStringLiteral :: ()}+  deriving (Eq, Ord, Read, Show)+_UnicodeCharacterStringLiteral = Core.Name "hydra.sql.syntax.UnicodeCharacterStringLiteral"+newtype UnsignedInteger =+  UnsignedInteger {+    unUnsignedInteger :: String}+  deriving (Eq, Ord, Read, Show)+_UnsignedInteger = Core.Name "hydra.sql.syntax.UnsignedInteger"+data ApproximateNumericType =+  ApproximateNumericTypeFloat (Maybe Precision) |+  ApproximateNumericTypeReal |+  ApproximateNumericTypeDouble+  deriving (Eq, Ord, Read, Show)+_ApproximateNumericType = Core.Name "hydra.sql.syntax.ApproximateNumericType"+_ApproximateNumericType_float = Core.Name "float"+_ApproximateNumericType_real = Core.Name "real"+_ApproximateNumericType_double = Core.Name "double"+newtype ArrayElement =+  ArrayElement {+    unArrayElement :: ValueExpression}+  deriving (Eq, Ord, Read, Show)+_ArrayElement = Core.Name "hydra.sql.syntax.ArrayElement"+data ArrayElementList =+  ArrayElementList {+    arrayElementListFirst :: ArrayElement,+    arrayElementListRest :: [ArrayElement]}+  deriving (Eq, Ord, Read, Show)+_ArrayElementList = Core.Name "hydra.sql.syntax.ArrayElementList"+_ArrayElementList_first = Core.Name "first"+_ArrayElementList_rest = Core.Name "rest"+newtype ArrayElementReference =+  ArrayElementReference {+    unArrayElementReference :: ()}+  deriving (Eq, Ord, Read, Show)+_ArrayElementReference = Core.Name "hydra.sql.syntax.ArrayElementReference"+newtype ArrayType =+  ArrayType {+    unArrayType :: ()}+  deriving (Eq, Ord, Read, Show)+_ArrayType = Core.Name "hydra.sql.syntax.ArrayType"+data ArrayValueConstructor =+  ArrayValueConstructorEnumeration ArrayValueConstructorByEnumeration |+  ArrayValueConstructorQuery ArrayValueConstructorByQuery+  deriving (Eq, Ord, Read, Show)+_ArrayValueConstructor = Core.Name "hydra.sql.syntax.ArrayValueConstructor"+_ArrayValueConstructor_enumeration = Core.Name "enumeration"+_ArrayValueConstructor_query = Core.Name "query"+newtype ArrayValueConstructorByQuery =+  ArrayValueConstructorByQuery {+    unArrayValueConstructorByQuery :: ()}+  deriving (Eq, Ord, Read, Show)+_ArrayValueConstructorByQuery = Core.Name "hydra.sql.syntax.ArrayValueConstructorByQuery"+data ArrayValueConstructorByEnumeration =+  ArrayValueConstructorByEnumeration {+    arrayValueConstructorByEnumerationLeftBracketOrTrigraph :: LeftBracketOrTrigraph,+    arrayValueConstructorByEnumerationArrayElementList :: ArrayElementList,+    arrayValueConstructorByEnumerationRightBracketOrTrigraph :: RightBracketOrTrigraph}+  deriving (Eq, Ord, Read, Show)+_ArrayValueConstructorByEnumeration = Core.Name "hydra.sql.syntax.ArrayValueConstructorByEnumeration"+_ArrayValueConstructorByEnumeration_LeftBracketOrTrigraph = Core.Name "LeftBracketOrTrigraph"+_ArrayValueConstructorByEnumeration_ArrayElementList = Core.Name "ArrayElementList"+_ArrayValueConstructorByEnumeration_RightBracketOrTrigraph = Core.Name "RightBracketOrTrigraph"+newtype ArrayValueExpression =+  ArrayValueExpression {+    unArrayValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_ArrayValueExpression = Core.Name "hydra.sql.syntax.ArrayValueExpression"+newtype AsSubqueryClause =+  AsSubqueryClause {+    unAsSubqueryClause :: ()}+  deriving (Eq, Ord, Read, Show)+_AsSubqueryClause = Core.Name "hydra.sql.syntax.AsSubqueryClause"+newtype AttributeOrMethodReference =+  AttributeOrMethodReference {+    unAttributeOrMethodReference :: ()}+  deriving (Eq, Ord, Read, Show)+_AttributeOrMethodReference = Core.Name "hydra.sql.syntax.AttributeOrMethodReference"+data BinaryLargeObjectStringType =+  BinaryLargeObjectStringTypeBinary (Maybe LargeObjectLength) |+  BinaryLargeObjectStringTypeBlob (Maybe LargeObjectLength)+  deriving (Eq, Ord, Read, Show)+_BinaryLargeObjectStringType = Core.Name "hydra.sql.syntax.BinaryLargeObjectStringType"+_BinaryLargeObjectStringType_binary = Core.Name "binary"+_BinaryLargeObjectStringType_blob = Core.Name "blob"+data BooleanFactor =+  BooleanFactor {+    booleanFactorNOT :: (Maybe ()),+    booleanFactorBooleanTest :: BooleanTest}+  deriving (Eq, Ord, Read, Show)+_BooleanFactor = Core.Name "hydra.sql.syntax.BooleanFactor"+_BooleanFactor_NOT = Core.Name "NOT"+_BooleanFactor_BooleanTest = Core.Name "BooleanTest"+data BooleanLiteral =+  BooleanLiteralTRUE |+  BooleanLiteralFALSE |+  BooleanLiteralUNKNOWN+  deriving (Eq, Ord, Read, Show)+_BooleanLiteral = Core.Name "hydra.sql.syntax.BooleanLiteral"+_BooleanLiteral_TRUE = Core.Name "TRUE"+_BooleanLiteral_FALSE = Core.Name "FALSE"+_BooleanLiteral_UNKNOWN = Core.Name "UNKNOWN"+newtype BooleanPredicand =+  BooleanPredicand {+    unBooleanPredicand :: ()}+  deriving (Eq, Ord, Read, Show)+_BooleanPredicand = Core.Name "hydra.sql.syntax.BooleanPredicand"+data BooleanPrimary =+  BooleanPrimaryPredicate Predicate |+  BooleanPrimaryPredicand BooleanPredicand+  deriving (Eq, Ord, Read, Show)+_BooleanPrimary = Core.Name "hydra.sql.syntax.BooleanPrimary"+_BooleanPrimary_predicate = Core.Name "predicate"+_BooleanPrimary_predicand = Core.Name "predicand"+data BooleanTerm =+  BooleanTermFactor BooleanFactor |+  BooleanTermAnd BooleanTerm_And+  deriving (Eq, Ord, Read, Show)+_BooleanTerm = Core.Name "hydra.sql.syntax.BooleanTerm"+_BooleanTerm_factor = Core.Name "factor"+_BooleanTerm_and = Core.Name "and"+data BooleanTerm_And =+  BooleanTerm_And {+    booleanTerm_AndLhs :: BooleanTerm,+    booleanTerm_AndRhs :: BooleanFactor}+  deriving (Eq, Ord, Read, Show)+_BooleanTerm_And = Core.Name "hydra.sql.syntax.BooleanTerm_And"+_BooleanTerm_And_lhs = Core.Name "lhs"+_BooleanTerm_And_rhs = Core.Name "rhs"+data BooleanTest =+  BooleanTest {+    booleanTestBooleanPrimary :: BooleanPrimary,+    booleanTestSequence :: (Maybe BooleanTest_Sequence_Option)}+  deriving (Eq, Ord, Read, Show)+_BooleanTest = Core.Name "hydra.sql.syntax.BooleanTest"+_BooleanTest_BooleanPrimary = Core.Name "BooleanPrimary"+_BooleanTest_Sequence = Core.Name "Sequence"+data BooleanTest_Sequence_Option =+  BooleanTest_Sequence_Option {+    booleanTest_Sequence_OptionNOT :: (Maybe ()),+    booleanTest_Sequence_OptionTruthValue :: TruthValue}+  deriving (Eq, Ord, Read, Show)+_BooleanTest_Sequence_Option = Core.Name "hydra.sql.syntax.BooleanTest_Sequence_Option"+_BooleanTest_Sequence_Option_NOT = Core.Name "NOT"+_BooleanTest_Sequence_Option_TruthValue = Core.Name "TruthValue"+newtype BooleanType =+  BooleanType {+    unBooleanType :: ()}+  deriving (Eq, Ord, Read, Show)+_BooleanType = Core.Name "hydra.sql.syntax.BooleanType"+data BooleanValueExpression =+  BooleanValueExpressionTerm BooleanTerm |+  BooleanValueExpressionOr BooleanValueExpression_Or+  deriving (Eq, Ord, Read, Show)+_BooleanValueExpression = Core.Name "hydra.sql.syntax.BooleanValueExpression"+_BooleanValueExpression_term = Core.Name "term"+_BooleanValueExpression_or = Core.Name "or"+data BooleanValueExpression_Or =+  BooleanValueExpression_Or {+    booleanValueExpression_OrLhs :: BooleanValueExpression,+    booleanValueExpression_OrRhs :: BooleanTerm}+  deriving (Eq, Ord, Read, Show)+_BooleanValueExpression_Or = Core.Name "hydra.sql.syntax.BooleanValueExpression_Or"+_BooleanValueExpression_Or_lhs = Core.Name "lhs"+_BooleanValueExpression_Or_rhs = Core.Name "rhs"+newtype CaseExpression =+  CaseExpression {+    unCaseExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_CaseExpression = Core.Name "hydra.sql.syntax.CaseExpression"+newtype CastSpecification =+  CastSpecification {+    unCastSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_CastSpecification = Core.Name "hydra.sql.syntax.CastSpecification"+newtype CharacterSetSpecification =+  CharacterSetSpecification {+    unCharacterSetSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_CharacterSetSpecification = Core.Name "hydra.sql.syntax.CharacterSetSpecification"+data CharacterStringType =+  CharacterStringTypeCharacter (Maybe Length) |+  CharacterStringTypeChar (Maybe Length) |+  CharacterStringTypeCharacterVarying Length |+  CharacterStringTypeCharVarying Length |+  CharacterStringTypeVarchar Length |+  CharacterStringTypeCharacterLargeObject (Maybe LargeObjectLength) |+  CharacterStringTypeCharLargeObject (Maybe LargeObjectLength) |+  CharacterStringTypeClob (Maybe LargeObjectLength)+  deriving (Eq, Ord, Read, Show)+_CharacterStringType = Core.Name "hydra.sql.syntax.CharacterStringType"+_CharacterStringType_character = Core.Name "character"+_CharacterStringType_char = Core.Name "char"+_CharacterStringType_characterVarying = Core.Name "characterVarying"+_CharacterStringType_charVarying = Core.Name "charVarying"+_CharacterStringType_varchar = Core.Name "varchar"+_CharacterStringType_characterLargeObject = Core.Name "characterLargeObject"+_CharacterStringType_charLargeObject = Core.Name "charLargeObject"+_CharacterStringType_clob = Core.Name "clob"+newtype CollateClause =+  CollateClause {+    unCollateClause :: ()}+  deriving (Eq, Ord, Read, Show)+_CollateClause = Core.Name "hydra.sql.syntax.CollateClause"+data CollectionType =+  CollectionTypeArray ArrayType |+  CollectionTypeMultiset MultisetType+  deriving (Eq, Ord, Read, Show)+_CollectionType = Core.Name "hydra.sql.syntax.CollectionType"+_CollectionType_array = Core.Name "array"+_CollectionType_multiset = Core.Name "multiset"+data CollectionValueConstructor =+  CollectionValueConstructorArray ArrayValueConstructor |+  CollectionValueConstructorMultiset MultisetValueConstructor+  deriving (Eq, Ord, Read, Show)+_CollectionValueConstructor = Core.Name "hydra.sql.syntax.CollectionValueConstructor"+_CollectionValueConstructor_array = Core.Name "array"+_CollectionValueConstructor_multiset = Core.Name "multiset"+data CollectionValueExpression =+  CollectionValueExpressionArray ArrayValueExpression |+  CollectionValueExpressionMultiset MultisetValueExpression+  deriving (Eq, Ord, Read, Show)+_CollectionValueExpression = Core.Name "hydra.sql.syntax.CollectionValueExpression"+_CollectionValueExpression_array = Core.Name "array"+_CollectionValueExpression_multiset = Core.Name "multiset"+newtype ColumnConstraintDefinition =+  ColumnConstraintDefinition {+    unColumnConstraintDefinition :: ()}+  deriving (Eq, Ord, Read, Show)+_ColumnConstraintDefinition = Core.Name "hydra.sql.syntax.ColumnConstraintDefinition"+data ColumnDefinition =+  ColumnDefinition {+    columnDefinitionName :: ColumnName,+    columnDefinitionTypeOrDomain :: (Maybe ColumnDefinition_TypeOrDomain_Option),+    columnDefinitionRefScope :: (Maybe ReferenceScopeCheck),+    columnDefinitionDefaultOrIdentityOrGeneration :: (Maybe ColumnDefinition_DefaultOrIdentityOrGeneration_Option),+    columnDefinitionConstraints :: [ColumnConstraintDefinition],+    columnDefinitionCollate :: (Maybe CollateClause)}+  deriving (Eq, Ord, Read, Show)+_ColumnDefinition = Core.Name "hydra.sql.syntax.ColumnDefinition"+_ColumnDefinition_name = Core.Name "name"+_ColumnDefinition_typeOrDomain = Core.Name "typeOrDomain"+_ColumnDefinition_refScope = Core.Name "refScope"+_ColumnDefinition_defaultOrIdentityOrGeneration = Core.Name "defaultOrIdentityOrGeneration"+_ColumnDefinition_constraints = Core.Name "constraints"+_ColumnDefinition_collate = Core.Name "collate"+data ColumnDefinition_TypeOrDomain_Option =+  ColumnDefinition_TypeOrDomain_OptionDataType DataType |+  ColumnDefinition_TypeOrDomain_OptionDomainName DomainName+  deriving (Eq, Ord, Read, Show)+_ColumnDefinition_TypeOrDomain_Option = Core.Name "hydra.sql.syntax.ColumnDefinition_TypeOrDomain_Option"+_ColumnDefinition_TypeOrDomain_Option_DataType = Core.Name "DataType"+_ColumnDefinition_TypeOrDomain_Option_DomainName = Core.Name "DomainName"+data ColumnDefinition_DefaultOrIdentityOrGeneration_Option =+  ColumnDefinition_DefaultOrIdentityOrGeneration_OptionDefaultClause DefaultClause |+  ColumnDefinition_DefaultOrIdentityOrGeneration_OptionIdentityColumnSpecification IdentityColumnSpecification |+  ColumnDefinition_DefaultOrIdentityOrGeneration_OptionGenerationClause GenerationClause+  deriving (Eq, Ord, Read, Show)+_ColumnDefinition_DefaultOrIdentityOrGeneration_Option =+    Core.Name "hydra.sql.syntax.ColumnDefinition_DefaultOrIdentityOrGeneration_Option"+_ColumnDefinition_DefaultOrIdentityOrGeneration_Option_DefaultClause = Core.Name "DefaultClause"+_ColumnDefinition_DefaultOrIdentityOrGeneration_Option_IdentityColumnSpecification =+    Core.Name "IdentityColumnSpecification"+_ColumnDefinition_DefaultOrIdentityOrGeneration_Option_GenerationClause = Core.Name "GenerationClause"+data ColumnNameList =+  ColumnNameList {+    columnNameListFirst :: ColumnName,+    columnNameListRest :: [ColumnName]}+  deriving (Eq, Ord, Read, Show)+_ColumnNameList = Core.Name "hydra.sql.syntax.ColumnNameList"+_ColumnNameList_first = Core.Name "first"+_ColumnNameList_rest = Core.Name "rest"+newtype ColumnOptions =+  ColumnOptions {+    unColumnOptions :: ()}+  deriving (Eq, Ord, Read, Show)+_ColumnOptions = Core.Name "hydra.sql.syntax.ColumnOptions"+newtype ColumnReference =+  ColumnReference {+    unColumnReference :: ()}+  deriving (Eq, Ord, Read, Show)+_ColumnReference = Core.Name "hydra.sql.syntax.ColumnReference"+data CommonValueExpression =+  CommonValueExpressionNumeric NumericValueExpression |+  CommonValueExpressionString StringValueExpression |+  CommonValueExpressionDatetime DatetimeValueExpression |+  CommonValueExpressionInterval IntervalValueExpression |+  CommonValueExpressionUserDefined UserDefinedTypeValueExpression |+  CommonValueExpressionReference ReferenceValueExpression |+  CommonValueExpressionCollection CollectionValueExpression+  deriving (Eq, Ord, Read, Show)+_CommonValueExpression = Core.Name "hydra.sql.syntax.CommonValueExpression"+_CommonValueExpression_numeric = Core.Name "numeric"+_CommonValueExpression_string = Core.Name "string"+_CommonValueExpression_datetime = Core.Name "datetime"+_CommonValueExpression_interval = Core.Name "interval"+_CommonValueExpression_userDefined = Core.Name "userDefined"+_CommonValueExpression_reference = Core.Name "reference"+_CommonValueExpression_collection = Core.Name "collection"+data ContextuallyTypedRowValueExpression =+  ContextuallyTypedRowValueExpressionSpecialCase RowValueSpecialCase |+  ContextuallyTypedRowValueExpressionConstructor ContextuallyTypedRowValueConstructor+  deriving (Eq, Ord, Read, Show)+_ContextuallyTypedRowValueExpression = Core.Name "hydra.sql.syntax.ContextuallyTypedRowValueExpression"+_ContextuallyTypedRowValueExpression_specialCase = Core.Name "specialCase"+_ContextuallyTypedRowValueExpression_constructor = Core.Name "constructor"+newtype ContextuallyTypedRowValueConstructor =+  ContextuallyTypedRowValueConstructor {+    unContextuallyTypedRowValueConstructor :: ()}+  deriving (Eq, Ord, Read, Show)+_ContextuallyTypedRowValueConstructor = Core.Name "hydra.sql.syntax.ContextuallyTypedRowValueConstructor"+data ContextuallyTypedRowValueExpressionList =+  ContextuallyTypedRowValueExpressionList {+    contextuallyTypedRowValueExpressionListFirst :: ContextuallyTypedRowValueExpression,+    contextuallyTypedRowValueExpressionListRest :: [ContextuallyTypedRowValueExpression]}+  deriving (Eq, Ord, Read, Show)+_ContextuallyTypedRowValueExpressionList = Core.Name "hydra.sql.syntax.ContextuallyTypedRowValueExpressionList"+_ContextuallyTypedRowValueExpressionList_first = Core.Name "first"+_ContextuallyTypedRowValueExpressionList_rest = Core.Name "rest"+newtype ContextuallyTypedTableValueConstructor =+  ContextuallyTypedTableValueConstructor {+    unContextuallyTypedTableValueConstructor :: ContextuallyTypedRowValueExpressionList}+  deriving (Eq, Ord, Read, Show)+_ContextuallyTypedTableValueConstructor = Core.Name "hydra.sql.syntax.ContextuallyTypedTableValueConstructor"+data DataType =+  DataTypePredefined PredefinedType |+  DataTypeRow RowType |+  DataTypeNamed PathResolvedUserDefinedTypeName |+  DataTypeReference ReferenceType |+  DataTypeCollection CollectionType+  deriving (Eq, Ord, Read, Show)+_DataType = Core.Name "hydra.sql.syntax.DataType"+_DataType_predefined = Core.Name "predefined"+_DataType_row = Core.Name "row"+_DataType_named = Core.Name "named"+_DataType_reference = Core.Name "reference"+_DataType_collection = Core.Name "collection"+newtype DateLiteral =+  DateLiteral {+    unDateLiteral :: DateString}+  deriving (Eq, Ord, Read, Show)+_DateLiteral = Core.Name "hydra.sql.syntax.DateLiteral"+data DatetimeLiteral =+  DatetimeLiteralDate DateLiteral |+  DatetimeLiteralTime TimeLiteral |+  DatetimeLiteralTimestamp TimestampLiteral+  deriving (Eq, Ord, Read, Show)+_DatetimeLiteral = Core.Name "hydra.sql.syntax.DatetimeLiteral"+_DatetimeLiteral_date = Core.Name "date"+_DatetimeLiteral_time = Core.Name "time"+_DatetimeLiteral_timestamp = Core.Name "timestamp"+newtype DatetimeType =+  DatetimeType {+    unDatetimeType :: ()}+  deriving (Eq, Ord, Read, Show)+_DatetimeType = Core.Name "hydra.sql.syntax.DatetimeType"+newtype DatetimeValueExpression =+  DatetimeValueExpression {+    unDatetimeValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_DatetimeValueExpression = Core.Name "hydra.sql.syntax.DatetimeValueExpression"+newtype DefaultClause =+  DefaultClause {+    unDefaultClause :: ()}+  deriving (Eq, Ord, Read, Show)+_DefaultClause = Core.Name "hydra.sql.syntax.DefaultClause"+data ExactNumericType =+  ExactNumericTypeNumeric (Maybe ExactNumericType_Numeric_Option) |+  ExactNumericTypeDecimal (Maybe ExactNumericType_Decimal_Option) |+  ExactNumericTypeDec (Maybe ExactNumericType_Dec_Option) |+  ExactNumericTypeSmallint |+  ExactNumericTypeInteger |+  ExactNumericTypeInt |+  ExactNumericTypeBigint+  deriving (Eq, Ord, Read, Show)+_ExactNumericType = Core.Name "hydra.sql.syntax.ExactNumericType"+_ExactNumericType_numeric = Core.Name "numeric"+_ExactNumericType_decimal = Core.Name "decimal"+_ExactNumericType_dec = Core.Name "dec"+_ExactNumericType_smallint = Core.Name "smallint"+_ExactNumericType_integer = Core.Name "integer"+_ExactNumericType_int = Core.Name "int"+_ExactNumericType_bigint = Core.Name "bigint"+data ExactNumericType_Numeric_Option =+  ExactNumericType_Numeric_Option {+    exactNumericType_Numeric_OptionPrecision :: Precision,+    exactNumericType_Numeric_OptionSequence :: (Maybe Scale)}+  deriving (Eq, Ord, Read, Show)+_ExactNumericType_Numeric_Option = Core.Name "hydra.sql.syntax.ExactNumericType_Numeric_Option"+_ExactNumericType_Numeric_Option_Precision = Core.Name "Precision"+_ExactNumericType_Numeric_Option_Sequence = Core.Name "Sequence"+data ExactNumericType_Decimal_Option =+  ExactNumericType_Decimal_Option {+    exactNumericType_Decimal_OptionPrecision :: Precision,+    exactNumericType_Decimal_OptionSequence :: (Maybe Scale)}+  deriving (Eq, Ord, Read, Show)+_ExactNumericType_Decimal_Option = Core.Name "hydra.sql.syntax.ExactNumericType_Decimal_Option"+_ExactNumericType_Decimal_Option_Precision = Core.Name "Precision"+_ExactNumericType_Decimal_Option_Sequence = Core.Name "Sequence"+data ExactNumericType_Dec_Option =+  ExactNumericType_Dec_Option {+    exactNumericType_Dec_OptionPrecision :: Precision,+    exactNumericType_Dec_OptionSequence :: (Maybe Scale)}+  deriving (Eq, Ord, Read, Show)+_ExactNumericType_Dec_Option = Core.Name "hydra.sql.syntax.ExactNumericType_Dec_Option"+_ExactNumericType_Dec_Option_Precision = Core.Name "Precision"+_ExactNumericType_Dec_Option_Sequence = Core.Name "Sequence"+newtype FieldReference =+  FieldReference {+    unFieldReference :: ()}+  deriving (Eq, Ord, Read, Show)+_FieldReference = Core.Name "hydra.sql.syntax.FieldReference"+data FromConstructor =+  FromConstructor {+    fromConstructorColumns :: (Maybe InsertColumnList),+    fromConstructorOverride :: (Maybe OverrideClause),+    fromConstructorValues :: ContextuallyTypedTableValueConstructor}+  deriving (Eq, Ord, Read, Show)+_FromConstructor = Core.Name "hydra.sql.syntax.FromConstructor"+_FromConstructor_columns = Core.Name "columns"+_FromConstructor_override = Core.Name "override"+_FromConstructor_values = Core.Name "values"+newtype FromDefault =+  FromDefault {+    unFromDefault :: ()}+  deriving (Eq, Ord, Read, Show)+_FromDefault = Core.Name "hydra.sql.syntax.FromDefault"+newtype FromSubquery =+  FromSubquery {+    unFromSubquery :: ()}+  deriving (Eq, Ord, Read, Show)+_FromSubquery = Core.Name "hydra.sql.syntax.FromSubquery"+data GeneralLiteral =+  GeneralLiteralString CharacterStringLiteral |+  GeneralLiteralNationalString NationalCharacterStringLiteral |+  GeneralLiteralUnicode UnicodeCharacterStringLiteral |+  GeneralLiteralBinary BinaryStringLiteral |+  GeneralLiteralDateTime DatetimeLiteral |+  GeneralLiteralInterval IntervalLiteral |+  GeneralLiteralBoolean BooleanLiteral+  deriving (Eq, Ord, Read, Show)+_GeneralLiteral = Core.Name "hydra.sql.syntax.GeneralLiteral"+_GeneralLiteral_string = Core.Name "string"+_GeneralLiteral_nationalString = Core.Name "nationalString"+_GeneralLiteral_unicode = Core.Name "unicode"+_GeneralLiteral_binary = Core.Name "binary"+_GeneralLiteral_dateTime = Core.Name "dateTime"+_GeneralLiteral_interval = Core.Name "interval"+_GeneralLiteral_boolean = Core.Name "boolean"+newtype GeneralValueSpecification =+  GeneralValueSpecification {+    unGeneralValueSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_GeneralValueSpecification = Core.Name "hydra.sql.syntax.GeneralValueSpecification"+newtype GenerationClause =+  GenerationClause {+    unGenerationClause :: ()}+  deriving (Eq, Ord, Read, Show)+_GenerationClause = Core.Name "hydra.sql.syntax.GenerationClause"+data GlobalOrLocal =+  GlobalOrLocalGlobal |+  GlobalOrLocalLocal+  deriving (Eq, Ord, Read, Show)+_GlobalOrLocal = Core.Name "hydra.sql.syntax.GlobalOrLocal"+_GlobalOrLocal_global = Core.Name "global"+_GlobalOrLocal_local = Core.Name "local"+newtype IdentityColumnSpecification =+  IdentityColumnSpecification {+    unIdentityColumnSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_IdentityColumnSpecification = Core.Name "hydra.sql.syntax.IdentityColumnSpecification"+newtype InsertColumnList =+  InsertColumnList {+    unInsertColumnList :: ColumnNameList}+  deriving (Eq, Ord, Read, Show)+_InsertColumnList = Core.Name "hydra.sql.syntax.InsertColumnList"+data InsertColumnsAndSource =+  InsertColumnsAndSourceSubquery FromSubquery |+  InsertColumnsAndSourceConstructor FromConstructor |+  InsertColumnsAndSourceDefault FromDefault+  deriving (Eq, Ord, Read, Show)+_InsertColumnsAndSource = Core.Name "hydra.sql.syntax.InsertColumnsAndSource"+_InsertColumnsAndSource_subquery = Core.Name "subquery"+_InsertColumnsAndSource_constructor = Core.Name "constructor"+_InsertColumnsAndSource_default = Core.Name "default"+data InsertStatement =+  InsertStatement {+    insertStatementTarget :: InsertionTarget,+    insertStatementColumnsAndSource :: InsertColumnsAndSource}+  deriving (Eq, Ord, Read, Show)+_InsertStatement = Core.Name "hydra.sql.syntax.InsertStatement"+_InsertStatement_target = Core.Name "target"+_InsertStatement_columnsAndSource = Core.Name "columnsAndSource"+newtype InsertionTarget =+  InsertionTarget {+    unInsertionTarget :: TableName}+  deriving (Eq, Ord, Read, Show)+_InsertionTarget = Core.Name "hydra.sql.syntax.InsertionTarget"+newtype IntervalLiteral =+  IntervalLiteral {+    unIntervalLiteral :: ()}+  deriving (Eq, Ord, Read, Show)+_IntervalLiteral = Core.Name "hydra.sql.syntax.IntervalLiteral"+newtype IntervalType =+  IntervalType {+    unIntervalType :: ()}+  deriving (Eq, Ord, Read, Show)+_IntervalType = Core.Name "hydra.sql.syntax.IntervalType"+newtype IntervalValueExpression =+  IntervalValueExpression {+    unIntervalValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_IntervalValueExpression = Core.Name "hydra.sql.syntax.IntervalValueExpression"+newtype LargeObjectLength =+  LargeObjectLength {+    unLargeObjectLength :: ()}+  deriving (Eq, Ord, Read, Show)+_LargeObjectLength = Core.Name "hydra.sql.syntax.LargeObjectLength"+newtype Length =+  Length {+    unLength :: UnsignedInteger}+  deriving (Eq, Ord, Read, Show)+_Length = Core.Name "hydra.sql.syntax.Length"+newtype LikeClause =+  LikeClause {+    unLikeClause :: ()}+  deriving (Eq, Ord, Read, Show)+_LikeClause = Core.Name "hydra.sql.syntax.LikeClause"+newtype MethodInvocation =+  MethodInvocation {+    unMethodInvocation :: ()}+  deriving (Eq, Ord, Read, Show)+_MethodInvocation = Core.Name "hydra.sql.syntax.MethodInvocation"+newtype MultisetElementReference =+  MultisetElementReference {+    unMultisetElementReference :: ()}+  deriving (Eq, Ord, Read, Show)+_MultisetElementReference = Core.Name "hydra.sql.syntax.MultisetElementReference"+newtype MultisetType =+  MultisetType {+    unMultisetType :: DataType}+  deriving (Eq, Ord, Read, Show)+_MultisetType = Core.Name "hydra.sql.syntax.MultisetType"+newtype MultisetValueConstructor =+  MultisetValueConstructor {+    unMultisetValueConstructor :: ()}+  deriving (Eq, Ord, Read, Show)+_MultisetValueConstructor = Core.Name "hydra.sql.syntax.MultisetValueConstructor"+newtype MultisetValueExpression =+  MultisetValueExpression {+    unMultisetValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_MultisetValueExpression = Core.Name "hydra.sql.syntax.MultisetValueExpression"+newtype NationalCharacterStringType =+  NationalCharacterStringType {+    unNationalCharacterStringType :: ()}+  deriving (Eq, Ord, Read, Show)+_NationalCharacterStringType = Core.Name "hydra.sql.syntax.NationalCharacterStringType"+newtype NewSpecification =+  NewSpecification {+    unNewSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_NewSpecification = Core.Name "hydra.sql.syntax.NewSpecification"+newtype NextValueExpression =+  NextValueExpression {+    unNextValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_NextValueExpression = Core.Name "hydra.sql.syntax.NextValueExpression"+data NumericType =+  NumericTypeExact ExactNumericType |+  NumericTypeApproximate ApproximateNumericType+  deriving (Eq, Ord, Read, Show)+_NumericType = Core.Name "hydra.sql.syntax.NumericType"+_NumericType_exact = Core.Name "exact"+_NumericType_approximate = Core.Name "approximate"+newtype NumericValueExpression =+  NumericValueExpression {+    unNumericValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_NumericValueExpression = Core.Name "hydra.sql.syntax.NumericValueExpression"+data OverrideClause =+  OverrideClauseOVERRIDINGspUSERspVALUE |+  OverrideClauseOVERRIDINGspSYSTEMspVALUE+  deriving (Eq, Ord, Read, Show)+_OverrideClause = Core.Name "hydra.sql.syntax.OverrideClause"+_OverrideClause_OVERRIDINGspUSERspVALUE = Core.Name "OVERRIDINGspUSERspVALUE"+_OverrideClause_OVERRIDINGspSYSTEMspVALUE = Core.Name "OVERRIDINGspSYSTEMspVALUE"+newtype ParenthesizedValueExpression =+  ParenthesizedValueExpression {+    unParenthesizedValueExpression :: ValueExpression}+  deriving (Eq, Ord, Read, Show)+_ParenthesizedValueExpression = Core.Name "hydra.sql.syntax.ParenthesizedValueExpression"+newtype Precision =+  Precision {+    unPrecision :: UnsignedInteger}+  deriving (Eq, Ord, Read, Show)+_Precision = Core.Name "hydra.sql.syntax.Precision"+data PredefinedType =+  PredefinedTypeString PredefinedType_String |+  PredefinedTypeNationalString PredefinedType_NationalString |+  PredefinedTypeBlob BinaryLargeObjectStringType |+  PredefinedTypeNumeric NumericType |+  PredefinedTypeBoolean BooleanType |+  PredefinedTypeDatetime DatetimeType |+  PredefinedTypeInterval IntervalType+  deriving (Eq, Ord, Read, Show)+_PredefinedType = Core.Name "hydra.sql.syntax.PredefinedType"+_PredefinedType_string = Core.Name "string"+_PredefinedType_nationalString = Core.Name "nationalString"+_PredefinedType_blob = Core.Name "blob"+_PredefinedType_numeric = Core.Name "numeric"+_PredefinedType_boolean = Core.Name "boolean"+_PredefinedType_datetime = Core.Name "datetime"+_PredefinedType_interval = Core.Name "interval"+data PredefinedType_String =+  PredefinedType_String {+    predefinedType_StringType :: CharacterStringType,+    predefinedType_StringCharacters :: (Maybe CharacterSetSpecification),+    predefinedType_StringCollate :: (Maybe CollateClause)}+  deriving (Eq, Ord, Read, Show)+_PredefinedType_String = Core.Name "hydra.sql.syntax.PredefinedType_String"+_PredefinedType_String_type = Core.Name "type"+_PredefinedType_String_characters = Core.Name "characters"+_PredefinedType_String_collate = Core.Name "collate"+data PredefinedType_NationalString =+  PredefinedType_NationalString {+    predefinedType_NationalStringType :: NationalCharacterStringType,+    predefinedType_NationalStringCollate :: (Maybe CollateClause)}+  deriving (Eq, Ord, Read, Show)+_PredefinedType_NationalString = Core.Name "hydra.sql.syntax.PredefinedType_NationalString"+_PredefinedType_NationalString_type = Core.Name "type"+_PredefinedType_NationalString_collate = Core.Name "collate"+newtype Predicate =+  Predicate {+    unPredicate :: ()}+  deriving (Eq, Ord, Read, Show)+_Predicate = Core.Name "hydra.sql.syntax.Predicate"+newtype QueryExpression =+  QueryExpression {+    unQueryExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_QueryExpression = Core.Name "hydra.sql.syntax.QueryExpression"+newtype ReferenceScopeCheck =+  ReferenceScopeCheck {+    unReferenceScopeCheck :: ()}+  deriving (Eq, Ord, Read, Show)+_ReferenceScopeCheck = Core.Name "hydra.sql.syntax.ReferenceScopeCheck"+newtype ReferenceType =+  ReferenceType {+    unReferenceType :: ()}+  deriving (Eq, Ord, Read, Show)+_ReferenceType = Core.Name "hydra.sql.syntax.ReferenceType"+newtype RowType =+  RowType {+    unRowType :: ()}+  deriving (Eq, Ord, Read, Show)+_RowType = Core.Name "hydra.sql.syntax.RowType"+newtype RowValueSpecialCase =+  RowValueSpecialCase {+    unRowValueSpecialCase :: NonparenthesizedValueExpressionPrimary}+  deriving (Eq, Ord, Read, Show)+_RowValueSpecialCase = Core.Name "hydra.sql.syntax.RowValueSpecialCase"+data NonparenthesizedValueExpressionPrimary =+  NonparenthesizedValueExpressionPrimaryUnsigned UnsignedValueSpecification |+  NonparenthesizedValueExpressionPrimaryColumn ColumnReference |+  NonparenthesizedValueExpressionPrimarySetFunction SetFunctionSpecification |+  NonparenthesizedValueExpressionPrimaryWindowFunction WindowFunction |+  NonparenthesizedValueExpressionPrimaryScalarSubquery ScalarSubquery |+  NonparenthesizedValueExpressionPrimaryCases CaseExpression |+  NonparenthesizedValueExpressionPrimaryCast CastSpecification |+  NonparenthesizedValueExpressionPrimaryField FieldReference |+  NonparenthesizedValueExpressionPrimarySubtype SubtypeTreatment |+  NonparenthesizedValueExpressionPrimaryMethod MethodInvocation |+  NonparenthesizedValueExpressionPrimaryStaticMethod StaticMethodInvocation |+  NonparenthesizedValueExpressionPrimaryNew NewSpecification |+  NonparenthesizedValueExpressionPrimaryAttributeOrMethod AttributeOrMethodReference |+  NonparenthesizedValueExpressionPrimaryReference ReferenceResolution |+  NonparenthesizedValueExpressionPrimaryCollection CollectionValueConstructor |+  NonparenthesizedValueExpressionPrimaryArrayElement ArrayElementReference |+  NonparenthesizedValueExpressionPrimaryMultisetElement MultisetElementReference |+  NonparenthesizedValueExpressionPrimaryRoutine RoutineInvocation |+  NonparenthesizedValueExpressionPrimaryNext NextValueExpression+  deriving (Eq, Ord, Read, Show)+_NonparenthesizedValueExpressionPrimary = Core.Name "hydra.sql.syntax.NonparenthesizedValueExpressionPrimary"+_NonparenthesizedValueExpressionPrimary_unsigned = Core.Name "unsigned"+_NonparenthesizedValueExpressionPrimary_column = Core.Name "column"+_NonparenthesizedValueExpressionPrimary_setFunction = Core.Name "setFunction"+_NonparenthesizedValueExpressionPrimary_windowFunction = Core.Name "windowFunction"+_NonparenthesizedValueExpressionPrimary_scalarSubquery = Core.Name "scalarSubquery"+_NonparenthesizedValueExpressionPrimary_cases = Core.Name "cases"+_NonparenthesizedValueExpressionPrimary_cast = Core.Name "cast"+_NonparenthesizedValueExpressionPrimary_field = Core.Name "field"+_NonparenthesizedValueExpressionPrimary_subtype = Core.Name "subtype"+_NonparenthesizedValueExpressionPrimary_method = Core.Name "method"+_NonparenthesizedValueExpressionPrimary_staticMethod = Core.Name "staticMethod"+_NonparenthesizedValueExpressionPrimary_new = Core.Name "new"+_NonparenthesizedValueExpressionPrimary_attributeOrMethod = Core.Name "attributeOrMethod"+_NonparenthesizedValueExpressionPrimary_reference = Core.Name "reference"+_NonparenthesizedValueExpressionPrimary_collection = Core.Name "collection"+_NonparenthesizedValueExpressionPrimary_arrayElement = Core.Name "arrayElement"+_NonparenthesizedValueExpressionPrimary_multisetElement = Core.Name "multisetElement"+_NonparenthesizedValueExpressionPrimary_routine = Core.Name "routine"+_NonparenthesizedValueExpressionPrimary_next = Core.Name "next"+newtype ReferenceResolution =+  ReferenceResolution {+    unReferenceResolution :: ()}+  deriving (Eq, Ord, Read, Show)+_ReferenceResolution = Core.Name "hydra.sql.syntax.ReferenceResolution"+newtype ReferenceValueExpression =+  ReferenceValueExpression {+    unReferenceValueExpression :: ValueExpressionPrimary}+  deriving (Eq, Ord, Read, Show)+_ReferenceValueExpression = Core.Name "hydra.sql.syntax.ReferenceValueExpression"+newtype RowValueExpression =+  RowValueExpression {+    unRowValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_RowValueExpression = Core.Name "hydra.sql.syntax.RowValueExpression"+newtype RoutineInvocation =+  RoutineInvocation {+    unRoutineInvocation :: ()}+  deriving (Eq, Ord, Read, Show)+_RoutineInvocation = Core.Name "hydra.sql.syntax.RoutineInvocation"+newtype ScalarSubquery =+  ScalarSubquery {+    unScalarSubquery :: Subquery}+  deriving (Eq, Ord, Read, Show)+_ScalarSubquery = Core.Name "hydra.sql.syntax.ScalarSubquery"+newtype Scale =+  Scale {+    unScale :: UnsignedInteger}+  deriving (Eq, Ord, Read, Show)+_Scale = Core.Name "hydra.sql.syntax.Scale"+newtype SelfReferencingColumnSpecification =+  SelfReferencingColumnSpecification {+    unSelfReferencingColumnSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_SelfReferencingColumnSpecification = Core.Name "hydra.sql.syntax.SelfReferencingColumnSpecification"+newtype SetFunctionSpecification =+  SetFunctionSpecification {+    unSetFunctionSpecification :: ()}+  deriving (Eq, Ord, Read, Show)+_SetFunctionSpecification = Core.Name "hydra.sql.syntax.SetFunctionSpecification"+newtype StaticMethodInvocation =+  StaticMethodInvocation {+    unStaticMethodInvocation :: ()}+  deriving (Eq, Ord, Read, Show)+_StaticMethodInvocation = Core.Name "hydra.sql.syntax.StaticMethodInvocation"+newtype StringValueExpression =+  StringValueExpression {+    unStringValueExpression :: ()}+  deriving (Eq, Ord, Read, Show)+_StringValueExpression = Core.Name "hydra.sql.syntax.StringValueExpression"+newtype Subquery =+  Subquery {+    unSubquery :: QueryExpression}+  deriving (Eq, Ord, Read, Show)+_Subquery = Core.Name "hydra.sql.syntax.Subquery"+newtype SubtableClause =+  SubtableClause {+    unSubtableClause :: ()}+  deriving (Eq, Ord, Read, Show)+_SubtableClause = Core.Name "hydra.sql.syntax.SubtableClause"+newtype SubtypeTreatment =+  SubtypeTreatment {+    unSubtypeTreatment :: ()}+  deriving (Eq, Ord, Read, Show)+_SubtypeTreatment = Core.Name "hydra.sql.syntax.SubtypeTreatment"+data TableCommitAction =+  TableCommitActionPreserve |+  TableCommitActionDelete+  deriving (Eq, Ord, Read, Show)+_TableCommitAction = Core.Name "hydra.sql.syntax.TableCommitAction"+_TableCommitAction_preserve = Core.Name "preserve"+_TableCommitAction_delete = Core.Name "delete"+newtype TableConstraintDefinition =+  TableConstraintDefinition {+    unTableConstraintDefinition :: ()}+  deriving (Eq, Ord, Read, Show)+_TableConstraintDefinition = Core.Name "hydra.sql.syntax.TableConstraintDefinition"+data TableContentsSource =+  TableContentsSourceList TableElementList |+  TableContentsSourceSubtable TableContentsSource_Subtable |+  TableContentsSourceSubquery AsSubqueryClause+  deriving (Eq, Ord, Read, Show)+_TableContentsSource = Core.Name "hydra.sql.syntax.TableContentsSource"+_TableContentsSource_list = Core.Name "list"+_TableContentsSource_subtable = Core.Name "subtable"+_TableContentsSource_subquery = Core.Name "subquery"+data TableContentsSource_Subtable =+  TableContentsSource_Subtable {+    tableContentsSource_SubtableType :: PathResolvedUserDefinedTypeName,+    tableContentsSource_SubtableSubtable :: (Maybe SubtableClause),+    tableContentsSource_SubtableElements :: (Maybe TableElementList)}+  deriving (Eq, Ord, Read, Show)+_TableContentsSource_Subtable = Core.Name "hydra.sql.syntax.TableContentsSource_Subtable"+_TableContentsSource_Subtable_type = Core.Name "type"+_TableContentsSource_Subtable_subtable = Core.Name "subtable"+_TableContentsSource_Subtable_elements = Core.Name "elements"+data TableDefinition =+  TableDefinition {+    tableDefinitionScope :: (Maybe TableScope),+    tableDefinitionName :: TableName,+    tableDefinitionSource :: TableContentsSource,+    tableDefinitionCommitActions :: (Maybe TableCommitAction)}+  deriving (Eq, Ord, Read, Show)+_TableDefinition = Core.Name "hydra.sql.syntax.TableDefinition"+_TableDefinition_scope = Core.Name "scope"+_TableDefinition_name = Core.Name "name"+_TableDefinition_source = Core.Name "source"+_TableDefinition_commitActions = Core.Name "commitActions"+data TableElement =+  TableElementColumn ColumnDefinition |+  TableElementTableConstraint TableConstraintDefinition |+  TableElementLike LikeClause |+  TableElementSelfReferencingColumn SelfReferencingColumnSpecification |+  TableElementColumOptions ColumnOptions+  deriving (Eq, Ord, Read, Show)+_TableElement = Core.Name "hydra.sql.syntax.TableElement"+_TableElement_column = Core.Name "column"+_TableElement_tableConstraint = Core.Name "tableConstraint"+_TableElement_like = Core.Name "like"+_TableElement_selfReferencingColumn = Core.Name "selfReferencingColumn"+_TableElement_columOptions = Core.Name "columOptions"+data TableElementList =+  TableElementList {+    tableElementListFirst :: TableElement,+    tableElementListRest :: [TableElement]}+  deriving (Eq, Ord, Read, Show)+_TableElementList = Core.Name "hydra.sql.syntax.TableElementList"+_TableElementList_first = Core.Name "first"+_TableElementList_rest = Core.Name "rest"+newtype TableScope =+  TableScope {+    unTableScope :: GlobalOrLocal}+  deriving (Eq, Ord, Read, Show)+_TableScope = Core.Name "hydra.sql.syntax.TableScope"+newtype TimeLiteral =+  TimeLiteral {+    unTimeLiteral :: TimeString}+  deriving (Eq, Ord, Read, Show)+_TimeLiteral = Core.Name "hydra.sql.syntax.TimeLiteral"+data TruthValue =+  TruthValueTRUE |+  TruthValueFALSE |+  TruthValueUNKNOWN+  deriving (Eq, Ord, Read, Show)+_TruthValue = Core.Name "hydra.sql.syntax.TruthValue"+_TruthValue_TRUE = Core.Name "TRUE"+_TruthValue_FALSE = Core.Name "FALSE"+_TruthValue_UNKNOWN = Core.Name "UNKNOWN"+data UnsignedLiteral =+  UnsignedLiteralNumeric UnsignedNumericLiteral |+  UnsignedLiteralGeneral GeneralLiteral+  deriving (Eq, Ord, Read, Show)+_UnsignedLiteral = Core.Name "hydra.sql.syntax.UnsignedLiteral"+_UnsignedLiteral_numeric = Core.Name "numeric"+_UnsignedLiteral_general = Core.Name "general"+data UnsignedNumericLiteral =+  UnsignedNumericLiteralExact ExactNumericLiteral |+  UnsignedNumericLiteralApproximate ApproximateNumericLiteral+  deriving (Eq, Ord, Read, Show)+_UnsignedNumericLiteral = Core.Name "hydra.sql.syntax.UnsignedNumericLiteral"+_UnsignedNumericLiteral_exact = Core.Name "exact"+_UnsignedNumericLiteral_approximate = Core.Name "approximate"+data UnsignedValueSpecification =+  UnsignedValueSpecificationLiteral UnsignedLiteral |+  UnsignedValueSpecificationGeneral GeneralValueSpecification+  deriving (Eq, Ord, Read, Show)+_UnsignedValueSpecification = Core.Name "hydra.sql.syntax.UnsignedValueSpecification"+_UnsignedValueSpecification_literal = Core.Name "literal"+_UnsignedValueSpecification_general = Core.Name "general"+newtype UserDefinedTypeValueExpression =+  UserDefinedTypeValueExpression {+    unUserDefinedTypeValueExpression :: ValueExpressionPrimary}+  deriving (Eq, Ord, Read, Show)+_UserDefinedTypeValueExpression = Core.Name "hydra.sql.syntax.UserDefinedTypeValueExpression"+data ValueExpression =+  ValueExpressionCommon CommonValueExpression |+  ValueExpressionBoolean BooleanValueExpression |+  ValueExpressionRow RowValueExpression+  deriving (Eq, Ord, Read, Show)+_ValueExpression = Core.Name "hydra.sql.syntax.ValueExpression"+_ValueExpression_common = Core.Name "common"+_ValueExpression_boolean = Core.Name "boolean"+_ValueExpression_row = Core.Name "row"+data ValueExpressionPrimary =+  ValueExpressionPrimaryParens ParenthesizedValueExpression |+  ValueExpressionPrimaryNoparens NonparenthesizedValueExpressionPrimary+  deriving (Eq, Ord, Read, Show)+_ValueExpressionPrimary = Core.Name "hydra.sql.syntax.ValueExpressionPrimary"+_ValueExpressionPrimary_parens = Core.Name "parens"+_ValueExpressionPrimary_noparens = Core.Name "noparens"+newtype WindowFunction =+  WindowFunction {+    unWindowFunction :: ()}+  deriving (Eq, Ord, Read, Show)+_WindowFunction = Core.Name "hydra.sql.syntax.WindowFunction"
+ src/main/haskell/Hydra/Stac/Items.hs view
@@ -0,0 +1,135 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for SpatioTemporal Asset Catalog (STAC) Items. See https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md++module Hydra.Stac.Items where+import qualified Hydra.Core as Core+import qualified Hydra.Geojson.Model as Model+import qualified Hydra.Iana.Linkrelations as Linkrelations+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+import qualified Data.Map as M+-- | An Asset is an object that contains a URI to data associated with the Item that can be downloaded or streamed. It is allowed to add additional fields.+data Asset =+  Asset {+    -- | URI to the asset object. Relative and absolute URI are both allowed.+    assetHref :: Uri,+    -- | The displayed title for clients and users.+    assetTitle :: (Maybe String),+    -- | A description of the Asset providing additional details, such as how it was processed or created. CommonMark 0.29 syntax MAY be used for rich text representation.+    assetDescription :: (Maybe String),+    -- | Media type of the asset. See the common media types in the best practice doc for commonly used asset types.+    assetType :: (Maybe MediaType),+    -- | The semantic roles of the asset, similar to the use of rel in links.+    assetRoles :: [Role]}+  deriving (Eq, Ord, Read, Show)+_Asset = Core.Name "hydra.stac.items.Asset"+_Asset_href = Core.Name "href"+_Asset_title = Core.Name "title"+_Asset_description = Core.Name "description"+_Asset_type = Core.Name "type"+_Asset_roles = Core.Name "roles"+-- | This object describes a STAC Item. The fields id, type, bbox, geometry and properties are inherited from GeoJSON.+data Item =+  Item {+    itemFeature :: Model.Feature,+    -- | The STAC version the Item implements+    itemStacVersion :: StacVersion,+    -- | A list of extensions the Item implements+    itemStacExtensions :: [Url],+    -- | List of link objects to resources and related URLs. A link with the rel set to self is strongly recommended.+    itemLinks :: [Link],+    -- | Dictionary of asset objects that can be downloaded, each with a unique key.+    itemAssets :: (M.Map String Asset),+    -- | The id of the STAC Collection this Item references to (see collection relation type). This field is required if such a relation type is present and is not allowed otherwise. This field provides an easy way for a user to search for any Items that belong in a specified Collection. Must be a non-empty string.+    itemCollection :: (Maybe Model.Id)}+  deriving (Eq, Ord, Read, Show)+_Item = Core.Name "hydra.stac.items.Item"+_Item_feature = Core.Name "feature"+_Item_stacVersion = Core.Name "stacVersion"+_Item_stacExtensions = Core.Name "stacExtensions"+_Item_links = Core.Name "links"+_Item_assets = Core.Name "assets"+_Item_collection = Core.Name "collection"+-- | This object describes a relationship with another entity. Data providers are advised to be liberal with the links section, to describe things like the Catalog an Item is in, related Items, parent or child Items (modeled in different ways, like an 'acquisition' or derived data). It is allowed to add additional fields such as a title and type.+data Link =+  Link {+    -- | The actual link in the format of an URL. Relative and absolute links are both allowed.+    linkHref :: Url,+    -- | Relationship between the current document and the linked document. See chapter "Relation types" for more information.+    linkRel :: RelationType,+    -- | Media type of the referenced entity.+    linkType :: (Maybe MediaType),+    -- | A human readable title to be used in rendered displays of the link.+    linkTitle :: (Maybe String)}+  deriving (Eq, Ord, Read, Show)+_Link = Core.Name "hydra.stac.items.Link"+_Link_href = Core.Name "href"+_Link_rel = Core.Name "rel"+_Link_type = Core.Name "type"+_Link_title = Core.Name "title"+newtype MediaType =+  MediaType {+    unMediaType :: String}+  deriving (Eq, Ord, Read, Show)+_MediaType = Core.Name "hydra.stac.items.MediaType"+-- | STAC Items use a variety of rel types in the link object, to describe the exact nature of the link between this Item and the entity it is linking to. It is recommended to use the official IANA Link Relation Types where possible. The following table explains places where STAC use custom rel types are used with Items. This happens where there is not a clear official option, or where STAC uses an official type but adds additional meaning for the STAC context.+data RelationType =+  RelationTypeIana Linkrelations.LinkRelationType |+  RelationTypeStac StacRelationType |+  RelationTypeOther String+  deriving (Eq, Ord, Read, Show)+_RelationType = Core.Name "hydra.stac.items.RelationType"+_RelationType_iana = Core.Name "iana"+_RelationType_stac = Core.Name "stac"+_RelationType_other = Core.Name "other"+-- | The roles field is used to describe the purpose of each asset. It is recommended to include one for every asset, to give users a sense of why they might want to make use of the asset. There are some emerging standards that enable clients to take particular action when they encounter particular roles, listed below. But implementors are encouraged to come up with their own terms to describe the role.+data Role =+  -- | An asset that represents a thumbnail of the Item, typically a true color image (for Items with assets in the visible wavelengths), lower-resolution (typically smaller 600x600 pixels), and typically a JPEG or PNG (suitable for display in a web browser). Multiple assets may have this purpose, but it recommended that the type and roles be unique tuples. For example, Sentinel-2 L2A provides thumbnail images in both JPEG and JPEG2000 formats, and would be distinguished by their media types.+  RoleThumbnail |+  -- | An asset that represents a possibly larger view than the thumbnail of the Item, for example, a true color composite of multi-band data.+  RoleOverview |+  -- | The data itself. This is a suggestion for a common role for data files to be used in case data providers don't come up with their own names and semantics.+  RoleData |+  -- | A metadata sidecar file describing the data in this Item, for example the Landsat-8 MTL file.+  RoleMetadata |+  RoleOther String+  deriving (Eq, Ord, Read, Show)+_Role = Core.Name "hydra.stac.items.Role"+_Role_thumbnail = Core.Name "thumbnail"+_Role_overview = Core.Name "overview"+_Role_data = Core.Name "data"+_Role_metadata = Core.Name "metadata"+_Role_other = Core.Name "other"+data StacRelationType =+  -- | STRONGLY RECOMMENDED. Absolute URL to the Item if it is available at a public URL. This is particularly useful when in a download package that includes metadata, so that the downstream user can know where the data has come from.+  StacRelationTypeSelf |+  -- | URL to the root STAC entity (Catalog or Collection).+  StacRelationTypeRoot |+  -- | URL to the parent STAC entity (Catalog or Collection).+  StacRelationTypeParent |+  -- | STRONGLY RECOMMENDED. URL to a Collection. Absolute URLs should be used whenever possible. The referenced Collection is STRONGLY RECOMMENDED to implement the same STAC version as the Item. A link with this rel type is required if the collection field in properties is present.+  StacRelationTypeCollection |+  -- | URL to a STAC Item that was used as input data in the creation of this Item.+  StacRelationTypeDerivedFrom+  deriving (Eq, Ord, Read, Show)+_StacRelationType = Core.Name "hydra.stac.items.StacRelationType"+_StacRelationType_self = Core.Name "self"+_StacRelationType_root = Core.Name "root"+_StacRelationType_parent = Core.Name "parent"+_StacRelationType_collection = Core.Name "collection"+_StacRelationType_derivedFrom = Core.Name "derivedFrom"+newtype StacVersion =+  StacVersion {+    unStacVersion :: String}+  deriving (Eq, Ord, Read, Show)+_StacVersion = Core.Name "hydra.stac.items.StacVersion"+newtype Uri =+  Uri {+    unUri :: String}+  deriving (Eq, Ord, Read, Show)+_Uri = Core.Name "hydra.stac.items.Uri"+newtype Url =+  Url {+    unUrl :: String}+  deriving (Eq, Ord, Read, Show)+_Url = Core.Name "hydra.stac.items.Url"
+ src/main/haskell/Hydra/Workflow.hs view
@@ -0,0 +1,50 @@+-- Note: this is an automatically generated file. Do not edit.+-- | A model for Hydra transformation workflows++module Hydra.Workflow where+import qualified Hydra.Core as Core+import qualified Hydra.Graph as Graph+import qualified Hydra.Packaging as Packaging+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | The specification of a Hydra schema, provided as a set of modules and a distinguished type+data HydraSchemaSpec =+  HydraSchemaSpec {+    -- | The modules to include in the schema graph+    hydraSchemaSpecModules :: [Packaging.Module],+    -- | The name of the top-level type; all data which passes through the workflow will be instances of this type+    hydraSchemaSpecTypeName :: Core.Name}+  deriving (Eq, Ord, Read, Show)+_HydraSchemaSpec = Core.Name "hydra.workflow.HydraSchemaSpec"+_HydraSchemaSpec_modules = Core.Name "modules"+_HydraSchemaSpec_typeName = Core.Name "typeName"+-- | The specification of a schema at the source end of a workflow+data SchemaSpec =+  -- | A native Hydra schema+  SchemaSpecHydra HydraSchemaSpec |+  -- | A schema provided as a file, available at the given file path+  SchemaSpecFile String |+  -- | A schema which will be provided within the workflow+  SchemaSpecProvided+  deriving (Eq, Ord, Read, Show)+_SchemaSpec = Core.Name "hydra.workflow.SchemaSpec"+_SchemaSpec_hydra = Core.Name "hydra"+_SchemaSpec_file = Core.Name "file"+_SchemaSpec_provided = Core.Name "provided"+-- | The specification of a workflow which takes a schema specification, reads data from a directory, and writes data to another directory+data TransformWorkflow =+  TransformWorkflow {+    -- | A descriptive name for the workflow+    transformWorkflowName :: String,+    -- | The schema specification+    transformWorkflowSchemaSpec :: SchemaSpec,+    -- | The source directory+    transformWorkflowSrcDir :: String,+    -- | The destination directory+    transformWorkflowDestDir :: String}+  deriving (Eq, Ord, Read, Show)+_TransformWorkflow = Core.Name "hydra.workflow.TransformWorkflow"+_TransformWorkflow_name = Core.Name "name"+_TransformWorkflow_schemaSpec = Core.Name "schemaSpec"+_TransformWorkflow_srcDir = Core.Name "srcDir"+_TransformWorkflow_destDir = Core.Name "destDir"
+ src/main/haskell/Hydra/Yaml/Coder.hs view
@@ -0,0 +1,261 @@+-- Note: this is an automatically generated file. Do not edit.+-- | YAML encoding and decoding for Hydra terms++module Hydra.Yaml.Coder where+import qualified Hydra.Adapt as Adapt+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Extract.Core as ExtractCore+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as JsonModel+import qualified Hydra.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as LibLiterals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Literals as Literals+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Show.Core as ShowCore+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import qualified Hydra.Yaml.Language as Language+import qualified Hydra.Yaml.Model as YamlModel+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Decode a YAML value to a record term+decodeRecord :: Core.Name -> [(Core.FieldType, (Coders.Coder Core.Term YamlModel.Node Errors.Error))] -> YamlModel.Node -> Either Errors.Error Core.Term+decodeRecord tname coders n =++      let decodeObjectBody =+              \m ->+                let decodeField =+                        \coder ->+                          let ft = Pairs.first coder+                              coder_ = Pairs.second coder+                              fname = Core.fieldTypeName ft+                              defaultValue = YamlModel.NodeScalar YamlModel.ScalarNull+                              yamlValue = Optionals.fromOptional defaultValue (Maps.lookup (YamlModel.NodeScalar (YamlModel.ScalarStr (Core.unName fname))) m)+                          in (Eithers.bind (Coders.coderDecode coder_ yamlValue) (\v -> Right (Core.Field {+                            Core.fieldName = fname,+                            Core.fieldTerm = v})))+                in (Eithers.bind (Eithers.mapList decodeField coders) (\fields -> Right (Core.TermRecord (Core.Record {+                  Core.recordTypeName = tname,+                  Core.recordFields = fields}))))+      in case n of+        YamlModel.NodeMapping v0 -> decodeObjectBody v0+        _ -> Left (Errors.ErrorOther (Errors.OtherError "expected mapping"))+-- | Encode a record term to YAML+encodeRecord :: [(Core.FieldType, (Coders.Coder Core.Term YamlModel.Node Errors.Error))] -> Graph.Graph -> Core.Term -> Either Errors.Error YamlModel.Node+encodeRecord coders graph term =++      let stripped = Strip.deannotateTerm term+          isMaybeNothing =+                  \ft -> \fvalue -> case (Core.fieldTypeType ft) of+                    Core.TypeOptional _ -> case fvalue of+                      Core.TermOptional v1 -> Optionals.isNone v1+                      _ -> False+                    _ -> False+          encodeField =+                  \coderAndField ->+                    let ftAndCoder = Pairs.first coderAndField+                        field = Pairs.second coderAndField+                        ft = Pairs.first ftAndCoder+                        coder_ = Pairs.second ftAndCoder+                        fname = Core.fieldName field+                        fvalue = Core.fieldTerm field+                    in (Logic.ifElse (isMaybeNothing ft fvalue) (Right Nothing) (Eithers.bind (Coders.coderEncode coder_ fvalue) (\encoded -> Right (Just (YamlModel.NodeScalar (YamlModel.ScalarStr (Core.unName fname)), encoded)))))+      in (Eithers.bind (ExtractCore.termRecord graph stripped) (\record ->+        let fields = Core.recordFields record+        in (Eithers.bind (Eithers.mapList encodeField (Lists.zip coders fields)) (\maybeFields -> Right (YamlModel.NodeMapping (Maps.fromList (Optionals.cat maybeFields)))))))+-- | Create a YAML coder for literal types+literalYamlCoder :: Core.LiteralType -> Either t0 (Coders.Coder Core.Literal YamlModel.Scalar Errors.Error)+literalYamlCoder lt =++      let decodeBool =+              \s -> case s of+                YamlModel.ScalarBool v0 -> Right (Core.LiteralBoolean v0)+                _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                  "expected boolean, found scalar"])))+          decodeDecimal =+                  \s -> case s of+                    YamlModel.ScalarDecimal v0 -> Right (Core.LiteralDecimal v0)+                    YamlModel.ScalarFloat v0 -> Right (Core.LiteralDecimal (LibLiterals.float64ToDecimal v0))+                    YamlModel.ScalarInt v0 -> Right (Core.LiteralDecimal (LibLiterals.bigintToDecimal v0))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected decimal, found scalar"])))+          decodeFloat =+                  \s -> case s of+                    YamlModel.ScalarDecimal v0 -> Right (Core.LiteralFloat (Core.FloatValueFloat64 (LibLiterals.decimalToFloat64 v0)))+                    YamlModel.ScalarFloat v0 -> Right (Core.LiteralFloat (Core.FloatValueFloat64 v0))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected float, found scalar"])))+          decodeInteger =+                  \s -> case s of+                    YamlModel.ScalarInt v0 -> Right (Core.LiteralInteger (Core.IntegerValueBigint v0))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected integer, found scalar"])))+          decodeString =+                  \s -> case s of+                    YamlModel.ScalarStr v0 -> Right (Core.LiteralString v0)+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected string, found scalar"])))+          encoded =+                  case lt of+                    Core.LiteralTypeBoolean -> Coders.Coder {+                      Coders.coderEncode = (\lit -> Eithers.bind (ExtractCore.booleanLiteral lit) (\b -> Right (YamlModel.ScalarBool b))),+                      Coders.coderDecode = decodeBool}+                    Core.LiteralTypeDecimal -> Coders.Coder {+                      Coders.coderEncode = (\lit -> Eithers.bind (ExtractCore.decimalLiteral lit) (\d -> Right (YamlModel.ScalarDecimal d))),+                      Coders.coderDecode = decodeDecimal}+                    Core.LiteralTypeFloat _ -> Coders.Coder {+                      Coders.coderEncode = (\lit -> Eithers.bind (ExtractCore.floatLiteral lit) (\f ->+                        let bf =+                                case f of+                                  Core.FloatValueFloat32 v1 -> LibLiterals.float32ToFloat64 v1+                                  Core.FloatValueFloat64 v1 -> v1+                            shown = LibLiterals.showFloat64 bf+                        in (Logic.ifElse (requiresYamlStringSentinel shown) (Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                          "YAML cannot represent float value: ",+                          shown])))) (Right (YamlModel.ScalarFloat bf))))),+                      Coders.coderDecode = decodeFloat}+                    Core.LiteralTypeInteger _ -> Coders.Coder {+                      Coders.coderEncode = (\lit -> Eithers.bind (ExtractCore.integerLiteral lit) (\i -> Eithers.bind (ExtractCore.bigintValue i) (\bi -> Right (YamlModel.ScalarInt bi)))),+                      Coders.coderDecode = decodeInteger}+                    Core.LiteralTypeString -> Coders.Coder {+                      Coders.coderEncode = (\lit -> Eithers.bind (ExtractCore.stringLiteral lit) (\s -> Right (YamlModel.ScalarStr s))),+                      Coders.coderDecode = decodeString}+      in (Right encoded)+-- | Create a YAML coder for record types+recordCoder :: Core.Name -> [Core.FieldType] -> t0 -> Graph.Graph -> Either Errors.Error (Coders.Coder Core.Term YamlModel.Node Errors.Error)+recordCoder tname rt cx g =++      let getCoder = \f -> Eithers.bind (termCoder (Core.fieldTypeType f) cx g) (\coder -> Right (f, coder))+      in (Eithers.bind (Eithers.mapList getCoder rt) (\coders -> Right (Coders.Coder {+        Coders.coderEncode = (\term -> encodeRecord coders g term),+        Coders.coderDecode = (\val -> decodeRecord tname coders val)})))+-- | True for IEEE sentinel strings that Hydra YAML cannot represent as a float scalar.+requiresYamlStringSentinel :: String -> Bool+requiresYamlStringSentinel s =+    Logic.or (Equality.equal s "NaN") (Logic.or (Equality.equal s "Infinity") (Logic.or (Equality.equal s "-Infinity") (Equality.equal s "-0.0")))+-- | Create a YAML coder for term types+termCoder :: Core.Type -> t0 -> Graph.Graph -> Either Errors.Error (Coders.Coder Core.Term YamlModel.Node Errors.Error)+termCoder typ cx g =++      let stripped = Strip.deannotateType typ+          encodeLiteral =+                  \ac -> \term -> case term of+                    Core.TermLiteral v0 -> Eithers.bind (Coders.coderEncode ac v0) (\scalar -> Right (YamlModel.NodeScalar scalar))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected literal term, found: ",+                      (ShowCore.term term)])))+          encodeList =+                  \lc -> \term -> case term of+                    Core.TermList v0 -> Eithers.bind (Eithers.mapList (\el -> Coders.coderEncode lc el) v0) (\encodedEls -> Right (YamlModel.NodeSequence encodedEls))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "expected list term, found: ",+                      (ShowCore.term term)])))+          decodeList =+                  \lc -> \n -> case n of+                    YamlModel.NodeSequence v0 -> Eithers.bind (Eithers.mapList (\node -> Coders.coderDecode lc node) v0) (\decodedNodes -> Right (Core.TermList decodedNodes))+                    _ -> Left (Errors.ErrorOther (Errors.OtherError "expected sequence"))+          encodeMaybe =+                  \maybeElementCoder -> \optionalTerm ->+                    let strippedMaybeTerm = Strip.deannotateTerm optionalTerm+                    in case strippedMaybeTerm of+                      Core.TermOptional v0 -> Optionals.cases v0 (Right (YamlModel.NodeScalar YamlModel.ScalarNull)) (\innerTerm -> Eithers.bind (Coders.coderEncode maybeElementCoder innerTerm) (\encodedInner -> Right encodedInner))+                      _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                        "expected optional term, found: ",+                        (ShowCore.term optionalTerm)])))+          decodeMaybe =+                  \maybeElementCoder -> \yamlVal -> case yamlVal of+                    YamlModel.NodeScalar v0 -> case v0 of+                      YamlModel.ScalarNull -> Right (Core.TermOptional Nothing)+                      _ -> Eithers.bind (Coders.coderDecode maybeElementCoder yamlVal) (\decodedInner -> Right (Core.TermOptional (Just decodedInner)))+                    _ -> Eithers.bind (Coders.coderDecode maybeElementCoder yamlVal) (\decodedInner -> Right (Core.TermOptional (Just decodedInner)))+          result =+                  case stripped of+                    Core.TypeLiteral v0 -> Eithers.bind (literalYamlCoder v0) (\ac -> Right (Coders.Coder {+                      Coders.coderEncode = (encodeLiteral ac),+                      Coders.coderDecode = (\n -> case n of+                        YamlModel.NodeScalar v1 -> Eithers.bind (Coders.coderDecode ac v1) (\lit -> Right (Core.TermLiteral lit))+                        _ -> Left (Errors.ErrorOther (Errors.OtherError "expected scalar node")))}))+                    Core.TypeList v0 -> Eithers.bind (termCoder v0 cx g) (\lc -> Right (Coders.Coder {+                      Coders.coderEncode = (encodeList lc),+                      Coders.coderDecode = (decodeList lc)}))+                    Core.TypeMap v0 ->+                      let kt = Core.mapTypeKeys v0+                          vt = Core.mapTypeValues v0+                      in (Eithers.bind (termCoder kt cx g) (\kc -> Eithers.bind (termCoder vt cx g) (\vc ->+                        let encodeEntry =+                                \kv ->+                                  let k = Pairs.first kv+                                      v = Pairs.second kv+                                  in (Eithers.bind (Coders.coderEncode kc k) (\encodedK -> Eithers.bind (Coders.coderEncode vc v) (\encodedV -> Right (encodedK, encodedV))))+                            decodeEntry =+                                    \kv ->+                                      let k = Pairs.first kv+                                          v = Pairs.second kv+                                      in (Eithers.bind (Coders.coderDecode kc k) (\decodedK -> Eithers.bind (Coders.coderDecode vc v) (\decodedV -> Right (decodedK, decodedV))))+                        in (Right (Coders.Coder {+                          Coders.coderEncode = (\term -> case term of+                            Core.TermMap v1 -> Eithers.bind (Eithers.mapList (\entry -> encodeEntry entry) (Maps.toList v1)) (\entries -> Right (YamlModel.NodeMapping (Maps.fromList entries)))+                            _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                              "expected map term, found: ",+                              (ShowCore.term term)])))),+                          Coders.coderDecode = (\n -> case n of+                            YamlModel.NodeMapping v1 -> Eithers.bind (Eithers.mapList (\entry -> decodeEntry entry) (Maps.toList v1)) (\entries -> Right (Core.TermMap (Maps.fromList entries)))+                            _ -> Left (Errors.ErrorOther (Errors.OtherError "expected mapping")))})))))+                    Core.TypeOptional v0 -> Eithers.bind (termCoder v0 cx g) (\maybeElementCoder -> Right (Coders.Coder {+                      Coders.coderEncode = (encodeMaybe maybeElementCoder),+                      Coders.coderDecode = (decodeMaybe maybeElementCoder)}))+                    Core.TypeRecord v0 -> recordCoder (Core.Name "yaml") v0 cx g+                    Core.TypeUnit -> Right unitCoder+                    _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+                      "unsupported type in YAML: ",+                      (ShowCore.type_ typ)])))+      in result+-- | YAML coder for unit values+unitCoder :: Coders.Coder Core.Term YamlModel.Node Errors.Error+unitCoder =+    Coders.Coder {+      Coders.coderEncode = encodeUnit,+      Coders.coderDecode = decodeUnit}+  where+    encodeUnit =+        \term -> case (Strip.deannotateTerm term) of+          Core.TermUnit -> Right (YamlModel.NodeScalar YamlModel.ScalarNull)+          _ -> Left (Errors.ErrorOther (Errors.OtherError (Strings.cat [+            "expected unit, found: ",+            (ShowCore.term term)])))+    decodeUnit =+        \n -> case n of+          YamlModel.NodeScalar v0 -> case v0 of+            YamlModel.ScalarNull -> Right Core.TermUnit+            _ -> Left (Errors.ErrorOther (Errors.OtherError "expected null scalar"))+          _ -> Left (Errors.ErrorOther (Errors.OtherError "expected null"))+-- | Create a YAML coder for a given type+yamlCoder :: Core.Type -> t0 -> Graph.Graph -> Either Errors.Error (Coders.Coder Core.Term YamlModel.Node Errors.Error)+yamlCoder typ cx g =++      let mkTermCoder = \t -> termCoder t cx g+      in (Eithers.bind (Adapt.simpleLanguageAdapter Language.yamlLanguage cx g typ) (\adapter -> Eithers.bind (mkTermCoder (Coders.adapterTarget adapter)) (\coder -> Right (Adapt.composeCoders (Coders.adapterCoder adapter) coder))))
+ src/main/haskell/Hydra/Yaml/Language.hs view
@@ -0,0 +1,76 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Language constraints for YAML++module Hydra.Yaml.Language where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as Model+import qualified Hydra.Overlay.Haskell.Lib.Sets as Sets+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Strip as Strip+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Language constraints for YAML+yamlLanguage :: Coders.Language+yamlLanguage =+    Coders.Language {+      Coders.languageName = (Coders.LanguageName "hydra.yaml"),+      Coders.languageConstraints = Coders.LanguageConstraints {+        Coders.languageConstraintsLiteralVariants = literalVariants,+        Coders.languageConstraintsFloatTypes = floatTypes,+        Coders.languageConstraintsIntegerTypes = integerTypes,+        Coders.languageConstraintsTermVariants = termVariants,+        Coders.languageConstraintsTypeVariants = typeVariants,+        Coders.languageConstraintsTypes = typePredicate}}+  where+    literalVariants =+        Sets.fromList [+          Variants.LiteralVariantBoolean,+          Variants.LiteralVariantFloat,+          Variants.LiteralVariantInteger,+          Variants.LiteralVariantString]+    floatTypes = Sets.fromList [+      Core.FloatTypeFloat64]+    integerTypes = Sets.fromList [+      Core.IntegerTypeBigint]+    termVariants =+        Sets.fromList [+          Variants.TermVariantLiteral,+          Variants.TermVariantList,+          Variants.TermVariantMap,+          Variants.TermVariantOptional,+          Variants.TermVariantRecord,+          Variants.TermVariantUnit]+    typeVariants =+        Sets.fromList [+          Variants.TypeVariantLiteral,+          Variants.TypeVariantList,+          Variants.TypeVariantMap,+          Variants.TypeVariantOptional,+          Variants.TypeVariantRecord,+          Variants.TypeVariantUnit,+          Variants.TypeVariantVoid]+    typePredicate =+        \typ -> case (Strip.deannotateType typ) of+          Core.TypeOptional v0 -> case v0 of+            Core.TypeOptional _ -> False+            _ -> True+          _ -> True
+ src/main/haskell/Hydra/Yaml/Serde.hs view
@@ -0,0 +1,236 @@+-- Note: this is an automatically generated file. Do not edit.+-- | Native YAML serialization: YAML Node to String++module Hydra.Yaml.Serde where+import qualified Hydra.Ast as Ast+import qualified Hydra.Coders as Coders+import qualified Hydra.Core as Core+import qualified Hydra.Error.Checking as Checking+import qualified Hydra.Error.Core as ErrorCore+import qualified Hydra.Error.Packaging as ErrorPackaging+import qualified Hydra.Errors as Errors+import qualified Hydra.Graph as Graph+import qualified Hydra.Json.Model as JsonModel+import qualified Hydra.Overlay.Haskell.Lib.Chars as Chars+import qualified Hydra.Overlay.Haskell.Lib.Equality as Equality+import qualified Hydra.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Overlay.Haskell.Lib.Literals as Literals+import qualified Hydra.Overlay.Haskell.Lib.Logic as Logic+import qualified Hydra.Overlay.Haskell.Lib.Maps as Maps+import qualified Hydra.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Overlay.Haskell.Lib.Pairs as Pairs+import qualified Hydra.Overlay.Haskell.Lib.Strings as Strings+import qualified Hydra.Packaging as Packaging+import qualified Hydra.Parsing as Parsing+import qualified Hydra.Paths as Paths+import qualified Hydra.Query as Query+import qualified Hydra.Relational as Relational+import qualified Hydra.Tabular as Tabular+import qualified Hydra.Testing as Testing+import qualified Hydra.Topology as Topology+import qualified Hydra.Typed as Typed+import qualified Hydra.Typing as Typing+import qualified Hydra.Util as Util+import qualified Hydra.Validation as Validation+import qualified Hydra.Variants as Variants+import qualified Hydra.Yaml.Model as YamlModel+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)+import qualified Data.Scientific as Sci+-- | Escape single quotes by doubling them+escapeSingleQuotes :: String -> String+escapeSingleQuotes s =++      let squote = 39+      in (Strings.fromList (Lists.bind (Strings.toList s) (\c -> Logic.ifElse (Equality.equal c squote) [+        squote,+        squote] [+        c])))+-- | Check if a string has leading or trailing whitespace+hasLeadingTrailingSpace :: String -> Bool+hasLeadingTrailingSpace s =++      let chars = Strings.toList s+      in (Logic.or (Optionals.fromOptional False (Optionals.map (\c -> Chars.isSpace c) (Lists.maybeHead chars))) (Optionals.fromOptional False (Optionals.map (\c -> Chars.isSpace c) (Lists.maybeLast chars))))+-- | Serialize a YAML node to a string+hydraYamlToString :: YamlModel.Node -> String+hydraYamlToString node = writeNode node+-- | Indent all lines of a string by 2 spaces+indentString :: String -> String+indentString s =+    Strings.cat (Lists.map (\line -> Logic.ifElse (Strings.null line) "" (Strings.cat [+      "  ",+      line,+      "\n"])) (Strings.lines s))+-- | Check if character codes represent a decimal number+isDecimalString :: [Int] -> Bool+isDecimalString chars =++      let dotCode = 46+          parts = Lists.span (\c -> Logic.not (Equality.equal c dotCode)) chars+          before = Pairs.first parts+          afterWithDot = Pairs.second parts+      in (Logic.ifElse (Lists.null before) False (Logic.ifElse (Lists.null afterWithDot) False (+        let after = Lists.drop 1 afterWithDot+        in (Logic.ifElse (Lists.null after) False (+          let isDigitFn = \c -> Logic.and (Equality.gte c 48) (Equality.lte c 57)+          in (Logic.and (Lists.null (Lists.filter (\c -> Logic.not (isDigitFn c)) before)) (Lists.null (Lists.filter (\c -> Logic.not (isDigitFn c)) after))))))))+-- | Check if a string looks like a number+looksLikeNumber :: String -> Bool+looksLikeNumber s =++      let chars = Strings.toList s+      in (Optionals.fromOptional False (Optionals.map (\p ->+        let firstCh = Pairs.first p+            tailCh = Pairs.second p+            rest = Logic.ifElse (Equality.equal firstCh 45) tailCh chars+            isDigitFn = \c -> Logic.and (Equality.gte c 48) (Equality.lte c 57)+            allDigits = Logic.and (Logic.not (Lists.null rest)) (Lists.null (Lists.filter (\c -> Logic.not (isDigitFn c)) rest))+        in (Logic.ifElse allDigits True (isDecimalString rest))) (Lists.uncons chars)))+-- | Check if a string needs quoting in YAML+needsQuoting :: String -> Bool+needsQuoting s =+    Logic.ifElse (Strings.null s) True (Logic.ifElse (Lists.elem s yamlReservedWords) True (Logic.ifElse (looksLikeNumber s) True (+      let chars = Strings.toList s+          specials = Strings.toList yamlSpecialChars+          hasSpecial = Logic.not (Lists.null (Lists.filter (\c -> Lists.elem c specials) chars))+      in (Logic.ifElse hasSpecial True (hasLeadingTrailingSpace s)))))+-- | Write a mapping entry in block style+writeMappingEntry :: (YamlModel.Node, YamlModel.Node) -> String+writeMappingEntry entry =++      let key = Pairs.first entry+          value = Pairs.second entry+      in case value of+        YamlModel.NodeScalar v0 -> Strings.cat [+          writeNodeInline key,+          ": ",+          (writeScalar v0),+          "\n"]+        YamlModel.NodeSequence v0 -> Logic.ifElse (Lists.null v0) (Strings.cat [+          writeNodeInline key,+          ": []\n"]) (Strings.cat [+          writeNodeInline key,+          ":\n",+          (indentString (writeNode value))])+        YamlModel.NodeMapping v0 -> Logic.ifElse (Equality.equal (Maps.size v0) 0) (Strings.cat [+          writeNodeInline key,+          ": {}\n"]) (Strings.cat [+          writeNodeInline key,+          ":\n",+          (indentString (writeNode value))])+-- | Write a mapping entry for the first item of a sequence element+writeMappingEntryInline :: (YamlModel.Node, YamlModel.Node) -> String+writeMappingEntryInline entry =++      let key = Pairs.first entry+          value = Pairs.second entry+      in case value of+        YamlModel.NodeScalar v0 -> Strings.cat [+          writeNodeInline key,+          ": ",+          (writeScalar v0),+          "\n"]+        YamlModel.NodeSequence v0 -> Logic.ifElse (Lists.null v0) (Strings.cat [+          writeNodeInline key,+          ": []\n"]) (Strings.cat [+          writeNodeInline key,+          ":\n",+          (indentString (writeNode value))])+        YamlModel.NodeMapping v0 -> Logic.ifElse (Equality.equal (Maps.size v0) 0) (Strings.cat [+          writeNodeInline key,+          ": {}\n"]) (Strings.cat [+          writeNodeInline key,+          ":\n",+          (indentString (writeNode value))])+-- | Write a YAML node as a top-level value in block style+writeNode :: YamlModel.Node -> String+writeNode node =+    case node of+      YamlModel.NodeScalar v0 -> Strings.cat2 (writeScalar v0) "\n"+      YamlModel.NodeSequence v0 -> Logic.ifElse (Lists.null v0) "[]\n" (Strings.cat (Lists.map (\item -> writeSequenceItem item) v0))+      YamlModel.NodeMapping v0 -> Logic.ifElse (Equality.equal (Maps.size v0) 0) "{}\n" (Strings.cat (Lists.map (\e -> writeMappingEntry e) (Maps.toList v0)))+-- | Write a node inline (for use as a mapping key)+writeNodeInline :: YamlModel.Node -> String+writeNodeInline node =+    case node of+      YamlModel.NodeScalar v0 -> writeScalar v0+      YamlModel.NodeSequence v0 -> Strings.cat [+        "[",+        (Strings.intercalate ", " (Lists.map (\item -> writeNodeInline item) v0)),+        "]"]+      YamlModel.NodeMapping v0 ->+        let writeFlowEntry =+                \e -> Strings.cat [+                  writeNodeInline (Pairs.first e),+                  ": ",+                  (writeNodeInline (Pairs.second e))]+        in (Strings.cat [+          "{",+          (Strings.intercalate ", " (Lists.map writeFlowEntry (Maps.toList v0))),+          "}"])+-- | Write a scalar value+writeScalar :: YamlModel.Scalar -> String+writeScalar s =+    case s of+      YamlModel.ScalarBool v0 -> Logic.ifElse v0 "true" "false"+      YamlModel.ScalarDecimal v0 -> Literals.showDecimal v0+      YamlModel.ScalarFloat v0 -> Literals.showFloat64 v0+      YamlModel.ScalarInt v0 -> Literals.showBigint v0+      YamlModel.ScalarNull -> "null"+      YamlModel.ScalarStr v0 -> writeString v0+-- | Write a sequence item in block style+writeSequenceItem :: YamlModel.Node -> String+writeSequenceItem node =+    case node of+      YamlModel.NodeScalar v0 -> Strings.cat [+        "- ",+        (writeScalar v0),+        "\n"]+      YamlModel.NodeSequence v0 -> Logic.ifElse (Lists.null v0) "- []\n" (Strings.cat2 "-\n" (indentString (writeNode node)))+      YamlModel.NodeMapping v0 -> Logic.ifElse (Equality.equal (Maps.size v0) 0) "- {}\n" (+        let entries = Maps.toList v0+        in (Optionals.fromOptional "" (Optionals.map (\p ->+          let firstEntry = Pairs.first p+              restEntries = Pairs.second p+              firstStr = writeMappingEntryInline firstEntry+              restStr = Strings.cat (Lists.map (\e -> writeMappingEntry e) restEntries)+          in (Strings.cat [+            "- ",+            firstStr,+            (indentString restStr)])) (Lists.uncons entries))))+-- | Write a string value, quoting if necessary+writeString :: String -> String+writeString s =+    Logic.ifElse (needsQuoting s) (Strings.cat [+      "'",+      (escapeSingleQuotes s),+      "'"]) s+-- | YAML reserved words that need quoting+yamlReservedWords :: [String]+yamlReservedWords =+    [+      "true",+      "false",+      "null",+      "~",+      "yes",+      "no",+      "on",+      "off",+      "True",+      "False",+      "Null",+      "Yes",+      "No",+      "On",+      "Off",+      "TRUE",+      "FALSE",+      "NULL",+      "YES",+      "NO",+      "ON",+      "OFF"]+-- | YAML special characters that trigger quoting+yamlSpecialChars :: String+yamlSpecialChars = ": {}[]#,&*!|>'\"%@`"