hydra-typescript 0.17.1 → 0.17.2
raw patch · 8 files changed
+1977/−2466 lines, 8 filesdep ~hydra-kernelPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hydra-kernel
API changes (from Hackage documentation)
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: addExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: andExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: anyType :: TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: arrayExpr :: [Expression] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: arrayPattern :: [Maybe Pattern] -> Pattern
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: arrayType :: TypeExpression -> TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: arrowBlockExpr :: [String] -> [Statement] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: arrowExpr :: [String] -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: assignExpr :: Pattern -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: asyncArrowExpr :: [String] -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: asyncFuncDecl :: String -> [String] -> [Statement] -> FunctionDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: awaitExpr :: Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: bigIntLit :: Integer -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: binaryExpr :: BinaryOperator -> Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: blockComment :: String -> Comment
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: blockStmt :: [Statement] -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: boolExpr :: Bool -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: boolLit :: Bool -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: breakStmt :: Maybe String -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: callExpr :: Expression -> [Expression] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: catchClause :: Maybe Pattern -> [Statement] -> CatchClause
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: classDecl :: String -> Maybe Expression -> [MethodDefinition] -> ClassDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: classDeclStmt :: ClassDeclaration -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: computedMemberExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: condExpr :: Expression -> Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: constDecl :: String -> Maybe Expression -> VariableDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: constructorDef :: [String] -> [Statement] -> MethodDefinition
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: continueStmt :: Maybe String -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: debuggerStmt :: Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: defaultExportDecl :: Expression -> ExportDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: defaultPattern :: String -> Expression -> Pattern
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: divExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: docComment :: String -> [DocumentationTag] -> Comment
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: emptyStmt :: Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: eqExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: exportDeclStmt :: Statement -> ExportDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: exportItem :: ExportDeclaration -> ModuleItem
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: exprStmt :: Expression -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: floatExpr :: Double -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: floatLit :: Double -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: forOfStmt :: Bool -> ForInLeft -> Expression -> Statement -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: forStmt :: Maybe ForInit -> Maybe Expression -> Maybe Expression -> Statement -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: funcDecl :: String -> [String] -> [Statement] -> FunctionDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: funcDeclStmt :: FunctionDeclaration -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: ident :: String -> Identifier
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: identExpr :: String -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: identPattern :: String -> Pattern
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: identType :: String -> TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: ifStmt :: Expression -> Statement -> Maybe Statement -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: importDecl :: [ImportClause] -> String -> ImportDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: importDefault :: String -> ImportClause
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: importItem :: ImportDeclaration -> ModuleItem
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: importNamed :: String -> String -> ImportClause
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: importNamespace :: String -> ImportClause
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: intExpr :: Int64 -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: intLit :: Int64 -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: letDecl :: String -> Maybe Expression -> VariableDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: lineComment :: String -> Comment
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: litExpr :: Literal -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: memberExpr :: Expression -> String -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: methodDef :: String -> [String] -> [Statement] -> MethodDefinition
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: moduleProgram :: [ModuleItem] -> Program
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: mulExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: namedExportDecl :: [(String, String)] -> Maybe String -> ExportDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: negateExpr :: Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: neqExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: neverType :: TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: newExpr :: Expression -> [Expression] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: notExpr :: Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: nullExpr :: Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: nullLit :: Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: objectExpr :: [(String, Expression)] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: objectPattern :: [Pattern] -> Pattern
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: optionalCallExpr :: Expression -> [Expression] -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: optionalMemberExpr :: Expression -> String -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: optionalType :: TypeExpression -> TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: orExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: paramTag :: String -> Maybe TypeExpression -> String -> DocumentationTag
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: paramType :: TypeExpression -> [TypeExpression] -> TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: parenExpr :: Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: qualifiedName :: [String] -> QualifiedName
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: restPattern :: String -> Pattern
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: returnStmt :: Maybe Expression -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: returnsTag :: Maybe TypeExpression -> String -> DocumentationTag
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: scriptProgram :: [ModuleItem] -> Program
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: spreadExpr :: Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: staticMethodDef :: String -> [String] -> [Statement] -> MethodDefinition
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: stmtItem :: Statement -> ModuleItem
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: stringExpr :: String -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: stringLit :: String -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: stringLitSingle :: String -> Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: subExpr :: Expression -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: switchCase :: Maybe Expression -> [Statement] -> SwitchCase
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: switchStmt :: Expression -> [SwitchCase] -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: thisExpr :: Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: throwStmt :: Expression -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: tryStmt :: [Statement] -> Maybe CatchClause -> Maybe [Statement] -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: typeTag :: TypeExpression -> DocumentationTag
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: unaryExpr :: UnaryOperator -> Expression -> Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: undefinedExpr :: Expression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: undefinedLit :: Literal
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: unionType :: [TypeExpression] -> TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: varDecl :: String -> Maybe Expression -> VariableDeclaration
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: varDeclStmt :: VariableDeclaration -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: voidType :: TypeExpression
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: whileStmt :: Expression -> Statement -> Statement
- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers: yieldExpr :: Maybe Expression -> Expression
+ Hydra.TypeScript.Coder: eagerFreeVariablesInTerm :: Term -> Set Name
Files
- CHANGELOG.md +173/−118
- hydra-typescript.cabal +3/−4
- src/main/haskell/Hydra/Overlay/Haskell/Dsl/TypeScript/Helpers.hs +0/−623
- src/main/haskell/Hydra/TypeScript/Coder.hs +78/−3
- src/main/haskell/Hydra/TypeScript/Language.hs +1/−0
- src/main/haskell/Hydra/TypeScript/Operators.hs +1/−0
- src/main/haskell/Hydra/TypeScript/Serde.hs +3/−0
- src/main/haskell/Hydra/TypeScript/Syntax.hs +1718/−1718
CHANGELOG.md view
@@ -15,142 +15,197 @@ --- -## [0.17.1] - unreleased+## [0.17.2] - 2026-07-28 -Development version. Opens the 0.17.x line — the first release built entirely against-published 0.17.0 hosts (Hackage / PyPI / Maven Central), with the `hostOverrides` shims-that were needed while 0.16.1 lacked the effect type and I/O primitives removed.+Point release on the 0.17.x line. Themes: promotion of the generator's routing and manifest+logic into Hydra (`hydra.build.*`), per-package API-doc publishing across Java/Scala/Python,+constraint-polymorphic arithmetic, and new effectful stream/file primitives. Includes the base64+binary-literal rename `literals.binaryToString`/`stringToBinary` → `binaryToBase64`/`base64ToBinary`,+a step toward [#417](https://github.com/CategoricalData/hydra/issues/417) (which remains in progress). +### Highlights++- **Build system promoted into Hydra**: the three generator drivers now consume `hydra.build.routing`+ ([#560](https://github.com/CategoricalData/hydra/issues/560)) and `hydra.build.manifest`+ ([#607](https://github.com/CategoricalData/hydra/issues/607)), retiring the legacy static prefix+ tables; the cold-seeder oil-and-water violation is fixed+ ([#608](https://github.com/CategoricalData/hydra/issues/608)) and guarded+ ([#617](https://github.com/CategoricalData/hydra/issues/617)).+- **Per-package API docs** for all doc-bearing hosts: JavaDoc restructured with cross-links and a fixed+ tag→CI→Pages chain ([#616](https://github.com/CategoricalData/hydra/issues/616)), plus mirrored+ Scaladoc ([#619](https://github.com/CategoricalData/hydra/issues/619)) and Python API docs+ ([#620](https://github.com/CategoricalData/hydra/issues/620)).+- **Constraint-polymorphic arithmetic**: a `numeric` type class with enforcement and value-level dispatch+ ([#566](https://github.com/CategoricalData/hydra/issues/566)), reflected on the target hosts+ ([#618](https://github.com/CategoricalData/hydra/issues/618)).+ ### New features +- Standard-stream primitives: `stdin`/`stdout`/`stderr` ([#526](https://github.com/CategoricalData/hydra/issues/526)).+- Recursive flag for `hydra.lib.files.listDirectory` ([#527](https://github.com/CategoricalData/hydra/issues/527)).+- Hydra-specific regex syntax with per-target translation (`hydra.read.regex` / `hydra.show.regex`)+ ([#567](https://github.com/CategoricalData/hydra/issues/567)).+- Constraint-polymorphic arithmetic: `numeric` type class + value-level dispatch+ ([#566](https://github.com/CategoricalData/hydra/issues/566)).+- Aggregated Java + Scala Maven publishing into a single Central Portal deployment+ ([#591](https://github.com/CategoricalData/hydra/issues/591)).++### Improvements++- Generator drivers consume `hydra.build.routing` ([#560](https://github.com/CategoricalData/hydra/issues/560))+ and `hydra.build.manifest` ([#607](https://github.com/CategoricalData/hydra/issues/607)).+- Fixed the cold-seeder oil-and-water violation ([#608](https://github.com/CategoricalData/hydra/issues/608))+ and extended `check-oil-and-water.py` to catch cold-seeder imports of unpublished `Hydra.Build.*`+ ([#617](https://github.com/CategoricalData/hydra/issues/617)).+- Moved non-kernel packages to strict validation, clearing the #575 backlog+ ([#580](https://github.com/CategoricalData/hydra/issues/580)).+- Decoupled `Hydra.Sources.Test.All` from `Hydra.Sources.All`'s re-export list+ ([#601](https://github.com/CategoricalData/hydra/issues/601)).+- Renamed `hydra.json.schema` to resolve the module-vs-namespace-prefix conflict that broke+ file-per-module hosts ([#532](https://github.com/CategoricalData/hydra/issues/532)).+- Coders route `hydra.lib.*` overlay imports by overlay-module existence, not name-matching+ `hydra.lib.defaults` ([#568](https://github.com/CategoricalData/hydra/issues/568)).+- Per-package JavaDoc/Scaladoc/Python-doc publishing+ ([#616](https://github.com/CategoricalData/hydra/issues/616),+ [#619](https://github.com/CategoricalData/hydra/issues/619),+ [#620](https://github.com/CategoricalData/hydra/issues/620)).+- Aligned Java-host Scala/TypeScript generation with Haskell on expression layout (line-wrapping,+ declaration order) ([#612](https://github.com/CategoricalData/hydra/issues/612)).++### Bug fixes++- **TypeScript** — added the missing CI job (zero prior coverage)+ ([#571](https://github.com/CategoricalData/hydra/issues/571)); fixed the+ `verify-distribution.sh` smoke-test import so the gate actually gates+ ([#578](https://github.com/CategoricalData/hydra/issues/578)); emit `hydra.parse.regex`'s+ `regexSequence` before its alternation use (TS2448)+ ([#604](https://github.com/CategoricalData/hydra/issues/604)).+- **Build and sync** — `sync.sh` Phase 3 digest-cache now sees cross-package deps on moved kernel+ symbols, fixing stale downstream output ([#606](https://github.com/CategoricalData/hydra/issues/606)).+- **Numeric constraints** — `#566` polymorphism now reflected on the target hosts (targets were+ monomorphizing `int32->int32->int32`) ([#618](https://github.com/CategoricalData/hydra/issues/618)).++---++## [0.17.1] - 2026-07-18++Consolidation release on the 0.17.x line, built against published 0.17.0 hosts. Themes:+generated term-reference DSLs, a translingual package-validation framework, promotion of the+build system into Hydra (`hydra-build`), and broad TypeScript-host and cross-host hardening.++### Highlights+ - **Generated term-reference DSLs** ([#467](https://github.com/CategoricalData/hydra/issues/467)):- kernel *term* modules now project generated DSL surfaces, completing the story begun with- type-module DSLs and the generated primitive wrappers (`hydra.dsl.lib.*`, 0.17.0). A- signature read-back in the DSL pass reuses the main pass's inference, and a demand-curated- set of 19 kernel term modules (plus the json/test/extract modules) emits one typed,- rename-safe reference per definition into every target language — e.g. Haskell- `Hydra.Dsl.Strip.deannotateType`, Java `hydra.dsl.Strip.deannotateType(...)`, Python- `hydra.dsl.strip.deannotate_type(...)`. The Java and Python coder sources were pivoted onto- the generated references, retiring ~700 stringly-typed inline `var("hydra....")` references- and shrinking Python's hand registry to the non-generatable remainder (byte-identical- generated output before and after). Follow-ups:- [#555](https://github.com/CategoricalData/hydra/issues/555) (typed references to derived- encode/decode/show functions via `TypedName`),- [#556](https://github.com/CategoricalData/hydra/issues/556) (non-kernel packages).+ kernel term modules now emit one typed, rename-safe reference per definition into every target+ language; the Java and Python coder sources were pivoted onto them, retiring ~700 stringly-typed+ inline references. - **Package validation** ([#574](https://github.com/CategoricalData/hydra/issues/574), [#575](https://github.com/CategoricalData/hydra/issues/575)): a translingual `hydra.validate.*`- framework carries per-package `ValidationProfile`s (error/warning rules, error/warning caps) and a- catalog of checks — undeclared-package-dependency detection (now a fatal gate, #574),- definition-name convention (PascalCase), definition ordering, documentation completeness, and- conflicting-variant-name detection — layered on the existing core term/type well-formedness rules.- A kernel-strict / others-relaxed policy keeps `/sync` green fleet-wide while the documentation- backlog drains. See the new [Validation](https://github.com/CategoricalData/hydra/wiki/Validation)- wiki page for the full per-package constraint specification.-- **DSL-authoring registration guards** ([#554](https://github.com/CategoricalData/hydra/issues/554)):- fail-fast authoring-time validation for the host-native DSL sources — every DSL-authoring module in- Java/`hydra-jvm`, Python, and Scala now asserts its definitions are fully registered- (`Defs.checkComplete` / `check_complete`), backed by a Haskell kernel-source registration-completeness- scanner, so a definition added to a source file but omitted from its `definitions` list fails loudly- instead of silently vanishing from the generated output.-- **`hydra-build` package** ([#546](https://github.com/CategoricalData/hydra/issues/546),- [#529](https://github.com/CategoricalData/hydra/issues/529),- [#530](https://github.com/CategoricalData/hydra/issues/530)): the build-orchestration logic that had- lived only in host scripts is now translingual Hydra. Pure module-list utilities became- `hydra.build.modules` (#529) and the orphan-reconcile decision became `hydra.build.reconcile` (#530),- each with a translingual test suite; the `hydra.build.*` modules were then extracted into a dedicated- `hydra-build` package (#546), separate from the kernel.-- **Metadata sidecar + content/version-addressed freshness**- ([#415](https://github.com/CategoricalData/hydra/issues/415)): dist manifests now carry a- `moduleFormatVersion` field, and the generator's freshness basis is content/version-addressed — the- groundwork for reproducible, cache-correct incremental generation.-- **Structured generation-provenance record**- ([#523](https://github.com/CategoricalData/hydra/issues/523)): each generation run now records a- structured `Generation` provenance entry (digest v2), replacing the ad-hoc shell threading of- generation metadata.-- **Worker + issue hierarchy** ([#557](https://github.com/CategoricalData/hydra/issues/557)): a- principled agent/worker framework — roles and parentage mirroring the GitHub issue tree, a- cross-worktree message transport with a verify-after-copy protocol, a blocking-aware design-question- (`decisions/`) channel, an issue-proposal queue with the `/issues` command, an autonomy-dial banner,- and cross-machine staging coordination. Contributor-facing process only; no change to generated code.+ framework with per-package `ValidationProfile`s (undeclared-dependency gate, naming/ordering/docs+ checks). See the [Validation](https://github.com/CategoricalData/hydra/wiki/Validation) wiki page.+- **`hydra-build` package** ([#546](https://github.com/CategoricalData/hydra/issues/546)):+ build-orchestration logic that lived only in host scripts is now translingual Hydra+ (`hydra.build.*`), extracted into a dedicated package. -### API and usability+### New features -- **DSL usability passes** ([#430](https://github.com/CategoricalData/hydra/issues/430),- [#553](https://github.com/CategoricalData/hydra/issues/553)): reviewed the host-native Java, Python,- and Scala DSL surfaces for ergonomics and cross-host parity (documented def shapes, added a Scala- projection helper), bringing the three authoring dialects into closer alignment.+- Generated term-reference DSLs ([#467](https://github.com/CategoricalData/hydra/issues/467));+ follow-ups: `TypedName` refs to derived encode/decode/show+ ([#555](https://github.com/CategoricalData/hydra/issues/555)), non-kernel packages+ ([#556](https://github.com/CategoricalData/hydra/issues/556)).+- Translingual package-validation framework ([#574](https://github.com/CategoricalData/hydra/issues/574),+ [#575](https://github.com/CategoricalData/hydra/issues/575)).+- DSL-authoring registration guards: fail-fast completeness checks for the Java/Python/Scala DSL sources+ ([#554](https://github.com/CategoricalData/hydra/issues/554)).+- `hydra-build` package: `hydra.build.modules`+ ([#529](https://github.com/CategoricalData/hydra/issues/529)), `hydra.build.reconcile`+ ([#530](https://github.com/CategoricalData/hydra/issues/530)), extracted from the kernel+ ([#546](https://github.com/CategoricalData/hydra/issues/546)).+- Effectful `hydra.lib.system` primitive library ([#498](https://github.com/CategoricalData/hydra/issues/498)).+- SHA-256 cryptographic hash primitive in `hydra.lib` ([#524](https://github.com/CategoricalData/hydra/issues/524)).+- `hydra-jvm` package: shared JVM serde helpers relocated out of `hydra.java.serde`+ ([#505](https://github.com/CategoricalData/hydra/issues/505)).+- Internalized the Hydra-TinkerPop bindings (formerly HydraPop)+ ([#442](https://github.com/CategoricalData/hydra/issues/442)).+- Compact unit-valued variants in the JSON encoding ([#520](https://github.com/CategoricalData/hydra/issues/520)).+- Structured generation-provenance record (digest v2) ([#413](https://github.com/CategoricalData/hydra/issues/413),+ [#523](https://github.com/CategoricalData/hydra/issues/523)).+- Metadata sidecar + content/version-addressed freshness (`moduleFormatVersion`)+ ([#415](https://github.com/CategoricalData/hydra/issues/415)).+- Worker + issue hierarchy: agent/worker framework, cross-worktree messaging, issue-proposal queue+ (contributor process only) ([#557](https://github.com/CategoricalData/hydra/issues/557)). -### Fixed+### Improvements -Bug fixes landed this cycle, grouped by area (see each issue for detail):+- Type inference for annotations ([#229](https://github.com/CategoricalData/hydra/issues/229)).+- Fixed the signature / definition split in primitive definitions+ ([#502](https://github.com/CategoricalData/hydra/issues/502)).+- DSL usability passes across the host-native Java/Python/Scala surfaces+ ([#430](https://github.com/CategoricalData/hydra/issues/430),+ [#553](https://github.com/CategoricalData/hydra/issues/553)).+- Audited the Scala and Lisp-family coders for the unconditional `hydra.lib.*` overlay-import rewrite+ ([#569](https://github.com/CategoricalData/hydra/issues/569)). -- **TypeScript** — reactivated `hydra.lib.*` primitive tests surfaced encoder gaps: lazy show-calling- let bindings and compact bare-string `LiteralType` expansion in the test converter- ([#564](https://github.com/CategoricalData/hydra/issues/564)),- `binaryToBytes` registration + base64 binary decode in `decodeUtf8`- ([#561](https://github.com/CategoricalData/hydra/issues/561)),+### Bug fixes++- **TypeScript host** — V8 stack budget on ts→Java ([#390](https://github.com/CategoricalData/hydra/issues/390));+ effectful libs not generated / 484 tsc errors ([#503](https://github.com/CategoricalData/hydra/issues/503));+ 15 effect/file inference cases ([#504](https://github.com/CategoricalData/hydra/issues/504));+ ts→ts self-host regression ([#507](https://github.com/CategoricalData/hydra/issues/507)); npm packages+ bundling a duplicate kernel ([#584](https://github.com/CategoricalData/hydra/issues/584)); broken npm+ entry points ([#587](https://github.com/CategoricalData/hydra/issues/587));+ `hydra.test.build.modules.allTests` gen-universe gap ([#588](https://github.com/CategoricalData/hydra/issues/588)).+- **TypeScript coder** — reactivated `hydra.lib.*` tests: lazy show-calling let bindings + compact+ `LiteralType` expansion ([#564](https://github.com/CategoricalData/hydra/issues/564)); `binaryToBytes`+ registration + base64 decode in `decodeUtf8` ([#561](https://github.com/CategoricalData/hydra/issues/561)); `hydra.test.build.*` emission after the #546 split- ([#570](https://github.com/CategoricalData/hydra/issues/570)), and `HYDRA_DEFAULT_IMPLS` support in- the test runner ([#536](https://github.com/CategoricalData/hydra/issues/536)).-- **Tests and CI** — restored the default-primitive-implementation testing solution- ([#388](https://github.com/CategoricalData/hydra/issues/388),- [#549](https://github.com/CategoricalData/hydra/issues/549)), reactivated previously-ignored kernel- test cases ([#513](https://github.com/CategoricalData/hydra/issues/513),- [#550](https://github.com/CategoricalData/hydra/issues/550)), wired the regression harnesses into CI- and split them out of the monolithic Haskell job for timeout headroom- ([#535](https://github.com/CategoricalData/hydra/issues/535),- [#563](https://github.com/CategoricalData/hydra/issues/563)), added Scala/Go/Lisp- self-containment gates to `verify-distribution.sh`- ([#537](https://github.com/CategoricalData/hydra/issues/537)), a manifest-JSON-tracked CI check- ([#541](https://github.com/CategoricalData/hydra/issues/541)), a per-package test-digest freshness- fix ([#551](https://github.com/CategoricalData/hydra/issues/551)), overlay-file restoration in- `test-stale-output-prune.sh` ([#558](https://github.com/CategoricalData/hydra/issues/558)), and a- sync-freshness fingerprint that now sees host-native DSL sources- ([#562](https://github.com/CategoricalData/hydra/issues/562)).+ ([#570](https://github.com/CategoricalData/hydra/issues/570)); `HYDRA_DEFAULT_IMPLS` in the test runner+ ([#536](https://github.com/CategoricalData/hydra/issues/536)); overlay-import rewrite no longer captures+ `hydra.lib.defaults` ([#565](https://github.com/CategoricalData/hydra/issues/565)).+- **Lisp family** — clj→clj bootstrap hang in `generate_source_files`+ ([#479](https://github.com/CategoricalData/hydra/issues/479)); Common Lisp `test_graph.lisp` loader+ forward-reference ([#496](https://github.com/CategoricalData/hydra/issues/496)); Scheme maps+ last-writer-wins in `union` ([#545](https://github.com/CategoricalData/hydra/issues/545)); Emacs Lisp+ bootstrap `wrong-type-argument (listp :string)` ([#586](https://github.com/CategoricalData/hydra/issues/586));+ `hydra.build.*` regeneration into the Lisp dialects ([#544](https://github.com/CategoricalData/hydra/issues/544)). - **Kernel and coders** — Java binary-literal signed-byte emission- ([#528](https://github.com/CategoricalData/hydra/issues/528)), `hydra.json.Decode.fromJson`- parametric-type (Application/Forall) support- ([#531](https://github.com/CategoricalData/hydra/issues/531)), stale 2-param `Coder` shape in- Java/Scala test bootstrap ([#552](https://github.com/CategoricalData/hydra/issues/552)), and a- kernel dead-code/TODO cleanup ([#538](https://github.com/CategoricalData/hydra/issues/538)).+ ([#528](https://github.com/CategoricalData/hydra/issues/528)); `hydra.json.Decode.fromJson`+ parametric-type support ([#531](https://github.com/CategoricalData/hydra/issues/531)); stale 2-param+ `Coder` shape in Java/Scala test bootstrap ([#552](https://github.com/CategoricalData/hydra/issues/552));+ Java Javadoc ampersand escaping ([#493](https://github.com/CategoricalData/hydra/issues/493)); Scala+ coder over-generalizing `Schema[S,T,V,E]` args, breaking `hydra-pg`+ ([#589](https://github.com/CategoricalData/hydra/issues/589)); kernel dead-code/TODO cleanup+ ([#538](https://github.com/CategoricalData/hydra/issues/538)).+- **Publishing and packaging** — self-broken 0.16.0 `hydra-kernel`/`hydra-python` wheels+ ([#472](https://github.com/CategoricalData/hydra/issues/472)). - **Lib and build** — `hydra.lib.files` copy/removeDirectory/status overlays across all nine hosts- ([#525](https://github.com/CategoricalData/hydra/issues/525)), `hydra.build.*` regeneration into the- Lisp dialects ([#544](https://github.com/CategoricalData/hydra/issues/544)), Scheme maps- last-writer-wins in `union` ([#545](https://github.com/CategoricalData/hydra/issues/545)),- standalone-kernel SHA dependency ([#542](https://github.com/CategoricalData/hydra/issues/542)),- the lexicon's empty Types section ([#539](https://github.com/CategoricalData/hydra/issues/539)), and- a duplicated generated-file header in `generate-head-haskell-build.py`- ([#540](https://github.com/CategoricalData/hydra/issues/540)).--- **TypeScript overlay-import rewrite** ([#565](https://github.com/CategoricalData/hydra/issues/565)):- the TypeScript coder's lib overlay-import rewrite no longer captures `hydra.lib.defaults`, which is a- generated (not overlaid) module; excluding it fixes spurious import references in generated TypeScript.--- **Lexicon generation** (`bin/regenerate-lexicon.sh`): the generator had been failing- silently since the encoder/decoder modules moved to in-memory synthesis- ([#448](https://github.com/CategoricalData/hydra/issues/448)) — the script masked the- failure and left a stale `docs/hydra-lexicon.txt` missing the four effectful primitive- libraries (`hydra.lib.{effects,files,system,text}`). The synthesized coder modules are- now included in the lexicon universe, the script fails loudly, and the regenerated- lexicon covers all 267 primitives across 17 library modules.-- **`bin/prepare-release.sh`**: the non-blocking Java quality check invoked Gradle- subprojects (`:hydra-rdf4j:test` etc.) that were removed in- [#511](https://github.com/CategoricalData/hydra/issues/511), so it always warned without- checking anything; it now runs the `dist/java/hydra-pg` package tests (the current home- of the former binding tests).-- **`.gitignore`**: the ignore rules for the overlaid hand-written Haskell runtime still- named pre-[#501](https://github.com/CategoricalData/hydra/issues/501) paths, so 41- duplicate copies under `dist/haskell/` had become tracked; the rules now match the- `Hydra/Overlay/` location and the duplicates are untracked.+ ([#525](https://github.com/CategoricalData/hydra/issues/525)); standalone-kernel SHA dependency+ ([#542](https://github.com/CategoricalData/hydra/issues/542)); lexicon's empty Types section+ ([#539](https://github.com/CategoricalData/hydra/issues/539)); silent lexicon-generation failure since+ the coders moved to in-memory synthesis ([#448](https://github.com/CategoricalData/hydra/issues/448));+ duplicated generated-file header in `generate-head-haskell-build.py`+ ([#540](https://github.com/CategoricalData/hydra/issues/540)); `.gitignore` untracking 41 duplicate+ overlaid-runtime copies under `dist/haskell/` ([#501](https://github.com/CategoricalData/hydra/issues/501));+ `bin/prepare-release.sh` Java quality check repointed to `dist/java/hydra-pg` tests after+ ([#511](https://github.com/CategoricalData/hydra/issues/511)).+- **Tests and CI** — restored default-primitive-implementation testing+ ([#388](https://github.com/CategoricalData/hydra/issues/388),+ [#549](https://github.com/CategoricalData/hydra/issues/549)); reactivated ignored kernel test cases+ ([#513](https://github.com/CategoricalData/hydra/issues/513),+ [#550](https://github.com/CategoricalData/hydra/issues/550)); wired + split out the regression harnesses+ ([#535](https://github.com/CategoricalData/hydra/issues/535),+ [#563](https://github.com/CategoricalData/hydra/issues/563)); Scala/Go/Lisp self-containment gates+ ([#537](https://github.com/CategoricalData/hydra/issues/537)); manifest-JSON-tracked CI check+ ([#541](https://github.com/CategoricalData/hydra/issues/541)); per-package test-digest freshness+ ([#551](https://github.com/CategoricalData/hydra/issues/551)); overlay-file restoration in+ `test-stale-output-prune.sh` ([#558](https://github.com/CategoricalData/hydra/issues/558)); DSL-aware+ sync-freshness fingerprint ([#562](https://github.com/CategoricalData/hydra/issues/562)). ### Documentation -- Corrected the 0.17.0 Maven coordinates throughout (Java artifacts publish under group- `net.fortytwo.hydra.java`, Scala under `net.fortytwo.hydra.scala`,- [#519](https://github.com/CategoricalData/hydra/issues/519)); added the npm and Scala- release channels to the README; added TypeScript/Scala/Lisp sections to Getting started;- repointed stale pre-#418/#501 DSL paths in the architecture docs; added GitHub issue and- PR templates.+- Corrected 0.17.0 Maven coordinates and added npm/Scala release channels, TypeScript/Scala/Lisp+ Getting-started sections, and issue/PR templates+ ([#519](https://github.com/CategoricalData/hydra/issues/519)). ---
hydra-typescript.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.38.1.+-- This file has been generated from package.yaml by hpack version 0.39.1. -- -- see: https://github.com/sol/hpack name: hydra-typescript-version: 0.17.1+version: 0.17.2 synopsis: Hydra's TypeScript coder: emit TypeScript source from Hydra modules 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". TypeScript support for Hydra category: Data@@ -28,7 +28,6 @@ library exposed-modules: Hydra.Dsl.TypeScript.Syntax- Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers Hydra.TypeScript.Coder Hydra.TypeScript.Language Hydra.TypeScript.Operators@@ -41,6 +40,6 @@ build-depends: base >=4.19.0 && <4.22 , containers >=0.6.7 && <0.8- , hydra-kernel ==0.17.1+ , hydra-kernel ==0.17.2 , scientific >=0.3.7 && <0.4 default-language: Haskell2010
− src/main/haskell/Hydra/Overlay/Haskell/Dsl/TypeScript/Helpers.hs
@@ -1,623 +0,0 @@--- | A DSL for constructing TypeScript syntax trees in Haskell.-module Hydra.Overlay.Haskell.Dsl.TypeScript.Helpers where--import Hydra.TypeScript.Syntax-import qualified Data.Int as I----- * Identifiers---- | Create an identifier--- Example: ident "foo"-ident :: String -> Identifier-ident = Identifier---- | Create a qualified name from a list of strings--- Example: qualifiedName ["module", "submodule", "name"]-qualifiedName :: [String] -> QualifiedName-qualifiedName = fmap Identifier----- * Literals---- | Create a string literal with double quotes--- Example: stringLit "hello"-stringLit :: String -> Literal-stringLit s = LiteralString $ StringLiteral s False---- | Create a string literal with single quotes--- Example: stringLitSingle "hello"-stringLitSingle :: String -> Literal-stringLitSingle s = LiteralString $ StringLiteral s True---- | Create an integer literal--- Example: intLit 42-intLit :: I.Int64 -> Literal-intLit = LiteralNumber . NumericLiteralInteger---- | Create a floating-point literal--- Example: floatLit 3.14-floatLit :: Double -> Literal-floatLit = LiteralNumber . NumericLiteralFloat---- | Create a boolean literal--- Example: boolLit True-boolLit :: Bool -> Literal-boolLit = LiteralBoolean---- | The null literal-nullLit :: Literal-nullLit = LiteralNull---- | The undefined literal-undefinedLit :: Literal-undefinedLit = LiteralUndefined---- | Create a BigInt literal--- Example: bigIntLit 123-bigIntLit :: Integer -> Literal-bigIntLit = LiteralBigInt----- * Expressions---- | Create an identifier expression--- Example: identExpr "foo"-identExpr :: String -> Expression-identExpr = ExpressionIdentifier . ident---- | Create a literal expression--- Example: litExpr (stringLit "hello")-litExpr :: Literal -> Expression-litExpr = ExpressionLiteral---- | Create a string expression--- Example: stringExpr "hello"-stringExpr :: String -> Expression-stringExpr = litExpr . stringLit---- | Create an integer expression--- Example: intExpr 42-intExpr :: I.Int64 -> Expression-intExpr = litExpr . intLit---- | Create a floating-point expression--- Example: floatExpr 3.14-floatExpr :: Double -> Expression-floatExpr = litExpr . floatLit---- | Create a boolean expression--- Example: boolExpr True-boolExpr :: Bool -> Expression-boolExpr = litExpr . boolLit---- | The null expression-nullExpr :: Expression-nullExpr = litExpr nullLit---- | The undefined expression-undefinedExpr :: Expression-undefinedExpr = litExpr undefinedLit---- | Create an array expression--- Example: arrayExpr [intExpr 1, intExpr 2, intExpr 3]-arrayExpr :: [Expression] -> Expression-arrayExpr = ExpressionArray . fmap ArrayElementExpression---- | Create an object expression from key-value pairs--- Example: objectExpr [("name", stringExpr "John"), ("age", intExpr 30)]-objectExpr :: [(String, Expression)] -> Expression-objectExpr pairs = ExpressionObject $ fmap toProperty pairs- where- toProperty (k, v) = Property (identExpr k) v PropertyKindInit False False---- | Create a function call expression--- Example: callExpr (identExpr "foo") [intExpr 1, intExpr 2]-callExpr :: Expression -> [Expression] -> Expression-callExpr callee args = ExpressionCall $ CallExpression callee args False---- | Create an optional chaining call expression--- Example: optionalCallExpr (identExpr "foo") [intExpr 1]-optionalCallExpr :: Expression -> [Expression] -> Expression-optionalCallExpr callee args = ExpressionCall $ CallExpression callee args True---- | Create a member access expression (obj.prop)--- Example: memberExpr (identExpr "obj") "prop"-memberExpr :: Expression -> String -> Expression-memberExpr obj prop = ExpressionMember $ MemberExpression obj (identExpr prop) False False---- | Create a computed member access expression (obj[expr])--- Example: computedMemberExpr (identExpr "arr") (intExpr 0)-computedMemberExpr :: Expression -> Expression -> Expression-computedMemberExpr obj prop = ExpressionMember $ MemberExpression obj prop True False---- | Create an optional chaining member expression (obj?.prop)--- Example: optionalMemberExpr (identExpr "obj") "prop"-optionalMemberExpr :: Expression -> String -> Expression-optionalMemberExpr obj prop = ExpressionMember $ MemberExpression obj (identExpr prop) False True---- | Create a conditional (ternary) expression--- Example: condExpr (identExpr "x") (intExpr 1) (intExpr 0)-condExpr :: Expression -> Expression -> Expression -> Expression-condExpr test consequent alternate = ExpressionConditional $- ConditionalExpression test consequent alternate---- | Create a binary expression--- Example: binaryExpr BinaryOperatorAdd (intExpr 1) (intExpr 2)-binaryExpr :: BinaryOperator -> Expression -> Expression -> Expression-binaryExpr op left right = ExpressionBinary $ BinaryExpression op left right---- | Create an addition expression--- Example: addExpr (intExpr 1) (intExpr 2)-addExpr :: Expression -> Expression -> Expression-addExpr = binaryExpr BinaryOperatorAdd---- | Create a subtraction expression--- Example: subExpr (intExpr 5) (intExpr 3)-subExpr :: Expression -> Expression -> Expression-subExpr = binaryExpr BinaryOperatorSubtract---- | Create a multiplication expression--- Example: mulExpr (intExpr 3) (intExpr 4)-mulExpr :: Expression -> Expression -> Expression-mulExpr = binaryExpr BinaryOperatorMultiply---- | Create a division expression--- Example: divExpr (intExpr 10) (intExpr 2)-divExpr :: Expression -> Expression -> Expression-divExpr = binaryExpr BinaryOperatorDivide---- | Create a strict equality expression (===)--- Example: eqExpr (identExpr "x") (intExpr 1)-eqExpr :: Expression -> Expression -> Expression-eqExpr = binaryExpr BinaryOperatorStrictEqual---- | Create a strict inequality expression (!==)--- Example: neqExpr (identExpr "x") (intExpr 1)-neqExpr :: Expression -> Expression -> Expression-neqExpr = binaryExpr BinaryOperatorStrictNotEqual---- | Create a logical AND expression--- Example: andExpr (identExpr "a") (identExpr "b")-andExpr :: Expression -> Expression -> Expression-andExpr = binaryExpr BinaryOperatorAnd---- | Create a logical OR expression--- Example: orExpr (identExpr "a") (identExpr "b")-orExpr :: Expression -> Expression -> Expression-orExpr = binaryExpr BinaryOperatorOr---- | Create a unary expression--- Example: unaryExpr UnaryOperatorNot (identExpr "x")-unaryExpr :: UnaryOperator -> Expression -> Expression-unaryExpr op arg = ExpressionUnary $ UnaryExpression op arg True---- | Create a logical NOT expression--- Example: notExpr (identExpr "x")-notExpr :: Expression -> Expression-notExpr = unaryExpr UnaryOperatorNot---- | Create a negation expression--- Example: negateExpr (identExpr "x")-negateExpr :: Expression -> Expression-negateExpr = unaryExpr UnaryOperatorNegate---- | Create an assignment expression--- Example: assignExpr (identPattern "x") (intExpr 42)-assignExpr :: Pattern -> Expression -> Expression-assignExpr left right = ExpressionAssignment $- AssignmentExpression AssignmentOperatorAssign left right---- | The 'this' expression-thisExpr :: Expression-thisExpr = ExpressionThis---- | Create a 'new' expression--- Example: newExpr (identExpr "Date") []-newExpr :: Expression -> [Expression] -> Expression-newExpr callee args = ExpressionNew $ CallExpression callee args False---- | Create an await expression--- Example: awaitExpr (callExpr (identExpr "fetch") [stringExpr "url"])-awaitExpr :: Expression -> Expression-awaitExpr = ExpressionAwait---- | Create a yield expression--- Example: yieldExpr (Just (intExpr 1))-yieldExpr :: Maybe Expression -> Expression-yieldExpr = ExpressionYield---- | Create a spread expression--- Example: spreadExpr (identExpr "arr")-spreadExpr :: Expression -> Expression-spreadExpr = ExpressionSpread . SpreadElement---- | Create a parenthesized expression--- Example: parenExpr (addExpr (intExpr 1) (intExpr 2))-parenExpr :: Expression -> Expression-parenExpr = ExpressionParenthesized----- * Arrow Functions---- | Create an arrow function with an expression body--- Example: arrowExpr ["x", "y"] (addExpr (identExpr "x") (identExpr "y"))-arrowExpr :: [String] -> Expression -> Expression-arrowExpr params body = ExpressionArrow $ ArrowFunctionExpression- (fmap identPattern params)- (ArrowFunctionBodyExpression body)- False---- | Create an async arrow function with an expression body--- Example: asyncArrowExpr ["x"] (awaitExpr (callExpr (identExpr "fetch") [identExpr "x"]))-asyncArrowExpr :: [String] -> Expression -> Expression-asyncArrowExpr params body = ExpressionArrow $ ArrowFunctionExpression- (fmap identPattern params)- (ArrowFunctionBodyExpression body)- True---- | Create an arrow function with a block body--- Example: arrowBlockExpr ["x"] [returnStmt (Just (identExpr "x"))]-arrowBlockExpr :: [String] -> [Statement] -> Expression-arrowBlockExpr params body = ExpressionArrow $ ArrowFunctionExpression- (fmap identPattern params)- (ArrowFunctionBodyBlock body)- False----- * Patterns---- | Create an identifier pattern--- Example: identPattern "x"-identPattern :: String -> Pattern-identPattern = PatternIdentifier . ident---- | Create an object destructuring pattern--- Example: objectPattern [identPattern "a", identPattern "b"]-objectPattern :: [Pattern] -> Pattern-objectPattern ps = PatternObject $ ObjectPattern $ fmap toProperty ps- where- toProperty p = case p of- PatternIdentifier i -> ObjectPatternPropertyProperty $- Property (ExpressionIdentifier i) (ExpressionIdentifier i) PropertyKindInit False True- _ -> ObjectPatternPropertyProperty $- Property nullExpr (patternToExpr p) PropertyKindInit False False- patternToExpr (PatternIdentifier i) = ExpressionIdentifier i- patternToExpr _ = nullExpr---- | Create an array destructuring pattern--- Example: arrayPattern [Just (identPattern "a"), Nothing, Just (identPattern "b")]-arrayPattern :: [Maybe Pattern] -> Pattern-arrayPattern = PatternArray---- | Create a rest pattern--- Example: restPattern "args"-restPattern :: String -> Pattern-restPattern = PatternRest . RestElement . identPattern---- | Create a pattern with a default value--- Example: defaultPattern "x" (intExpr 0)-defaultPattern :: String -> Expression -> Pattern-defaultPattern name def = PatternAssignment $- AssignmentPattern (identPattern name) def----- * Statements---- | Create an expression statement--- Example: exprStmt (callExpr (identExpr "console.log") [stringExpr "hello"])-exprStmt :: Expression -> Statement-exprStmt = StatementExpression---- | Create a block statement--- Example: blockStmt [exprStmt (intExpr 1), exprStmt (intExpr 2)]-blockStmt :: [Statement] -> Statement-blockStmt = StatementBlock---- | Create a return statement--- Example: returnStmt (Just (intExpr 42))-returnStmt :: Maybe Expression -> Statement-returnStmt = StatementReturn---- | Create a throw statement--- Example: throwStmt (newExpr (identExpr "Error") [stringExpr "oops"])-throwStmt :: Expression -> Statement-throwStmt = StatementThrow . ThrowStatement---- | Create a break statement--- Example: breakStmt Nothing-breakStmt :: Maybe String -> Statement-breakStmt = StatementBreak . fmap ident---- | Create a continue statement--- Example: continueStmt Nothing-continueStmt :: Maybe String -> Statement-continueStmt = StatementContinue . fmap ident---- | Create an if statement--- Example: ifStmt (identExpr "x") (returnStmt (Just (intExpr 1))) Nothing-ifStmt :: Expression -> Statement -> Maybe Statement -> Statement-ifStmt test consequent alternate = StatementIf $ IfStatement test consequent alternate---- | Create a while statement--- Example: whileStmt (boolExpr True) (blockStmt [breakStmt Nothing])-whileStmt :: Expression -> Statement -> Statement-whileStmt test body = StatementWhile $ WhileStatement test body---- | Create a for statement--- Example: forStmt (Just (ForInitVariable (constDecl "i" (intExpr 0)))) (Just (binaryExpr BinaryOperatorLessThan (identExpr "i") (intExpr 10))) (Just (unaryExpr UnaryOperatorIncrement (identExpr "i"))) (blockStmt [])-forStmt :: Maybe ForInit -> Maybe Expression -> Maybe Expression -> Statement -> Statement-forStmt init test update body = StatementFor $ ForStatement init test update body---- | Create a for-of statement--- Example: forOfStmt False (ForInLeftVariable (constDecl "item" Nothing)) (identExpr "items") (blockStmt [])-forOfStmt :: Bool -> ForInLeft -> Expression -> Statement -> Statement-forOfStmt await left right body = StatementForOf $ ForOfStatement await left right body---- | Create a try statement--- Example: tryStmt [exprStmt (callExpr (identExpr "riskyOp") [])] (Just (catchClause (Just (identPattern "e")) [throwStmt (identExpr "e")])) Nothing-tryStmt :: [Statement] -> Maybe CatchClause -> Maybe [Statement] -> Statement-tryStmt block handler finalizer = StatementTry $ TryStatement block handler finalizer---- | Create a catch clause--- Example: catchClause (Just (identPattern "e")) [throwStmt (identExpr "e")]-catchClause :: Maybe Pattern -> [Statement] -> CatchClause-catchClause = CatchClause---- | Create a switch statement--- Example: switchStmt (identExpr "x") [switchCase (Just (intExpr 1)) [returnStmt (Just (stringExpr "one"))], switchCase Nothing [returnStmt (Just (stringExpr "default"))]]-switchStmt :: Expression -> [SwitchCase] -> Statement-switchStmt discriminant cases = StatementSwitch $ SwitchStatement discriminant cases---- | Create a switch case--- Example: switchCase (Just (intExpr 1)) [returnStmt (Just (stringExpr "one"))]-switchCase :: Maybe Expression -> [Statement] -> SwitchCase-switchCase = SwitchCase---- | An empty statement-emptyStmt :: Statement-emptyStmt = StatementEmpty---- | A debugger statement-debuggerStmt :: Statement-debuggerStmt = StatementDebugger----- * Variable Declarations---- | Create a const declaration--- Example: constDecl "x" (Just (intExpr 42))-constDecl :: String -> Maybe Expression -> VariableDeclaration-constDecl name init = VariableDeclaration VariableKindConst- [VariableDeclarator (identPattern name) init]---- | Create a let declaration--- Example: letDecl "x" (Just (intExpr 42))-letDecl :: String -> Maybe Expression -> VariableDeclaration-letDecl name init = VariableDeclaration VariableKindLet- [VariableDeclarator (identPattern name) init]---- | Create a var declaration--- Example: varDecl "x" (Just (intExpr 42))-varDecl :: String -> Maybe Expression -> VariableDeclaration-varDecl name init = VariableDeclaration VariableKindVar- [VariableDeclarator (identPattern name) init]---- | Create a variable declaration statement--- Example: varDeclStmt (constDecl "x" (Just (intExpr 42)))-varDeclStmt :: VariableDeclaration -> Statement-varDeclStmt = StatementVariableDeclaration----- * Function Declarations---- | Create a function declaration--- Example: funcDecl "add" ["x", "y"] [returnStmt (Just (addExpr (identExpr "x") (identExpr "y")))]-funcDecl :: String -> [String] -> [Statement] -> FunctionDeclaration-funcDecl name params body = FunctionDeclaration- (ident name)- (fmap identPattern params)- body- False- False---- | Create an async function declaration--- Example: asyncFuncDecl "fetchData" ["url"] [returnStmt (Just (awaitExpr (callExpr (identExpr "fetch") [identExpr "url"])))]-asyncFuncDecl :: String -> [String] -> [Statement] -> FunctionDeclaration-asyncFuncDecl name params body = FunctionDeclaration- (ident name)- (fmap identPattern params)- body- True- False---- | Create a function declaration statement--- Example: funcDeclStmt (funcDecl "add" ["x", "y"] [returnStmt (Just (addExpr (identExpr "x") (identExpr "y")))])-funcDeclStmt :: FunctionDeclaration -> Statement-funcDeclStmt = StatementFunctionDeclaration----- * Class Declarations---- | Create a class declaration--- Example: classDecl "Person" Nothing [methodDef "greet" [] [returnStmt (Just (stringExpr "hello"))]]-classDecl :: String -> Maybe Expression -> [MethodDefinition] -> ClassDeclaration-classDecl name superClass body = ClassDeclaration (ident name) superClass body---- | Create a method definition--- Example: methodDef "greet" [] [returnStmt (Just (stringExpr "hello"))]-methodDef :: String -> [String] -> [Statement] -> MethodDefinition-methodDef name params body = MethodDefinition- (identExpr name)- (FunctionExpression Nothing (fmap identPattern params) body False False)- MethodKindMethod- False- False---- | Create a constructor definition--- Example: constructorDef ["name"] [exprStmt (assignExpr (PatternIdentifier (ident "this.name")) (identExpr "name"))]-constructorDef :: [String] -> [Statement] -> MethodDefinition-constructorDef params body = MethodDefinition- (identExpr "constructor")- (FunctionExpression Nothing (fmap identPattern params) body False False)- MethodKindConstructor- False- False---- | Create a static method definition--- Example: staticMethodDef "create" [] [returnStmt (Just (newExpr (identExpr "Person") []))]-staticMethodDef :: String -> [String] -> [Statement] -> MethodDefinition-staticMethodDef name params body = MethodDefinition- (identExpr name)- (FunctionExpression Nothing (fmap identPattern params) body False False)- MethodKindMethod- False- True---- | Create a class declaration statement--- Example: classDeclStmt (classDecl "Person" Nothing [])-classDeclStmt :: ClassDeclaration -> Statement-classDeclStmt = StatementClassDeclaration----- * Module Items---- | Create a statement module item--- Example: stmtItem (varDeclStmt (constDecl "x" (Just (intExpr 42))))-stmtItem :: Statement -> ModuleItem-stmtItem = ModuleItemStatement---- | Create an import declaration--- Example: importDecl [importNamed "foo" "foo"] "./module.js"-importDecl :: [ImportClause] -> String -> ImportDeclaration-importDecl specifiers source = ImportDeclaration specifiers (StringLiteral source False)---- | Create a named import--- Example: importNamed "foo" "bar" -- import { foo as bar }-importNamed :: String -> String -> ImportClause-importNamed imported local = ImportClauseNamed $- ImportSpecifier (ident imported) (ident local)---- | Create a default import--- Example: importDefault "foo" -- import foo from ...-importDefault :: String -> ImportClause-importDefault = ImportClauseDefault . ImportDefaultSpecifier . ident---- | Create a namespace import--- Example: importNamespace "foo" -- import * as foo from ...-importNamespace :: String -> ImportClause-importNamespace = ImportClauseNamespace . ImportNamespaceSpecifier . ident---- | Create an import module item--- Example: importItem (importDecl [importDefault "React"] "react")-importItem :: ImportDeclaration -> ModuleItem-importItem = ModuleItemImport---- | Create a named export declaration--- Example: namedExportDecl [("foo", "foo")] Nothing-namedExportDecl :: [(String, String)] -> Maybe String -> ExportDeclaration-namedExportDecl specifiers source = ExportDeclarationNamed $ NamedExport- (fmap (\(local, exported) -> ExportSpecifier (ident local) (ident exported)) specifiers)- (fmap (\s -> StringLiteral s False) source)---- | Create a default export declaration--- Example: defaultExportDecl (identExpr "foo")-defaultExportDecl :: Expression -> ExportDeclaration-defaultExportDecl = ExportDeclarationDefault---- | Create an export declaration for a statement--- Example: exportDeclStmt (varDeclStmt (constDecl "x" (Just (intExpr 42))))-exportDeclStmt :: Statement -> ExportDeclaration-exportDeclStmt = ExportDeclarationDeclaration---- | Create an export module item--- Example: exportItem (defaultExportDecl (identExpr "foo"))-exportItem :: ExportDeclaration -> ModuleItem-exportItem = ModuleItemExport----- * Programs---- | Create a module program--- Example: moduleProgram [importItem (importDecl [importDefault "foo"] "./foo.js"), stmtItem (varDeclStmt (constDecl "x" (Just (intExpr 42))))]-moduleProgram :: [ModuleItem] -> Program-moduleProgram body = Program body SourceTypeModule---- | Create a script program--- Example: scriptProgram [stmtItem (varDeclStmt (constDecl "x" (Just (intExpr 42))))]-scriptProgram :: [ModuleItem] -> Program-scriptProgram body = Program body SourceTypeScript----- * Type Expressions---- | Create an identifier type expression--- Example: identType "string"-identType :: String -> TypeExpression-identType = TypeExpressionIdentifier . ident---- | Create an array type expression--- Example: arrayType (identType "number")-arrayType :: TypeExpression -> TypeExpression-arrayType = TypeExpressionArray . ArrayTypeExpression---- | Create a union type expression--- Example: unionType [identType "string", identType "number"]-unionType :: [TypeExpression] -> TypeExpression-unionType = TypeExpressionUnion---- | Create an optional type expression--- Example: optionalType (identType "string")-optionalType :: TypeExpression -> TypeExpression-optionalType = TypeExpressionOptional---- | Create a parameterized type expression--- Example: paramType (identType "Array") [identType "string"]-paramType :: TypeExpression -> [TypeExpression] -> TypeExpression-paramType base args = TypeExpressionParameterized $- ParameterizedTypeExpression base args---- | The 'any' type-anyType :: TypeExpression-anyType = TypeExpressionAny---- | The 'void' type-voidType :: TypeExpression-voidType = TypeExpressionVoid---- | The 'never' type-neverType :: TypeExpression-neverType = TypeExpressionNever----- * Comments and Documentation---- | Create a line comment--- Example: lineComment "This is a comment"-lineComment :: String -> Comment-lineComment = CommentLine---- | Create a block comment--- Example: blockComment "This is a\nmultiline comment"-blockComment :: String -> Comment-blockComment = CommentBlock---- | Create a documentation comment--- Example: docComment "Description of the function" [paramTag "x" (Just (identType "number")) "The input value"]-docComment :: String -> [DocumentationTag] -> Comment-docComment desc tags = CommentDocumentation $ DocumentationComment desc tags---- | Create a @param documentation tag--- Example: paramTag "x" (Just (identType "number")) "The input value"-paramTag :: String -> Maybe TypeExpression -> String -> DocumentationTag-paramTag name typ desc = DocumentationTag "param" typ (Just $ ident name) desc---- | Create a @returns documentation tag--- Example: returnsTag (Just (identType "number")) "The result"-returnsTag :: Maybe TypeExpression -> String -> DocumentationTag-returnsTag typ desc = DocumentationTag "returns" typ Nothing desc---- | Create a @type documentation tag--- Example: typeTag (identType "number")-typeTag :: TypeExpression -> DocumentationTag-typeTag typ = DocumentationTag "type" (Just typ) Nothing ""
src/main/haskell/Hydra/TypeScript/Coder.hs view
@@ -38,12 +38,13 @@ import qualified Hydra.Packaging as Packaging import qualified Hydra.Parsing as Parsing import qualified Hydra.Paths as Paths+import qualified Hydra.Print.Docs as PrintDocs import qualified Hydra.Query as Query+import qualified Hydra.Regex as Regex import qualified Hydra.Relational as Relational import qualified Hydra.Rewriting as Rewriting import qualified Hydra.Scoping as Scoping import qualified Hydra.Serialization as Serialization-import qualified Hydra.Show.Docs as ShowDocs import qualified Hydra.Sorting as Sorting import qualified Hydra.Strip as Strip import qualified Hydra.System as System@@ -65,6 +66,7 @@ import qualified Data.Map as M import qualified Data.Set as S +-- | Analyze a term as a TypeScript function, using the Graph as the analysis environment analyzeTypeScriptFunction :: Typing.InferenceContext -> Graph.Graph -> Core.Term -> Either t0 (Typing.FunctionStructure Graph.Graph) analyzeTypeScriptFunction cx g term = Analysis.analyzeFunctionTerm cx tsEnvGetGraph tsEnvSetGraph g term @@ -106,6 +108,19 @@ let vars = Variables.freeVariablesInTerm t in (filterNonLocalNames currentNs vars) +-- | Find the free variables of a term that are referenced eagerly, i.e. outside of any nested lambda body; used to break false dependency cycles caused by DSL-level thunks such as hydra.parsers.lazy+eagerFreeVariablesInTerm :: Core.Term -> S.Set Core.Name+eagerFreeVariablesInTerm term =++ let dfltVars =+ \_ -> Lists.foldl (\s -> \t -> Sets.union s (eagerFreeVariablesInTerm t)) Sets.empty (Rewriting.subterms term)+ in case term of+ Core.TermLambda _ -> Sets.empty+ Core.TermLet v0 -> Sets.difference (dfltVars ()) (Sets.fromList (Lists.map (\b -> Core.bindingName b) (Core.letBindings v0)))+ Core.TermVariable v0 -> Sets.singleton v0+ _ -> dfltVars ()++-- | Encode a let-binding as a TS statement inside an enclosing function body, hoisting lambda-valued bindings as nested function declarations encodeBindingAsStatement :: Typing.InferenceContext -> Graph.Graph -> Packaging.ModuleName -> Core.Binding -> Syntax.Statement encodeBindingAsStatement cx g currentNs b = @@ -131,6 +146,7 @@ declarator]} in (Syntax.StatementVariableDeclaration varDecl) +-- | Emit a fully-applied primitive call with selected arguments wrapped in thunks, per a parallel list of laziness flags encodeLazyCall :: Typing.InferenceContext -> Graph.Graph -> Packaging.ModuleName -> Core.Term -> [Core.Term] -> [Bool] -> Syntax.Expression encodeLazyCall cx g currentNs headTerm args lazyFlags = @@ -145,6 +161,7 @@ argExprs = Lists.map renderArg paired in (tsCall headExpr argExprs) +-- | Render a Hydra literal as a TypeScript expression encodeLiteral :: Core.Literal -> Syntax.Expression encodeLiteral lit = @@ -180,6 +197,7 @@ _ -> floatLit 0.0 _ -> litExpr Syntax.LiteralNull +-- | Map a Hydra literal type to a TypeScript type expression encodeLiteralType :: Core.LiteralType -> Syntax.TypeExpression encodeLiteralType lt = case lt of@@ -201,6 +219,7 @@ Core.IntegerTypeUint64 -> tsNamedType "bigint" Core.LiteralTypeString -> tsNamedType "string" +-- | Build a TS function parameter as a pattern, typed unless the domain is the analyze pass's untyped-variable sentinel encodeParam :: t0 -> t1 -> Packaging.ModuleName -> Core.Name -> Core.Type -> Syntax.Pattern encodeParam cx g currentNs pname dom = @@ -209,6 +228,7 @@ Core.TypeVariable _ -> tsTypedIdent nstr Syntax.TypeExpressionAny _ -> tsTypedIdent nstr (encodeTypeOrAny cx g currentNs dom) +-- | Render a Hydra term as a TypeScript expression encodeTerm :: Typing.InferenceContext -> Graph.Graph -> Packaging.ModuleName -> Core.Term -> Syntax.Expression encodeTerm cx g currentNs term = case term of@@ -394,6 +414,7 @@ ("value", (encodeTerm cx g currentNs r))])) v0 _ -> tsExprIdent "null" +-- | Render a Hydra term definition as a TypeScript module item encodeTermDefinition :: Typing.InferenceContext -> Graph.Graph -> Packaging.ModuleName -> Packaging.TermDefinition -> (Maybe String, Syntax.ModuleItem) encodeTermDefinition cx g currentNs td = @@ -425,6 +446,7 @@ in (asExport (Syntax.StatementVariableDeclaration varDecl)) in (mdoc, item) +-- | Map a Hydra type to a TypeScript type expression encodeType :: t0 -> t1 -> Packaging.ModuleName -> Core.Type -> Either t2 Syntax.TypeExpression encodeType cx g currentNs t = @@ -508,6 +530,7 @@ Syntax.stringLiteralSingleQuote = False}))), (tsPropSig "value" False sftyp)])))) v0) (\arms -> Right (Syntax.TypeExpressionUnion arms)) +-- | Encode a Hydra type definition as an interface declaration, a discriminated-union type alias, or a plain type alias encodeTypeDefinition :: t0 -> Graph.Graph -> Packaging.ModuleName -> Packaging.TypeDefinition -> Either Errors.Error (Maybe String, Syntax.ModuleItem) encodeTypeDefinition cx g currentNs tdef = @@ -565,14 +588,17 @@ Syntax.typeAliasDeclarationTypeParameters = typeParams, Syntax.typeAliasDeclarationType = styp})))))) +-- | Try to encode a Hydra type as a TS type expression, falling back to any if encodeType fails encodeTypeOrAny :: t0 -> t1 -> Packaging.ModuleName -> Core.Type -> Syntax.TypeExpression encodeTypeOrAny cx g currentNs typ = Eithers.either (\_e -> Syntax.TypeExpressionAny) (\te -> te) (encodeType cx g currentNs typ) +-- | Keep only names whose module differs from the current module's filterNonLocalNames :: Packaging.ModuleName -> S.Set Core.Name -> S.Set Core.Name filterNonLocalNames currentNs names = Sets.fromList (Optionals.cat (Lists.map (\n -> Optionals.cases (Names.moduleNameOf n) Nothing (\nameNs -> Logic.ifElse (Equality.equal (Packaging.unModuleName currentNs) (Packaging.unModuleName nameNs)) Nothing (Just n))) (Sets.toList names))) +-- | Walk an application spine, returning the innermost head term and its arguments in application order flattenApplication :: Core.Term -> (Core.Term, [Core.Term]) flattenApplication t = @@ -585,6 +611,7 @@ in (head_, (Lists.concat2 prevArgs (Lists.singleton (Core.applicationArgument v0)))) _ -> (t, []) +-- | Rewrite free occurrences of the given target names from x to x(undefined), forcing a thunked binding created by thunkLazyLet forceLazyRefs :: S.Set Core.Name -> Core.Term -> Core.Term forceLazyRefs targets0 term0 = Rewriting.rewriteTermWithContext (\recurse0 -> \targets -> \term -> case term of@@ -600,6 +627,7 @@ in (recurse0 innerTargets term) _ -> recurse0 targets term) targets0 term0 +-- | Build a TS function declaration from a Hydra term by peeling lambdas and let bindings into explicit parameters, statements, and a body functionDeclarationFromTerm :: Typing.InferenceContext -> Graph.Graph -> Packaging.ModuleName -> String -> Core.Term -> Maybe Core.Type -> Syntax.FunctionDeclaration functionDeclarationFromTerm cx g currentNs lname term _mScheme = @@ -638,6 +666,7 @@ Syntax.functionDeclarationAsync = False, Syntax.functionDeclarationGenerator = False} +-- | Render a set of qualified names as TypeScript import statements grouped by source module importsToText :: String -> Packaging.ModuleName -> S.Set Core.Name -> String importsToText kind currentNs names = @@ -684,10 +713,12 @@ ".js\";\n"])) (Maps.toList grouped) in (Strings.cat lines) +-- | Look up a primitive by name and return its per-parameter laziness flags in parameter order lazyFlagsForPrimitive :: Graph.Graph -> Core.Name -> [Bool] lazyFlagsForPrimitive g name = Optionals.cases (Maps.lookup name (Graph.graphPrimitives g)) [] (\prim -> Lists.map (\p -> Typing.parameterIsLazy p) (Typing.termSignatureParameters (Packaging.primitiveDefinitionSignature (Graph.primitiveDefinition prim)))) +-- | True when a let-binding's value should be thunked to preserve Haskell's lazy evaluation semantics letBindingIsThunkCandidate :: Core.Binding -> Bool letBindingIsThunkCandidate b = @@ -703,12 +734,14 @@ "show"]))) False (Sets.toList freeVars) in (Logic.and (Logic.not isLambda) callsShow) +-- | Build a documentation comment from an optional description string, or nothing if the description is missing or empty mkDocComment :: Maybe String -> Maybe Syntax.DocumentationComment mkDocComment mdesc = Optionals.cases mdesc Nothing (\d -> Logic.ifElse (Equality.equal d "") Nothing (Just (Syntax.DocumentationComment {- Syntax.documentationCommentDescription = (ShowDocs.renderDocStringWith tsDocEntityRef d),+ Syntax.documentationCommentDescription = (PrintDocs.renderDocStringWith tsDocEntityRef d), Syntax.documentationCommentTags = []}))) +-- | Convert a Hydra module to a map from .ts file path to TypeScript source moduleToTypeScript :: Packaging.Module -> [Packaging.Definition] -> Typing.InferenceContext -> Graph.Graph -> Either Errors.Error (M.Map String String) moduleToTypeScript mod defs cx g = @@ -753,6 +786,7 @@ body, (Logic.ifElse (Equality.equal body "") "" "\n")]))))) +-- | Render an interface declaration printInterfaceDeclaration :: Syntax.InterfaceDeclaration -> String printInterfaceDeclaration decl = @@ -777,6 +811,7 @@ body, "}\n"]) +-- | Render a TypeScript literal as source text printLiteral :: Syntax.Literal -> String printLiteral lit = case lit of@@ -786,6 +821,7 @@ Syntax.LiteralUndefined -> "undefined" _ -> "null" +-- | Render a top-level module item printModuleItem :: Syntax.ModuleItem -> String printModuleItem mi = case mi of@@ -796,6 +832,7 @@ Syntax.ModuleItemExport _ -> Serialization.printExpr (Serde.moduleItemToExpr mi) _ -> "" +-- | Render a property signature, with an optional JSDoc comment prepended printPropertySignature :: Syntax.PropertySignature -> String printPropertySignature ps = @@ -812,6 +849,7 @@ "\n", line])) +-- | Render a type alias declaration printTypeAliasDeclaration :: Syntax.TypeAliasDeclaration -> String printTypeAliasDeclaration decl = @@ -826,6 +864,7 @@ rhs, ";\n"]) +-- | Render a TypeScript type expression as source text printTypeExpression :: Syntax.TypeExpression -> String printTypeExpression t = case t of@@ -861,6 +900,7 @@ Syntax.TypeExpressionNever -> "never" _ -> "unknown" +-- | Render one generic type parameter, with an optional extends constraint printTypeParameter :: Syntax.TypeParameter -> String printTypeParameter tp = @@ -871,6 +911,7 @@ " extends ", (printTypeExpression c)])) +-- | Render a generic parameter list, or the empty string when there are no parameters printTypeParameterList :: [Syntax.TypeParameter] -> String printTypeParameterList tps = Logic.ifElse (Lists.null tps) "" (Strings.cat [@@ -878,9 +919,11 @@ (Strings.intercalate ", " (Lists.map printTypeParameter tps)), ">"]) +-- | Sanitize a Hydra parameter name into a valid, non-reserved TS identifier sanitizeParamName :: Core.Name -> String sanitizeParamName n = Formatting.sanitizeWithUnderscores Language.typeScriptReservedWords (Names.localNameOf n) +-- | Reorder let-bindings so each appears after the sibling bindings it depends on, avoiding JS temporal-dead-zone errors sortBindingsTopologically :: [Core.Binding] -> [Core.Binding] sortBindingsTopologically bindings = @@ -895,6 +938,7 @@ sccs = Sorting.topologicalSortComponents adjacency in (Optionals.cat (Lists.map (\n -> Maps.lookup n byName) (Lists.concat sccs))) +-- | Reorder term definitions so each appears after the intra-module definitions it depends on sortTermDefsTopologically :: t0 -> [Packaging.TermDefinition] -> [Packaging.TermDefinition] sortTermDefsTopologically currentNs tdefs = @@ -903,12 +947,13 @@ Lists.map (\td -> let tname = Packaging.termDefinitionName td tterm = Packaging.termDefinitionBody td- freeVars = Variables.freeVariablesInTerm tterm+ freeVars = eagerFreeVariablesInTerm tterm deps = Lists.filter (\n -> Maps.member n byName) (Sets.toList freeVars) in (tname, deps)) tdefs sccs = Sorting.topologicalSortComponents adjacency in (Optionals.cat (Lists.map (\n -> Maps.lookup n byName) (Lists.concat sccs))) +-- | Strip leading forall quantifiers from a type, returning the innermost body stripForalls :: Core.Type -> Core.Type stripForalls t = @@ -917,6 +962,7 @@ Core.TypeForall v0 -> stripForalls (Core.forallTypeBody v0) _ -> dt +-- | If a term reduces, through annotations and type applications, to a variable reference, return its name termHeadVariable :: Core.Term -> Maybe Core.Name termHeadVariable t = @@ -926,6 +972,7 @@ Core.TermTypeApplication v0 -> termHeadVariable (Core.typeApplicationTermBody v0) _ -> Nothing +-- | The bindings-and-body core of thunkLazyLet, shared by the Term_let encoder and the lifted-binding path in functionDeclarationFromTerm thunkLazyBindings :: [Core.Binding] -> Core.Term -> ([Core.Binding], Core.Term) thunkLazyBindings bindings body = @@ -945,6 +992,7 @@ Core.bindingTypeScheme = (Core.bindingTypeScheme b)}) in (Lists.map wrapCandidate bindings, (forceLazyRefs targets body)))) +-- | Thunk every let-binding for which letBindingIsThunkCandidate holds, and rewrite forced references to it accordingly thunkLazyLet :: Core.Let -> Core.Let thunkLazyLet lt = @@ -953,9 +1001,11 @@ Core.letBindings = (Pairs.first result), Core.letBody = (Pairs.second result)} +-- | An array expression: [e1, e2, ...] tsArray :: [Syntax.Expression] -> Syntax.Expression tsArray elems = Syntax.ExpressionArray (Lists.map (\e -> Syntax.ArrayElementExpression e) elems) +-- | An untyped arrow function with an expression body tsArrow :: [String] -> Syntax.Expression -> Syntax.Expression tsArrow params body = Syntax.ExpressionArrow (Syntax.ArrowFunctionExpression {@@ -963,6 +1013,7 @@ Syntax.arrowFunctionExpressionBody = (Syntax.ArrowFunctionBodyExpression body), Syntax.arrowFunctionExpressionAsync = False}) +-- | A typed arrow function with typed parameter patterns tsArrowTyped :: [Syntax.Pattern] -> Syntax.Expression -> Syntax.Expression tsArrowTyped patterns body = Syntax.ExpressionArrow (Syntax.ArrowFunctionExpression {@@ -970,12 +1021,14 @@ Syntax.arrowFunctionExpressionBody = (Syntax.ArrowFunctionBodyExpression body), Syntax.arrowFunctionExpressionAsync = False}) +-- | Wrap an expression in a TypeScript 'as any' cast tsAsAny :: Syntax.Expression -> Syntax.Expression tsAsAny e = Syntax.ExpressionAsExpression (Syntax.AsExpression { Syntax.asExpressionExpression = e, Syntax.asExpressionType = Syntax.TypeExpressionAny}) +-- | A call expression, parenthesizing the callee when it's an arrow function or other ambiguous call target tsCall :: Syntax.Expression -> [Syntax.Expression] -> Syntax.Expression tsCall callee args = Syntax.ExpressionCall (Syntax.CallExpression {@@ -983,6 +1036,7 @@ Syntax.callExpressionArguments = args, Syntax.callExpressionOptional = False}) +-- | A conditional (ternary) expression tsCond :: Syntax.Expression -> Syntax.Expression -> Syntax.Expression -> Syntax.Expression tsCond test cons alt = Syntax.ExpressionConditional (Syntax.ConditionalExpression {@@ -1003,12 +1057,15 @@ Packaging.EntityReferenceTermExpr v0 -> Strings.cat2 "`" (Strings.cat2 v0 "`") Packaging.EntityReferenceTypeExpr v0 -> Strings.cat2 "`" (Strings.cat2 v0 "`") +-- | Identity getter for analyzeFunctionTerm when the environment is a Graph tsEnvGetGraph :: t0 -> t0 tsEnvGetGraph g = g +-- | Setter for analyzeFunctionTerm when the environment is a Graph tsEnvSetGraph :: t0 -> t1 -> t0 tsEnvSetGraph newG _old = newG +-- | Escape a Hydra string for embedding as a double-quoted TypeScript string literal tsEscapeString :: String -> String tsEscapeString s = @@ -1019,18 +1076,22 @@ (Strings.cat (Lists.map escapeChar (Strings.toList s))), "\""]) +-- | A bare identifier expression tsExprIdent :: String -> Syntax.Expression tsExprIdent s = Syntax.ExpressionIdentifier (tsIdent s) +-- | A string-literal expression tsExprStr :: String -> Syntax.Expression tsExprStr s = Syntax.ExpressionLiteral (Syntax.LiteralString (Syntax.StringLiteral { Syntax.stringLiteralValue = s, Syntax.stringLiteralSingleQuote = False})) +-- | Wrap a string into a TypeScript identifier tsIdent :: String -> Syntax.Identifier tsIdent s = Syntax.Identifier s +-- | A member-access expression: obj.prop tsMember :: Syntax.Expression -> String -> Syntax.Expression tsMember obj prop = Syntax.ExpressionMember (Syntax.MemberExpression {@@ -1039,9 +1100,11 @@ Syntax.memberExpressionComputed = False, Syntax.memberExpressionOptional = False}) +-- | A bare named type reference tsNamedType :: String -> Syntax.TypeExpression tsNamedType n = Syntax.TypeExpressionIdentifier (tsIdent n) +-- | A new-expression: new C(args) tsNew :: Syntax.Expression -> [Syntax.Expression] -> Syntax.Expression tsNew callee args = Syntax.ExpressionNew (Syntax.CallExpression {@@ -1049,6 +1112,7 @@ Syntax.callExpressionArguments = args, Syntax.callExpressionOptional = False}) +-- | An object literal with identifier-style keys tsObject :: [(String, Syntax.Expression)] -> Syntax.Expression tsObject props = Syntax.ExpressionObject (Lists.map (\kv ->@@ -1061,6 +1125,7 @@ Syntax.propertyComputed = False, Syntax.propertyShorthand = False}) props) +-- | A generic type parameter with no constraint tsParam :: String -> Syntax.TypeParameter tsParam n = Syntax.TypeParameter {@@ -1068,6 +1133,7 @@ Syntax.typeParameterConstraint = Nothing, Syntax.typeParameterDefault = Nothing} +-- | A parameterized type with one type argument tsParamApp1 :: String -> Syntax.TypeExpression -> Syntax.TypeExpression tsParamApp1 n arg = Syntax.TypeExpressionParameterized (Syntax.ParameterizedTypeExpression {@@ -1075,6 +1141,7 @@ Syntax.parameterizedTypeExpressionArguments = [ arg]}) +-- | A parameterized type with two type arguments tsParamApp2 :: String -> Syntax.TypeExpression -> Syntax.TypeExpression -> Syntax.TypeExpression tsParamApp2 n a b = Syntax.TypeExpressionParameterized (Syntax.ParameterizedTypeExpression {@@ -1083,12 +1150,15 @@ a, b]}) +-- | Wrap an expression in parentheses when its serialized form needs grouping tsParen :: Syntax.Expression -> Syntax.Expression tsParen e = Syntax.ExpressionParenthesized e +-- | A readonly property signature, with the name sanitized for TS reserved words tsPropSig :: String -> Bool -> Syntax.TypeExpression -> Syntax.PropertySignature tsPropSig name optional typ = tsPropSigWithDoc name optional typ Nothing +-- | A readonly property signature with an optional JSDoc comment above the property line tsPropSigWithDoc :: String -> Bool -> Syntax.TypeExpression -> Maybe Syntax.DocumentationComment -> Syntax.PropertySignature tsPropSigWithDoc name optional typ mcomments = @@ -1100,20 +1170,25 @@ Syntax.propertySignatureReadonly = True, Syntax.propertySignatureComments = mcomments} +-- | A ReadonlyMap type with the given key and value types tsReadonlyMap :: Syntax.TypeExpression -> Syntax.TypeExpression -> Syntax.TypeExpression tsReadonlyMap k v = tsParamApp2 "ReadonlyMap" k v +-- | A ReadonlySet type with the given element type tsReadonlySet :: Syntax.TypeExpression -> Syntax.TypeExpression tsReadonlySet t = tsParamApp1 "ReadonlySet" t +-- | A tuple type tsTuple :: [Syntax.TypeExpression] -> Syntax.TypeExpression tsTuple ts = Syntax.TypeExpressionTuple ts +-- | A typed-identifier pattern for a function parameter with a known domain type tsTypedIdent :: String -> Syntax.TypeExpression -> Syntax.Pattern tsTypedIdent name typ = Syntax.PatternTyped (Syntax.TypedPattern { Syntax.typedPatternPattern = (Syntax.PatternIdentifier (tsIdent name)), Syntax.typedPatternType = typ}) +-- | The undefined value as an expression tsUndefined :: Syntax.Expression tsUndefined = tsExprIdent "undefined"
src/main/haskell/Hydra/TypeScript/Language.hs view
@@ -24,6 +24,7 @@ import qualified Hydra.Parsing as Parsing import qualified Hydra.Paths as Paths import qualified Hydra.Query as Query+import qualified Hydra.Regex as Regex import qualified Hydra.Relational as Relational import qualified Hydra.System as System import qualified Hydra.Tabular as Tabular
src/main/haskell/Hydra/TypeScript/Operators.hs view
@@ -21,6 +21,7 @@ import qualified Hydra.Parsing as Parsing import qualified Hydra.Paths as Paths import qualified Hydra.Query as Query+import qualified Hydra.Regex as Regex import qualified Hydra.Relational as Relational import qualified Hydra.Serialization as Serialization import qualified Hydra.System as System
src/main/haskell/Hydra/TypeScript/Serde.hs view
@@ -30,6 +30,7 @@ import qualified Hydra.Parsing as Parsing import qualified Hydra.Paths as Paths import qualified Hydra.Query as Query+import qualified Hydra.Regex as Regex import qualified Hydra.Relational as Relational import qualified Hydra.Serialization as Serialization import qualified Hydra.System as System@@ -47,6 +48,7 @@ import Prelude hiding (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum) import qualified Data.Scientific as Sci +-- | True iff every codepoint is an ASCII digit 0-9, and the list is non-empty allDigits :: [Int] -> Bool allDigits cps = Logic.and (Equality.gt (Lists.length cps) 0) (Lists.foldl (\acc -> \c -> Logic.and acc (Logic.and (Equality.gte c 48) (Equality.lte c 57))) True cps)@@ -594,6 +596,7 @@ (Serialization.cst "as"), (identifierToExpr (Syntax.unImportNamespaceSpecifier v0))] +-- | Detect a kernel-synthesized type-variable name like T0 or T12, which is unbound in inline type annotations isKernelTypeVarName :: String -> Bool isKernelTypeVarName s =
src/main/haskell/Hydra/TypeScript/Syntax.hs view
@@ -9,1721 +9,1721 @@ import qualified Data.Scientific as Sci import qualified Data.Int as I --- | A TypeScript identifier (variable, function, class name, etc.)-newtype Identifier =- Identifier {- unIdentifier :: String}- deriving (Eq, Ord, Read, Show)--_Identifier = Core.Name "hydra.typeScript.syntax.Identifier"---- | A qualified name like 'module.submodule.name'-type QualifiedName = [Identifier]--_QualifiedName = Core.Name "hydra.typeScript.syntax.QualifiedName"---- | A literal value-data Literal =- -- | A string literal- LiteralString StringLiteral |- -- | A numeric literal- LiteralNumber NumericLiteral |- -- | A boolean literal (true or false)- LiteralBoolean Bool |- -- | The null literal- LiteralNull |- -- | The undefined literal- LiteralUndefined |- -- | A BigInt literal (e.g., 123n)- LiteralBigInt Integer |- -- | A template literal- LiteralTemplate TemplateLiteral- deriving (Eq, Ord, Read, Show)--_Literal = Core.Name "hydra.typeScript.syntax.Literal"--_Literal_string = Core.Name "string"--_Literal_number = Core.Name "number"--_Literal_boolean = Core.Name "boolean"--_Literal_null = Core.Name "null"--_Literal_undefined = Core.Name "undefined"--_Literal_bigInt = Core.Name "bigInt"--_Literal_template = Core.Name "template"---- | A string literal with quote style-data StringLiteral =- StringLiteral {- -- | The string value- stringLiteralValue :: String,- -- | Whether to use single quotes (true) or double quotes (false)- stringLiteralSingleQuote :: Bool}- deriving (Eq, Ord, Read, Show)--_StringLiteral = Core.Name "hydra.typeScript.syntax.StringLiteral"--_StringLiteral_value = Core.Name "value"--_StringLiteral_singleQuote = Core.Name "singleQuote"---- | A template literal (backtick string with interpolations)-data TemplateLiteral =- TemplateLiteral {- -- | The static string parts- templateLiteralQuasis :: [TemplateElement],- -- | The interpolated expressions- templateLiteralExpressions :: [Expression]}- deriving (Eq, Ord, Read, Show)--_TemplateLiteral = Core.Name "hydra.typeScript.syntax.TemplateLiteral"--_TemplateLiteral_quasis = Core.Name "quasis"--_TemplateLiteral_expressions = Core.Name "expressions"---- | A static part of a template literal-data TemplateElement =- TemplateElement {- -- | The raw string value- templateElementValue :: String,- -- | Whether this is the last element- templateElementTail :: Bool}- deriving (Eq, Ord, Read, Show)--_TemplateElement = Core.Name "hydra.typeScript.syntax.TemplateElement"--_TemplateElement_value = Core.Name "value"--_TemplateElement_tail = Core.Name "tail"---- | A numeric literal (integer or floating-point)-data NumericLiteral =- -- | An integer literal- NumericLiteralInteger I.Int64 |- -- | A floating-point literal- NumericLiteralFloat Double- deriving (Eq, Ord, Read, Show)--_NumericLiteral = Core.Name "hydra.typeScript.syntax.NumericLiteral"--_NumericLiteral_integer = Core.Name "integer"--_NumericLiteral_float = Core.Name "float"---- | A type annotation (for JSDoc comments or TypeScript)-newtype TypeAnnotation =- TypeAnnotation {- unTypeAnnotation :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_TypeAnnotation = Core.Name "hydra.typeScript.syntax.TypeAnnotation"---- | A type expression-data TypeExpression =- -- | A named type (e.g., 'string', 'number', 'MyClass')- TypeExpressionIdentifier Identifier |- -- | A literal type (e.g., 'hello', 42)- TypeExpressionLiteral Literal |- -- | An array type- TypeExpressionArray ArrayTypeExpression |- -- | A function type- TypeExpressionFunction FunctionTypeExpression |- -- | An object type- TypeExpressionObject ObjectTypeExpression |- -- | A tuple type (readonly [A, B, C])- TypeExpressionTuple TupleTypeExpression |- -- | A union type (A | B)- TypeExpressionUnion UnionTypeExpression |- -- | An intersection type (A & B)- TypeExpressionIntersection IntersectionTypeExpression |- -- | A parameterized type (e.g., Array<T>, Map<K, V>)- TypeExpressionParameterized ParameterizedTypeExpression |- -- | An optional type (T | undefined or T?)- TypeExpressionOptional TypeExpression |- -- | A readonly modifier (readonly T[], readonly [A, B])- TypeExpressionReadonly TypeExpression |- -- | The 'any' type- TypeExpressionAny |- -- | The 'unknown' type- TypeExpressionUnknown |- -- | The 'void' type- TypeExpressionVoid |- -- | The 'never' type- TypeExpressionNever- deriving (Eq, Ord, Read, Show)--_TypeExpression = Core.Name "hydra.typeScript.syntax.TypeExpression"--_TypeExpression_identifier = Core.Name "identifier"--_TypeExpression_literal = Core.Name "literal"--_TypeExpression_array = Core.Name "array"--_TypeExpression_function = Core.Name "function"--_TypeExpression_object = Core.Name "object"--_TypeExpression_tuple = Core.Name "tuple"--_TypeExpression_union = Core.Name "union"--_TypeExpression_intersection = Core.Name "intersection"--_TypeExpression_parameterized = Core.Name "parameterized"--_TypeExpression_optional = Core.Name "optional"--_TypeExpression_readonly = Core.Name "readonly"--_TypeExpression_any = Core.Name "any"--_TypeExpression_unknown = Core.Name "unknown"--_TypeExpression_void = Core.Name "void"--_TypeExpression_never = Core.Name "never"---- | A function type expression-data FunctionTypeExpression =- FunctionTypeExpression {- -- | Type parameters (generics)- functionTypeExpressionTypeParameters :: [TypeParameter],- -- | Parameter types- functionTypeExpressionParameters :: [TypeExpression],- -- | Return type- functionTypeExpressionReturnType :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_FunctionTypeExpression = Core.Name "hydra.typeScript.syntax.FunctionTypeExpression"--_FunctionTypeExpression_typeParameters = Core.Name "typeParameters"--_FunctionTypeExpression_parameters = Core.Name "parameters"--_FunctionTypeExpression_returnType = Core.Name "returnType"---- | An array type (T[])-newtype ArrayTypeExpression =- ArrayTypeExpression {- unArrayTypeExpression :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_ArrayTypeExpression = Core.Name "hydra.typeScript.syntax.ArrayTypeExpression"---- | A tuple type ([A, B] or readonly [A, B])-type TupleTypeExpression = [TypeExpression]--_TupleTypeExpression = Core.Name "hydra.typeScript.syntax.TupleTypeExpression"---- | A union type (A | B | C)-type UnionTypeExpression = [TypeExpression]--_UnionTypeExpression = Core.Name "hydra.typeScript.syntax.UnionTypeExpression"---- | An intersection type (A & B & C)-type IntersectionTypeExpression = [TypeExpression]--_IntersectionTypeExpression = Core.Name "hydra.typeScript.syntax.IntersectionTypeExpression"---- | A parameterized type (e.g., Array<T>, Map<K, V>)-data ParameterizedTypeExpression =- ParameterizedTypeExpression {- parameterizedTypeExpressionBase :: TypeExpression,- parameterizedTypeExpressionArguments :: [TypeExpression]}- deriving (Eq, Ord, Read, Show)--_ParameterizedTypeExpression = Core.Name "hydra.typeScript.syntax.ParameterizedTypeExpression"--_ParameterizedTypeExpression_base = Core.Name "base"--_ParameterizedTypeExpression_arguments = Core.Name "arguments"---- | An object type with property signatures-type ObjectTypeExpression = [PropertySignature]--_ObjectTypeExpression = Core.Name "hydra.typeScript.syntax.ObjectTypeExpression"---- | A property signature in an object type-data PropertySignature =- PropertySignature {- -- | Property name- propertySignatureName :: Identifier,- -- | Property type- propertySignatureType :: TypeExpression,- -- | Whether the property is optional- propertySignatureOptional :: Bool,- -- | Whether the property is readonly- propertySignatureReadonly :: Bool,- -- | Optional JSDoc documentation comment to emit above this property- propertySignatureComments :: (Maybe DocumentationComment)}- deriving (Eq, Ord, Read, Show)--_PropertySignature = Core.Name "hydra.typeScript.syntax.PropertySignature"--_PropertySignature_name = Core.Name "name"--_PropertySignature_type = Core.Name "type"--_PropertySignature_optional = Core.Name "optional"--_PropertySignature_readonly = Core.Name "readonly"--_PropertySignature_comments = Core.Name "comments"---- | A type parameter (generic)-data TypeParameter =- TypeParameter {- -- | Parameter name- typeParameterName :: Identifier,- -- | Optional constraint (extends clause)- typeParameterConstraint :: (Maybe TypeExpression),- -- | Optional default type- typeParameterDefault :: (Maybe TypeExpression)}- deriving (Eq, Ord, Read, Show)--_TypeParameter = Core.Name "hydra.typeScript.syntax.TypeParameter"--_TypeParameter_name = Core.Name "name"--_TypeParameter_constraint = Core.Name "constraint"--_TypeParameter_default = Core.Name "default"---- | A TypeScript interface declaration (interface Foo<T> extends Bar { ... })-data InterfaceDeclaration =- InterfaceDeclaration {- -- | Interface name- interfaceDeclarationName :: Identifier,- -- | Generic parameters- interfaceDeclarationTypeParameters :: [TypeParameter],- -- | Interfaces this one extends- interfaceDeclarationExtends :: [TypeExpression],- -- | Property signatures (the interface body)- interfaceDeclarationMembers :: [PropertySignature]}- deriving (Eq, Ord, Read, Show)--_InterfaceDeclaration = Core.Name "hydra.typeScript.syntax.InterfaceDeclaration"--_InterfaceDeclaration_name = Core.Name "name"--_InterfaceDeclaration_typeParameters = Core.Name "typeParameters"--_InterfaceDeclaration_extends = Core.Name "extends"--_InterfaceDeclaration_members = Core.Name "members"---- | A TypeScript type alias declaration (type Foo<T> = ...)-data TypeAliasDeclaration =- TypeAliasDeclaration {- -- | Alias name- typeAliasDeclarationName :: Identifier,- -- | Generic parameters- typeAliasDeclarationTypeParameters :: [TypeParameter],- -- | The right-hand-side type- typeAliasDeclarationType :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_TypeAliasDeclaration = Core.Name "hydra.typeScript.syntax.TypeAliasDeclaration"--_TypeAliasDeclaration_name = Core.Name "name"--_TypeAliasDeclaration_typeParameters = Core.Name "typeParameters"--_TypeAliasDeclaration_type = Core.Name "type"---- | A TypeScript expression-data Expression =- -- | A simple identifier- ExpressionIdentifier Identifier |- -- | A literal value- ExpressionLiteral Literal |- -- | An array expression [a, b, c]- ExpressionArray ArrayExpression |- -- | An object expression {a: 1, b: 2}- ExpressionObject ObjectExpression |- -- | A function expression- ExpressionFunction FunctionExpression |- -- | An arrow function expression- ExpressionArrow ArrowFunctionExpression |- -- | A function call expression- ExpressionCall CallExpression |- -- | A member access expression (obj.prop or obj[prop])- ExpressionMember MemberExpression |- -- | A conditional (ternary) expression- ExpressionConditional ConditionalExpression |- -- | A binary operation expression- ExpressionBinary BinaryExpression |- -- | A unary operation expression- ExpressionUnary UnaryExpression |- -- | An assignment expression- ExpressionAssignment AssignmentExpression |- -- | A sequence expression (a, b, c)- ExpressionSequence [Expression] |- -- | The 'this' keyword- ExpressionThis |- -- | A 'new' expression- ExpressionNew CallExpression |- -- | A yield expression- ExpressionYield (Maybe Expression) |- -- | An await expression- ExpressionAwait Expression |- -- | A spread expression (...x)- ExpressionSpread SpreadElement |- -- | A parenthesized expression- ExpressionParenthesized Expression |- -- | A TypeScript type assertion `<expr> as <type>`- ExpressionAsExpression AsExpression- deriving (Eq, Ord, Read, Show)--_Expression = Core.Name "hydra.typeScript.syntax.Expression"--_Expression_identifier = Core.Name "identifier"--_Expression_literal = Core.Name "literal"--_Expression_array = Core.Name "array"--_Expression_object = Core.Name "object"--_Expression_function = Core.Name "function"--_Expression_arrow = Core.Name "arrow"--_Expression_call = Core.Name "call"--_Expression_member = Core.Name "member"--_Expression_conditional = Core.Name "conditional"--_Expression_binary = Core.Name "binary"--_Expression_unary = Core.Name "unary"--_Expression_assignment = Core.Name "assignment"--_Expression_sequence = Core.Name "sequence"--_Expression_this = Core.Name "this"--_Expression_new = Core.Name "new"--_Expression_yield = Core.Name "yield"--_Expression_await = Core.Name "await"--_Expression_spread = Core.Name "spread"--_Expression_parenthesized = Core.Name "parenthesized"--_Expression_asExpression = Core.Name "asExpression"---- | A TypeScript `<expression> as <type>` cast-data AsExpression =- AsExpression {- -- | The expression being cast- asExpressionExpression :: Expression,- -- | The target type- asExpressionType :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_AsExpression = Core.Name "hydra.typeScript.syntax.AsExpression"--_AsExpression_expression = Core.Name "expression"--_AsExpression_type = Core.Name "type"---- | An array expression [a, b, c]-type ArrayExpression = [ArrayElement]--_ArrayExpression = Core.Name "hydra.typeScript.syntax.ArrayExpression"---- | An object expression {a: 1, b: 2}-type ObjectExpression = [Property]--_ObjectExpression = Core.Name "hydra.typeScript.syntax.ObjectExpression"---- | A function expression-data FunctionExpression =- FunctionExpression {- -- | Optional function name- functionExpressionId :: (Maybe Identifier),- -- | Function parameters- functionExpressionParams :: [Pattern],- -- | Function body- functionExpressionBody :: BlockStatement,- -- | Whether the function is async- functionExpressionAsync :: Bool,- -- | Whether the function is a generator- functionExpressionGenerator :: Bool}- deriving (Eq, Ord, Read, Show)--_FunctionExpression = Core.Name "hydra.typeScript.syntax.FunctionExpression"--_FunctionExpression_id = Core.Name "id"--_FunctionExpression_params = Core.Name "params"--_FunctionExpression_body = Core.Name "body"--_FunctionExpression_async = Core.Name "async"--_FunctionExpression_generator = Core.Name "generator"---- | An arrow function expression-data ArrowFunctionExpression =- ArrowFunctionExpression {- -- | Function parameters- arrowFunctionExpressionParams :: [Pattern],- -- | Function body (expression or block)- arrowFunctionExpressionBody :: ArrowFunctionBody,- -- | Whether the function is async- arrowFunctionExpressionAsync :: Bool}- deriving (Eq, Ord, Read, Show)--_ArrowFunctionExpression = Core.Name "hydra.typeScript.syntax.ArrowFunctionExpression"--_ArrowFunctionExpression_params = Core.Name "params"--_ArrowFunctionExpression_body = Core.Name "body"--_ArrowFunctionExpression_async = Core.Name "async"---- | The body of an arrow function (expression or block)-data ArrowFunctionBody =- ArrowFunctionBodyExpression Expression |- ArrowFunctionBodyBlock BlockStatement- deriving (Eq, Ord, Read, Show)--_ArrowFunctionBody = Core.Name "hydra.typeScript.syntax.ArrowFunctionBody"--_ArrowFunctionBody_expression = Core.Name "expression"--_ArrowFunctionBody_block = Core.Name "block"---- | A function call expression-data CallExpression =- CallExpression {- -- | The function being called- callExpressionCallee :: Expression,- -- | The arguments- callExpressionArguments :: [Expression],- -- | Whether using optional chaining (?.)- callExpressionOptional :: Bool}- deriving (Eq, Ord, Read, Show)--_CallExpression = Core.Name "hydra.typeScript.syntax.CallExpression"--_CallExpression_callee = Core.Name "callee"--_CallExpression_arguments = Core.Name "arguments"--_CallExpression_optional = Core.Name "optional"---- | A member access expression-data MemberExpression =- MemberExpression {- -- | The object- memberExpressionObject :: Expression,- -- | The property- memberExpressionProperty :: Expression,- -- | Whether using bracket notation (obj[prop])- memberExpressionComputed :: Bool,- -- | Whether using optional chaining (?.)- memberExpressionOptional :: Bool}- deriving (Eq, Ord, Read, Show)--_MemberExpression = Core.Name "hydra.typeScript.syntax.MemberExpression"--_MemberExpression_object = Core.Name "object"--_MemberExpression_property = Core.Name "property"--_MemberExpression_computed = Core.Name "computed"--_MemberExpression_optional = Core.Name "optional"---- | A conditional (ternary) expression: test ? consequent : alternate-data ConditionalExpression =- ConditionalExpression {- conditionalExpressionTest :: Expression,- conditionalExpressionConsequent :: Expression,- conditionalExpressionAlternate :: Expression}- deriving (Eq, Ord, Read, Show)--_ConditionalExpression = Core.Name "hydra.typeScript.syntax.ConditionalExpression"--_ConditionalExpression_test = Core.Name "test"--_ConditionalExpression_consequent = Core.Name "consequent"--_ConditionalExpression_alternate = Core.Name "alternate"---- | A binary operation expression-data BinaryExpression =- BinaryExpression {- binaryExpressionOperator :: BinaryOperator,- binaryExpressionLeft :: Expression,- binaryExpressionRight :: Expression}- deriving (Eq, Ord, Read, Show)--_BinaryExpression = Core.Name "hydra.typeScript.syntax.BinaryExpression"--_BinaryExpression_operator = Core.Name "operator"--_BinaryExpression_left = Core.Name "left"--_BinaryExpression_right = Core.Name "right"---- | A unary operation expression-data UnaryExpression =- UnaryExpression {- unaryExpressionOperator :: UnaryOperator,- unaryExpressionArgument :: Expression,- -- | Whether the operator is prefix (true) or postfix (false)- unaryExpressionPrefix :: Bool}- deriving (Eq, Ord, Read, Show)--_UnaryExpression = Core.Name "hydra.typeScript.syntax.UnaryExpression"--_UnaryExpression_operator = Core.Name "operator"--_UnaryExpression_argument = Core.Name "argument"--_UnaryExpression_prefix = Core.Name "prefix"---- | An assignment expression-data AssignmentExpression =- AssignmentExpression {- assignmentExpressionOperator :: AssignmentOperator,- assignmentExpressionLeft :: Pattern,- assignmentExpressionRight :: Expression}- deriving (Eq, Ord, Read, Show)--_AssignmentExpression = Core.Name "hydra.typeScript.syntax.AssignmentExpression"--_AssignmentExpression_operator = Core.Name "operator"--_AssignmentExpression_left = Core.Name "left"--_AssignmentExpression_right = Core.Name "right"---- | A spread element (...x)-newtype SpreadElement =- SpreadElement {- unSpreadElement :: Expression}- deriving (Eq, Ord, Read, Show)--_SpreadElement = Core.Name "hydra.typeScript.syntax.SpreadElement"---- | A property in an object expression-data Property =- Property {- -- | Property key (identifier, literal, or computed)- propertyKey :: Expression,- -- | Property value- propertyValue :: Expression,- -- | Property kind (init, get, set)- propertyKind :: PropertyKind,- -- | Whether the key is computed [expr]- propertyComputed :: Bool,- -- | Whether using shorthand syntax {x} for {x: x}- propertyShorthand :: Bool}- deriving (Eq, Ord, Read, Show)--_Property = Core.Name "hydra.typeScript.syntax.Property"--_Property_key = Core.Name "key"--_Property_value = Core.Name "value"--_Property_kind = Core.Name "kind"--_Property_computed = Core.Name "computed"--_Property_shorthand = Core.Name "shorthand"---- | The kind of an object property-data PropertyKind =- -- | A normal property initialization- PropertyKindInit |- -- | A getter- PropertyKindGet |- -- | A setter- PropertyKindSet- deriving (Eq, Ord, Read, Show)--_PropertyKind = Core.Name "hydra.typeScript.syntax.PropertyKind"--_PropertyKind_init = Core.Name "init"--_PropertyKind_get = Core.Name "get"--_PropertyKind_set = Core.Name "set"---- | An element in an array expression-data ArrayElement =- -- | A regular expression element- ArrayElementExpression Expression |- -- | A spread element ...x- ArrayElementSpread SpreadElement |- -- | An empty slot (elision)- ArrayElementHole- deriving (Eq, Ord, Read, Show)--_ArrayElement = Core.Name "hydra.typeScript.syntax.ArrayElement"--_ArrayElement_expression = Core.Name "expression"--_ArrayElement_spread = Core.Name "spread"--_ArrayElement_hole = Core.Name "hole"---- | A binding pattern (for destructuring)-data Pattern =- -- | A simple identifier binding- PatternIdentifier Identifier |- -- | An object destructuring pattern- PatternObject ObjectPattern |- -- | An array destructuring pattern- PatternArray ArrayPattern |- -- | A pattern with default value- PatternAssignment AssignmentPattern |- -- | A rest element (...x)- PatternRest RestElement |- -- | A pattern with a TypeScript type annotation (`x: T`)- PatternTyped TypedPattern- deriving (Eq, Ord, Read, Show)--_Pattern = Core.Name "hydra.typeScript.syntax.Pattern"--_Pattern_identifier = Core.Name "identifier"--_Pattern_object = Core.Name "object"--_Pattern_array = Core.Name "array"--_Pattern_assignment = Core.Name "assignment"--_Pattern_rest = Core.Name "rest"--_Pattern_typed = Core.Name "typed"---- | An object destructuring pattern {a, b: c}-data ObjectPattern =- ObjectPattern {- -- | The property patterns- objectPatternProperties :: [ObjectPatternProperty]}- deriving (Eq, Ord, Read, Show)--_ObjectPattern = Core.Name "hydra.typeScript.syntax.ObjectPattern"--_ObjectPattern_properties = Core.Name "properties"---- | A property in an object pattern-data ObjectPatternProperty =- ObjectPatternPropertyProperty Property |- ObjectPatternPropertyRest RestElement- deriving (Eq, Ord, Read, Show)--_ObjectPatternProperty = Core.Name "hydra.typeScript.syntax.ObjectPatternProperty"--_ObjectPatternProperty_property = Core.Name "property"--_ObjectPatternProperty_rest = Core.Name "rest"---- | An array destructuring pattern [a, b, c]-type ArrayPattern = [Maybe Pattern]--_ArrayPattern = Core.Name "hydra.typeScript.syntax.ArrayPattern"---- | A pattern with default value (param = default)-data AssignmentPattern =- AssignmentPattern {- assignmentPatternLeft :: Pattern,- assignmentPatternRight :: Expression}- deriving (Eq, Ord, Read, Show)--_AssignmentPattern = Core.Name "hydra.typeScript.syntax.AssignmentPattern"--_AssignmentPattern_left = Core.Name "left"--_AssignmentPattern_right = Core.Name "right"---- | A rest element pattern (...x)-newtype RestElement =- RestElement {- unRestElement :: Pattern}- deriving (Eq, Ord, Read, Show)--_RestElement = Core.Name "hydra.typeScript.syntax.RestElement"---- | A pattern with a TypeScript type annotation (`x: T`)-data TypedPattern =- TypedPattern {- -- | The underlying binding pattern- typedPatternPattern :: Pattern,- -- | The TypeScript type annotation- typedPatternType :: TypeExpression}- deriving (Eq, Ord, Read, Show)--_TypedPattern = Core.Name "hydra.typeScript.syntax.TypedPattern"--_TypedPattern_pattern = Core.Name "pattern"--_TypedPattern_type = Core.Name "type"---- | A TypeScript statement-data Statement =- -- | An expression statement- StatementExpression Expression |- -- | A block statement- StatementBlock BlockStatement |- -- | An empty statement (;)- StatementEmpty |- -- | A debugger statement- StatementDebugger |- -- | A return statement- StatementReturn ReturnStatement |- -- | A break statement- StatementBreak BreakStatement |- -- | A continue statement- StatementContinue ContinueStatement |- -- | An if statement- StatementIf IfStatement |- -- | A switch statement- StatementSwitch SwitchStatement |- -- | A throw statement- StatementThrow ThrowStatement |- -- | A try statement- StatementTry TryStatement |- -- | A while statement- StatementWhile WhileStatement |- -- | A do-while statement- StatementDoWhile DoWhileStatement |- -- | A for statement- StatementFor ForStatement |- -- | A for-in statement- StatementForIn ForInStatement |- -- | A for-of statement- StatementForOf ForOfStatement |- -- | A variable declaration- StatementVariableDeclaration VariableDeclaration |- -- | A function declaration- StatementFunctionDeclaration FunctionDeclaration |- -- | A class declaration- StatementClassDeclaration ClassDeclaration |- -- | A labeled statement- StatementLabeled LabeledStatement- deriving (Eq, Ord, Read, Show)--_Statement = Core.Name "hydra.typeScript.syntax.Statement"--_Statement_expression = Core.Name "expression"--_Statement_block = Core.Name "block"--_Statement_empty = Core.Name "empty"--_Statement_debugger = Core.Name "debugger"--_Statement_return = Core.Name "return"--_Statement_break = Core.Name "break"--_Statement_continue = Core.Name "continue"--_Statement_if = Core.Name "if"--_Statement_switch = Core.Name "switch"--_Statement_throw = Core.Name "throw"--_Statement_try = Core.Name "try"--_Statement_while = Core.Name "while"--_Statement_doWhile = Core.Name "doWhile"--_Statement_for = Core.Name "for"--_Statement_forIn = Core.Name "forIn"--_Statement_forOf = Core.Name "forOf"--_Statement_variableDeclaration = Core.Name "variableDeclaration"--_Statement_functionDeclaration = Core.Name "functionDeclaration"--_Statement_classDeclaration = Core.Name "classDeclaration"--_Statement_labeled = Core.Name "labeled"---- | A labeled statement-data LabeledStatement =- LabeledStatement {- labeledStatementLabel :: Identifier,- labeledStatementBody :: Statement}- deriving (Eq, Ord, Read, Show)--_LabeledStatement = Core.Name "hydra.typeScript.syntax.LabeledStatement"--_LabeledStatement_label = Core.Name "label"--_LabeledStatement_body = Core.Name "body"---- | A block statement { ... }-type BlockStatement = [Statement]--_BlockStatement = Core.Name "hydra.typeScript.syntax.BlockStatement"---- | A variable declaration (var, let, const)-data VariableDeclaration =- VariableDeclaration {- variableDeclarationKind :: VariableKind,- variableDeclarationDeclarations :: [VariableDeclarator]}- deriving (Eq, Ord, Read, Show)--_VariableDeclaration = Core.Name "hydra.typeScript.syntax.VariableDeclaration"--_VariableDeclaration_kind = Core.Name "kind"--_VariableDeclaration_declarations = Core.Name "declarations"---- | A variable declarator (id = init)-data VariableDeclarator =- VariableDeclarator {- variableDeclaratorId :: Pattern,- variableDeclaratorInit :: (Maybe Expression)}- deriving (Eq, Ord, Read, Show)--_VariableDeclarator = Core.Name "hydra.typeScript.syntax.VariableDeclarator"--_VariableDeclarator_id = Core.Name "id"--_VariableDeclarator_init = Core.Name "init"---- | The kind of variable declaration-data VariableKind =- VariableKindVar |- VariableKindLet |- VariableKindConst- deriving (Eq, Ord, Read, Show)--_VariableKind = Core.Name "hydra.typeScript.syntax.VariableKind"--_VariableKind_var = Core.Name "var"--_VariableKind_let = Core.Name "let"--_VariableKind_const = Core.Name "const"---- | An if statement-data IfStatement =- IfStatement {- ifStatementTest :: Expression,- ifStatementConsequent :: Statement,- ifStatementAlternate :: (Maybe Statement)}- deriving (Eq, Ord, Read, Show)--_IfStatement = Core.Name "hydra.typeScript.syntax.IfStatement"--_IfStatement_test = Core.Name "test"--_IfStatement_consequent = Core.Name "consequent"--_IfStatement_alternate = Core.Name "alternate"---- | A switch statement-data SwitchStatement =- SwitchStatement {- switchStatementDiscriminant :: Expression,- switchStatementCases :: [SwitchCase]}- deriving (Eq, Ord, Read, Show)--_SwitchStatement = Core.Name "hydra.typeScript.syntax.SwitchStatement"--_SwitchStatement_discriminant = Core.Name "discriminant"--_SwitchStatement_cases = Core.Name "cases"---- | A case clause in a switch statement-data SwitchCase =- SwitchCase {- -- | The test expression (Nothing for default)- switchCaseTest :: (Maybe Expression),- -- | The statements to execute- switchCaseConsequent :: [Statement]}- deriving (Eq, Ord, Read, Show)--_SwitchCase = Core.Name "hydra.typeScript.syntax.SwitchCase"--_SwitchCase_test = Core.Name "test"--_SwitchCase_consequent = Core.Name "consequent"---- | A for statement-data ForStatement =- ForStatement {- -- | Initialization- forStatementInit :: (Maybe ForInit),- -- | Test condition- forStatementTest :: (Maybe Expression),- -- | Update expression- forStatementUpdate :: (Maybe Expression),- forStatementBody :: Statement}- deriving (Eq, Ord, Read, Show)--_ForStatement = Core.Name "hydra.typeScript.syntax.ForStatement"--_ForStatement_init = Core.Name "init"--_ForStatement_test = Core.Name "test"--_ForStatement_update = Core.Name "update"--_ForStatement_body = Core.Name "body"---- | Initialization clause of a for statement-data ForInit =- ForInitVariable VariableDeclaration |- ForInitExpression Expression- deriving (Eq, Ord, Read, Show)--_ForInit = Core.Name "hydra.typeScript.syntax.ForInit"--_ForInit_variable = Core.Name "variable"--_ForInit_expression = Core.Name "expression"---- | A for-in statement-data ForInStatement =- ForInStatement {- forInStatementLeft :: ForInLeft,- forInStatementRight :: Expression,- forInStatementBody :: Statement}- deriving (Eq, Ord, Read, Show)--_ForInStatement = Core.Name "hydra.typeScript.syntax.ForInStatement"--_ForInStatement_left = Core.Name "left"--_ForInStatement_right = Core.Name "right"--_ForInStatement_body = Core.Name "body"---- | Left-hand side of a for-in or for-of statement-data ForInLeft =- ForInLeftVariable VariableDeclaration |- ForInLeftPattern Pattern- deriving (Eq, Ord, Read, Show)--_ForInLeft = Core.Name "hydra.typeScript.syntax.ForInLeft"--_ForInLeft_variable = Core.Name "variable"--_ForInLeft_pattern = Core.Name "pattern"---- | A for-of statement-data ForOfStatement =- ForOfStatement {- -- | Whether this is a for-await-of- forOfStatementAwait :: Bool,- forOfStatementLeft :: ForInLeft,- forOfStatementRight :: Expression,- forOfStatementBody :: Statement}- deriving (Eq, Ord, Read, Show)--_ForOfStatement = Core.Name "hydra.typeScript.syntax.ForOfStatement"--_ForOfStatement_await = Core.Name "await"--_ForOfStatement_left = Core.Name "left"--_ForOfStatement_right = Core.Name "right"--_ForOfStatement_body = Core.Name "body"---- | A while statement-data WhileStatement =- WhileStatement {- whileStatementTest :: Expression,- whileStatementBody :: Statement}- deriving (Eq, Ord, Read, Show)--_WhileStatement = Core.Name "hydra.typeScript.syntax.WhileStatement"--_WhileStatement_test = Core.Name "test"--_WhileStatement_body = Core.Name "body"---- | A do-while statement-data DoWhileStatement =- DoWhileStatement {- doWhileStatementBody :: Statement,- doWhileStatementTest :: Expression}- deriving (Eq, Ord, Read, Show)--_DoWhileStatement = Core.Name "hydra.typeScript.syntax.DoWhileStatement"--_DoWhileStatement_body = Core.Name "body"--_DoWhileStatement_test = Core.Name "test"---- | A try statement-data TryStatement =- TryStatement {- tryStatementBlock :: BlockStatement,- tryStatementHandler :: (Maybe CatchClause),- tryStatementFinalizer :: (Maybe BlockStatement)}- deriving (Eq, Ord, Read, Show)--_TryStatement = Core.Name "hydra.typeScript.syntax.TryStatement"--_TryStatement_block = Core.Name "block"--_TryStatement_handler = Core.Name "handler"--_TryStatement_finalizer = Core.Name "finalizer"---- | A catch clause-data CatchClause =- CatchClause {- -- | The catch parameter (can be omitted in ES2019+)- catchClauseParam :: (Maybe Pattern),- catchClauseBody :: BlockStatement}- deriving (Eq, Ord, Read, Show)--_CatchClause = Core.Name "hydra.typeScript.syntax.CatchClause"--_CatchClause_param = Core.Name "param"--_CatchClause_body = Core.Name "body"---- | A throw statement-newtype ThrowStatement =- ThrowStatement {- unThrowStatement :: Expression}- deriving (Eq, Ord, Read, Show)--_ThrowStatement = Core.Name "hydra.typeScript.syntax.ThrowStatement"---- | A return statement-type ReturnStatement = (Maybe Expression)--_ReturnStatement = Core.Name "hydra.typeScript.syntax.ReturnStatement"---- | A break statement-type BreakStatement = (Maybe Identifier)--_BreakStatement = Core.Name "hydra.typeScript.syntax.BreakStatement"---- | A continue statement-type ContinueStatement = (Maybe Identifier)--_ContinueStatement = Core.Name "hydra.typeScript.syntax.ContinueStatement"---- | A function declaration-data FunctionDeclaration =- FunctionDeclaration {- -- | Function name- functionDeclarationId :: Identifier,- -- | Function parameters- functionDeclarationParams :: [Pattern],- -- | Function body- functionDeclarationBody :: BlockStatement,- -- | Whether the function is async- functionDeclarationAsync :: Bool,- -- | Whether the function is a generator- functionDeclarationGenerator :: Bool}- deriving (Eq, Ord, Read, Show)--_FunctionDeclaration = Core.Name "hydra.typeScript.syntax.FunctionDeclaration"--_FunctionDeclaration_id = Core.Name "id"--_FunctionDeclaration_params = Core.Name "params"--_FunctionDeclaration_body = Core.Name "body"--_FunctionDeclaration_async = Core.Name "async"--_FunctionDeclaration_generator = Core.Name "generator"---- | A class declaration-data ClassDeclaration =- ClassDeclaration {- -- | Class name- classDeclarationId :: Identifier,- -- | Optional superclass- classDeclarationSuperClass :: (Maybe Expression),- -- | Class body- classDeclarationBody :: ClassBody}- deriving (Eq, Ord, Read, Show)--_ClassDeclaration = Core.Name "hydra.typeScript.syntax.ClassDeclaration"--_ClassDeclaration_id = Core.Name "id"--_ClassDeclaration_superClass = Core.Name "superClass"--_ClassDeclaration_body = Core.Name "body"---- | A class body-type ClassBody = [MethodDefinition]--_ClassBody = Core.Name "hydra.typeScript.syntax.ClassBody"---- | A method definition in a class-data MethodDefinition =- MethodDefinition {- -- | Method name- methodDefinitionKey :: Expression,- -- | Method function- methodDefinitionValue :: FunctionExpression,- -- | Method kind- methodDefinitionKind :: MethodKind,- -- | Whether the key is computed- methodDefinitionComputed :: Bool,- -- | Whether the method is static- methodDefinitionStatic :: Bool}- deriving (Eq, Ord, Read, Show)--_MethodDefinition = Core.Name "hydra.typeScript.syntax.MethodDefinition"--_MethodDefinition_key = Core.Name "key"--_MethodDefinition_value = Core.Name "value"--_MethodDefinition_kind = Core.Name "kind"--_MethodDefinition_computed = Core.Name "computed"--_MethodDefinition_static = Core.Name "static"---- | The kind of a class method-data MethodKind =- MethodKindConstructor |- MethodKindMethod |- MethodKindGet |- MethodKindSet- deriving (Eq, Ord, Read, Show)--_MethodKind = Core.Name "hydra.typeScript.syntax.MethodKind"--_MethodKind_constructor = Core.Name "constructor"--_MethodKind_method = Core.Name "method"--_MethodKind_get = Core.Name "get"--_MethodKind_set = Core.Name "set"---- | A TypeScript program (module)-data Program =- Program {- -- | The module items- programBody :: [ModuleItem],- -- | Whether this is a module or script- programSourceType :: SourceType}- deriving (Eq, Ord, Read, Show)--_Program = Core.Name "hydra.typeScript.syntax.Program"--_Program_body = Core.Name "body"--_Program_sourceType = Core.Name "sourceType"---- | Whether the program is a module or script-data SourceType =- SourceTypeModule |- SourceTypeScript- deriving (Eq, Ord, Read, Show)--_SourceType = Core.Name "hydra.typeScript.syntax.SourceType"--_SourceType_module = Core.Name "module"--_SourceType_script = Core.Name "script"---- | A top-level item in a module-data ModuleItem =- ModuleItemStatement Statement |- ModuleItemImport ImportDeclaration |- ModuleItemExport ExportDeclaration |- -- | A top-level interface declaration- ModuleItemInterface InterfaceDeclaration |- -- | A top-level type alias declaration- ModuleItemTypeAlias TypeAliasDeclaration- deriving (Eq, Ord, Read, Show)--_ModuleItem = Core.Name "hydra.typeScript.syntax.ModuleItem"--_ModuleItem_statement = Core.Name "statement"--_ModuleItem_import = Core.Name "import"--_ModuleItem_export = Core.Name "export"--_ModuleItem_interface = Core.Name "interface"--_ModuleItem_typeAlias = Core.Name "typeAlias"---- | An import declaration-data ImportDeclaration =- ImportDeclaration {- -- | What to import- importDeclarationSpecifiers :: [ImportClause],- -- | The module to import from- importDeclarationSource :: StringLiteral}- deriving (Eq, Ord, Read, Show)--_ImportDeclaration = Core.Name "hydra.typeScript.syntax.ImportDeclaration"--_ImportDeclaration_specifiers = Core.Name "specifiers"--_ImportDeclaration_source = Core.Name "source"---- | An import clause (named, default, or namespace import)-data ImportClause =- ImportClauseNamed ImportSpecifier |- ImportClauseDefault ImportDefaultSpecifier |- ImportClauseNamespace ImportNamespaceSpecifier- deriving (Eq, Ord, Read, Show)--_ImportClause = Core.Name "hydra.typeScript.syntax.ImportClause"--_ImportClause_named = Core.Name "named"--_ImportClause_default = Core.Name "default"--_ImportClause_namespace = Core.Name "namespace"---- | A named import specifier (import {x as y} from ...)-data ImportSpecifier =- ImportSpecifier {- importSpecifierImported :: Identifier,- importSpecifierLocal :: Identifier}- deriving (Eq, Ord, Read, Show)--_ImportSpecifier = Core.Name "hydra.typeScript.syntax.ImportSpecifier"--_ImportSpecifier_imported = Core.Name "imported"--_ImportSpecifier_local = Core.Name "local"---- | A default import specifier (import x from ...)-newtype ImportDefaultSpecifier =- ImportDefaultSpecifier {- unImportDefaultSpecifier :: Identifier}- deriving (Eq, Ord, Read, Show)--_ImportDefaultSpecifier = Core.Name "hydra.typeScript.syntax.ImportDefaultSpecifier"---- | A namespace import specifier (import * as x from ...)-newtype ImportNamespaceSpecifier =- ImportNamespaceSpecifier {- unImportNamespaceSpecifier :: Identifier}- deriving (Eq, Ord, Read, Show)--_ImportNamespaceSpecifier = Core.Name "hydra.typeScript.syntax.ImportNamespaceSpecifier"---- | An export declaration-data ExportDeclaration =- -- | Named exports (export {x, y as z})- ExportDeclarationNamed NamedExport |- -- | Default export (export default ...)- ExportDeclarationDefault Expression |- -- | Export a declaration (export const x = ...)- ExportDeclarationDeclaration Statement |- -- | Export all (export * from ...)- ExportDeclarationAll ExportAllDeclaration- deriving (Eq, Ord, Read, Show)--_ExportDeclaration = Core.Name "hydra.typeScript.syntax.ExportDeclaration"--_ExportDeclaration_named = Core.Name "named"--_ExportDeclaration_default = Core.Name "default"--_ExportDeclaration_declaration = Core.Name "declaration"--_ExportDeclaration_all = Core.Name "all"---- | Named exports (export {x, y as z})-data NamedExport =- NamedExport {- namedExportSpecifiers :: [ExportSpecifier],- namedExportSource :: (Maybe StringLiteral)}- deriving (Eq, Ord, Read, Show)--_NamedExport = Core.Name "hydra.typeScript.syntax.NamedExport"--_NamedExport_specifiers = Core.Name "specifiers"--_NamedExport_source = Core.Name "source"---- | Export all declaration (export * from ...)-data ExportAllDeclaration =- ExportAllDeclaration {- exportAllDeclarationExported :: (Maybe Identifier),- exportAllDeclarationSource :: StringLiteral}- deriving (Eq, Ord, Read, Show)--_ExportAllDeclaration = Core.Name "hydra.typeScript.syntax.ExportAllDeclaration"--_ExportAllDeclaration_exported = Core.Name "exported"--_ExportAllDeclaration_source = Core.Name "source"---- | An export specifier (x as y)-data ExportSpecifier =- ExportSpecifier {- exportSpecifierLocal :: Identifier,- exportSpecifierExported :: Identifier}- deriving (Eq, Ord, Read, Show)--_ExportSpecifier = Core.Name "hydra.typeScript.syntax.ExportSpecifier"--_ExportSpecifier_local = Core.Name "local"--_ExportSpecifier_exported = Core.Name "exported"---- | A binary operator-data BinaryOperator =- -- | +- BinaryOperatorAdd |- -- | -- BinaryOperatorSubtract |- -- | *- BinaryOperatorMultiply |- -- | /- BinaryOperatorDivide |- -- | %- BinaryOperatorModulo |- -- | **- BinaryOperatorExponentiate |- -- | ==- BinaryOperatorEqual |- -- | !=- BinaryOperatorNotEqual |- -- | ===- BinaryOperatorStrictEqual |- -- | !==- BinaryOperatorStrictNotEqual |- -- | <- BinaryOperatorLessThan |- -- | <=- BinaryOperatorLessThanOrEqual |- -- | >- BinaryOperatorGreaterThan |- -- | >=- BinaryOperatorGreaterThanOrEqual |- -- | &&- BinaryOperatorAnd |- -- | ||- BinaryOperatorOr |- -- | ??- BinaryOperatorNullishCoalescing |- -- | &- BinaryOperatorBitwiseAnd |- -- | |- BinaryOperatorBitwiseOr |- -- | ^- BinaryOperatorBitwiseXor |- -- | <<- BinaryOperatorLeftShift |- -- | >>- BinaryOperatorRightShift |- -- | >>>- BinaryOperatorUnsignedRightShift |- -- | in- BinaryOperatorIn |- -- | instanceof- BinaryOperatorInstanceof- deriving (Eq, Ord, Read, Show)--_BinaryOperator = Core.Name "hydra.typeScript.syntax.BinaryOperator"--_BinaryOperator_add = Core.Name "add"--_BinaryOperator_subtract = Core.Name "subtract"--_BinaryOperator_multiply = Core.Name "multiply"--_BinaryOperator_divide = Core.Name "divide"--_BinaryOperator_modulo = Core.Name "modulo"--_BinaryOperator_exponentiate = Core.Name "exponentiate"--_BinaryOperator_equal = Core.Name "equal"--_BinaryOperator_notEqual = Core.Name "notEqual"--_BinaryOperator_strictEqual = Core.Name "strictEqual"--_BinaryOperator_strictNotEqual = Core.Name "strictNotEqual"--_BinaryOperator_lessThan = Core.Name "lessThan"--_BinaryOperator_lessThanOrEqual = Core.Name "lessThanOrEqual"--_BinaryOperator_greaterThan = Core.Name "greaterThan"--_BinaryOperator_greaterThanOrEqual = Core.Name "greaterThanOrEqual"--_BinaryOperator_and = Core.Name "and"--_BinaryOperator_or = Core.Name "or"--_BinaryOperator_nullishCoalescing = Core.Name "nullishCoalescing"--_BinaryOperator_bitwiseAnd = Core.Name "bitwiseAnd"--_BinaryOperator_bitwiseOr = Core.Name "bitwiseOr"--_BinaryOperator_bitwiseXor = Core.Name "bitwiseXor"--_BinaryOperator_leftShift = Core.Name "leftShift"--_BinaryOperator_rightShift = Core.Name "rightShift"--_BinaryOperator_unsignedRightShift = Core.Name "unsignedRightShift"--_BinaryOperator_in = Core.Name "in"--_BinaryOperator_instanceof = Core.Name "instanceof"---- | A unary operator-data UnaryOperator =- -- | -- UnaryOperatorNegate |- -- | +- UnaryOperatorPlus |- -- | !- UnaryOperatorNot |- -- | ~- UnaryOperatorBitwiseNot |- -- | typeof- UnaryOperatorTypeof |- -- | void- UnaryOperatorVoid |- -- | delete- UnaryOperatorDelete |- -- | ++- UnaryOperatorIncrement |- -- | --- UnaryOperatorDecrement- deriving (Eq, Ord, Read, Show)--_UnaryOperator = Core.Name "hydra.typeScript.syntax.UnaryOperator"--_UnaryOperator_negate = Core.Name "negate"--_UnaryOperator_plus = Core.Name "plus"--_UnaryOperator_not = Core.Name "not"--_UnaryOperator_bitwiseNot = Core.Name "bitwiseNot"--_UnaryOperator_typeof = Core.Name "typeof"--_UnaryOperator_void = Core.Name "void"--_UnaryOperator_delete = Core.Name "delete"--_UnaryOperator_increment = Core.Name "increment"--_UnaryOperator_decrement = Core.Name "decrement"---- | An assignment operator-data AssignmentOperator =- -- | =- AssignmentOperatorAssign |- -- | +=- AssignmentOperatorAddAssign |- -- | -=- AssignmentOperatorSubtractAssign |- -- | *=- AssignmentOperatorMultiplyAssign |- -- | /=- AssignmentOperatorDivideAssign |- -- | %=- AssignmentOperatorModuloAssign |- -- | **=- AssignmentOperatorExponentiateAssign |- -- | <<=- AssignmentOperatorLeftShiftAssign |- -- | >>=- AssignmentOperatorRightShiftAssign |- -- | >>>=- AssignmentOperatorUnsignedRightShiftAssign |- -- | &=- AssignmentOperatorBitwiseAndAssign |- -- | |=- AssignmentOperatorBitwiseOrAssign |- -- | ^=- AssignmentOperatorBitwiseXorAssign |- -- | &&=- AssignmentOperatorAndAssign |- -- | ||=- AssignmentOperatorOrAssign |- -- | ??=- AssignmentOperatorNullishAssign- deriving (Eq, Ord, Read, Show)--_AssignmentOperator = Core.Name "hydra.typeScript.syntax.AssignmentOperator"--_AssignmentOperator_assign = Core.Name "assign"--_AssignmentOperator_addAssign = Core.Name "addAssign"--_AssignmentOperator_subtractAssign = Core.Name "subtractAssign"--_AssignmentOperator_multiplyAssign = Core.Name "multiplyAssign"--_AssignmentOperator_divideAssign = Core.Name "divideAssign"--_AssignmentOperator_moduloAssign = Core.Name "moduloAssign"--_AssignmentOperator_exponentiateAssign = Core.Name "exponentiateAssign"--_AssignmentOperator_leftShiftAssign = Core.Name "leftShiftAssign"--_AssignmentOperator_rightShiftAssign = Core.Name "rightShiftAssign"--_AssignmentOperator_unsignedRightShiftAssign = Core.Name "unsignedRightShiftAssign"--_AssignmentOperator_bitwiseAndAssign = Core.Name "bitwiseAndAssign"--_AssignmentOperator_bitwiseOrAssign = Core.Name "bitwiseOrAssign"--_AssignmentOperator_bitwiseXorAssign = Core.Name "bitwiseXorAssign"--_AssignmentOperator_andAssign = Core.Name "andAssign"--_AssignmentOperator_orAssign = Core.Name "orAssign"--_AssignmentOperator_nullishAssign = Core.Name "nullishAssign"---- | A TypeScript comment-data Comment =- -- | A single-line comment (// ...)- CommentLine String |- -- | A block comment, delimited by slash-star and star-slash- CommentBlock String |- -- | A documentation comment, delimited by slash-double-star and star-slash (JSDoc)- CommentDocumentation DocumentationComment- deriving (Eq, Ord, Read, Show)--_Comment = Core.Name "hydra.typeScript.syntax.Comment"--_Comment_line = Core.Name "line"--_Comment_block = Core.Name "block"--_Comment_documentation = Core.Name "documentation"---- | A documentation comment (JSDoc) with structured tags-data DocumentationComment =- DocumentationComment {- -- | The main description- documentationCommentDescription :: String,- -- | Documentation tags (@param, @returns, etc.)- documentationCommentTags :: [DocumentationTag]}- deriving (Eq, Ord, Read, Show)--_DocumentationComment = Core.Name "hydra.typeScript.syntax.DocumentationComment"--_DocumentationComment_description = Core.Name "description"--_DocumentationComment_tags = Core.Name "tags"---- | A documentation tag (@param, @returns, @type, etc.)-data DocumentationTag =- DocumentationTag {- -- | Tag name (param, returns, type, etc.)- documentationTagName :: String,- -- | Optional type expression- documentationTagType :: (Maybe TypeExpression),- -- | Optional parameter name (for @param)- documentationTagParamName :: (Maybe Identifier),- -- | Tag description- documentationTagDescription :: String}- deriving (Eq, Ord, Read, Show)--_DocumentationTag = Core.Name "hydra.typeScript.syntax.DocumentationTag"--_DocumentationTag_name = Core.Name "name"--_DocumentationTag_type = Core.Name "type"--_DocumentationTag_paramName = Core.Name "paramName"--_DocumentationTag_description = Core.Name "description"---- | A module item with optional documentation-data ModuleItemWithComments =- ModuleItemWithComments {- -- | The module item- moduleItemWithCommentsBody :: ModuleItem,- -- | Optional documentation comment- moduleItemWithCommentsComments :: (Maybe DocumentationComment)}- deriving (Eq, Ord, Read, Show)--_ModuleItemWithComments = Core.Name "hydra.typeScript.syntax.ModuleItemWithComments"--_ModuleItemWithComments_body = Core.Name "body"--_ModuleItemWithComments_comments = Core.Name "comments"---- | A statement with optional documentation-data StatementWithComments =- StatementWithComments {- -- | The statement- statementWithCommentsBody :: Statement,- -- | Optional documentation comment- statementWithCommentsComments :: (Maybe DocumentationComment)}- deriving (Eq, Ord, Read, Show)--_StatementWithComments = Core.Name "hydra.typeScript.syntax.StatementWithComments"--_StatementWithComments_body = Core.Name "body"--_StatementWithComments_comments = Core.Name "comments"---- | A function declaration with optional JSDoc-data FunctionDeclarationWithComments =- FunctionDeclarationWithComments {- -- | The function declaration- functionDeclarationWithCommentsBody :: FunctionDeclaration,- -- | Optional JSDoc comment- functionDeclarationWithCommentsComments :: (Maybe DocumentationComment)}- deriving (Eq, Ord, Read, Show)--_FunctionDeclarationWithComments = Core.Name "hydra.typeScript.syntax.FunctionDeclarationWithComments"--_FunctionDeclarationWithComments_body = Core.Name "body"--_FunctionDeclarationWithComments_comments = Core.Name "comments"---- | A class declaration with optional JSDoc-data ClassDeclarationWithComments =- ClassDeclarationWithComments {- -- | The class declaration- classDeclarationWithCommentsBody :: ClassDeclaration,- -- | Optional JSDoc comment- classDeclarationWithCommentsComments :: (Maybe DocumentationComment)}- deriving (Eq, Ord, Read, Show)--_ClassDeclarationWithComments = Core.Name "hydra.typeScript.syntax.ClassDeclarationWithComments"--_ClassDeclarationWithComments_body = Core.Name "body"--_ClassDeclarationWithComments_comments = Core.Name "comments"+-- | An element in an array expression+data ArrayElement =+ -- | A regular expression element+ ArrayElementExpression Expression |+ -- | A spread element ...x+ ArrayElementSpread SpreadElement |+ -- | An empty slot (elision)+ ArrayElementHole+ deriving (Eq, Ord, Read, Show)++_ArrayElement = Core.Name "hydra.typeScript.syntax.ArrayElement"++_ArrayElement_expression = Core.Name "expression"++_ArrayElement_spread = Core.Name "spread"++_ArrayElement_hole = Core.Name "hole"++-- | An array expression [a, b, c]+type ArrayExpression = [ArrayElement]++_ArrayExpression = Core.Name "hydra.typeScript.syntax.ArrayExpression"++-- | An array destructuring pattern [a, b, c]+type ArrayPattern = [Maybe Pattern]++_ArrayPattern = Core.Name "hydra.typeScript.syntax.ArrayPattern"++-- | An array type (T[])+newtype ArrayTypeExpression =+ ArrayTypeExpression {+ unArrayTypeExpression :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_ArrayTypeExpression = Core.Name "hydra.typeScript.syntax.ArrayTypeExpression"++-- | The body of an arrow function (expression or block)+data ArrowFunctionBody =+ ArrowFunctionBodyExpression Expression |+ ArrowFunctionBodyBlock BlockStatement+ deriving (Eq, Ord, Read, Show)++_ArrowFunctionBody = Core.Name "hydra.typeScript.syntax.ArrowFunctionBody"++_ArrowFunctionBody_expression = Core.Name "expression"++_ArrowFunctionBody_block = Core.Name "block"++-- | An arrow function expression+data ArrowFunctionExpression =+ ArrowFunctionExpression {+ -- | Function parameters+ arrowFunctionExpressionParams :: [Pattern],+ -- | Function body (expression or block)+ arrowFunctionExpressionBody :: ArrowFunctionBody,+ -- | Whether the function is async+ arrowFunctionExpressionAsync :: Bool}+ deriving (Eq, Ord, Read, Show)++_ArrowFunctionExpression = Core.Name "hydra.typeScript.syntax.ArrowFunctionExpression"++_ArrowFunctionExpression_params = Core.Name "params"++_ArrowFunctionExpression_body = Core.Name "body"++_ArrowFunctionExpression_async = Core.Name "async"++-- | A TypeScript `<expression> as <type>` cast+data AsExpression =+ AsExpression {+ -- | The expression being cast+ asExpressionExpression :: Expression,+ -- | The target type+ asExpressionType :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_AsExpression = Core.Name "hydra.typeScript.syntax.AsExpression"++_AsExpression_expression = Core.Name "expression"++_AsExpression_type = Core.Name "type"++-- | An assignment expression+data AssignmentExpression =+ AssignmentExpression {+ assignmentExpressionOperator :: AssignmentOperator,+ assignmentExpressionLeft :: Pattern,+ assignmentExpressionRight :: Expression}+ deriving (Eq, Ord, Read, Show)++_AssignmentExpression = Core.Name "hydra.typeScript.syntax.AssignmentExpression"++_AssignmentExpression_operator = Core.Name "operator"++_AssignmentExpression_left = Core.Name "left"++_AssignmentExpression_right = Core.Name "right"++-- | An assignment operator+data AssignmentOperator =+ -- | =+ AssignmentOperatorAssign |+ -- | +=+ AssignmentOperatorAddAssign |+ -- | -=+ AssignmentOperatorSubtractAssign |+ -- | *=+ AssignmentOperatorMultiplyAssign |+ -- | /=+ AssignmentOperatorDivideAssign |+ -- | %=+ AssignmentOperatorModuloAssign |+ -- | **=+ AssignmentOperatorExponentiateAssign |+ -- | <<=+ AssignmentOperatorLeftShiftAssign |+ -- | >>=+ AssignmentOperatorRightShiftAssign |+ -- | >>>=+ AssignmentOperatorUnsignedRightShiftAssign |+ -- | &=+ AssignmentOperatorBitwiseAndAssign |+ -- | |=+ AssignmentOperatorBitwiseOrAssign |+ -- | ^=+ AssignmentOperatorBitwiseXorAssign |+ -- | &&=+ AssignmentOperatorAndAssign |+ -- | ||=+ AssignmentOperatorOrAssign |+ -- | ??=+ AssignmentOperatorNullishAssign+ deriving (Eq, Ord, Read, Show)++_AssignmentOperator = Core.Name "hydra.typeScript.syntax.AssignmentOperator"++_AssignmentOperator_assign = Core.Name "assign"++_AssignmentOperator_addAssign = Core.Name "addAssign"++_AssignmentOperator_subtractAssign = Core.Name "subtractAssign"++_AssignmentOperator_multiplyAssign = Core.Name "multiplyAssign"++_AssignmentOperator_divideAssign = Core.Name "divideAssign"++_AssignmentOperator_moduloAssign = Core.Name "moduloAssign"++_AssignmentOperator_exponentiateAssign = Core.Name "exponentiateAssign"++_AssignmentOperator_leftShiftAssign = Core.Name "leftShiftAssign"++_AssignmentOperator_rightShiftAssign = Core.Name "rightShiftAssign"++_AssignmentOperator_unsignedRightShiftAssign = Core.Name "unsignedRightShiftAssign"++_AssignmentOperator_bitwiseAndAssign = Core.Name "bitwiseAndAssign"++_AssignmentOperator_bitwiseOrAssign = Core.Name "bitwiseOrAssign"++_AssignmentOperator_bitwiseXorAssign = Core.Name "bitwiseXorAssign"++_AssignmentOperator_andAssign = Core.Name "andAssign"++_AssignmentOperator_orAssign = Core.Name "orAssign"++_AssignmentOperator_nullishAssign = Core.Name "nullishAssign"++-- | A pattern with default value (param = default)+data AssignmentPattern =+ AssignmentPattern {+ assignmentPatternLeft :: Pattern,+ assignmentPatternRight :: Expression}+ deriving (Eq, Ord, Read, Show)++_AssignmentPattern = Core.Name "hydra.typeScript.syntax.AssignmentPattern"++_AssignmentPattern_left = Core.Name "left"++_AssignmentPattern_right = Core.Name "right"++-- | A binary operation expression+data BinaryExpression =+ BinaryExpression {+ binaryExpressionOperator :: BinaryOperator,+ binaryExpressionLeft :: Expression,+ binaryExpressionRight :: Expression}+ deriving (Eq, Ord, Read, Show)++_BinaryExpression = Core.Name "hydra.typeScript.syntax.BinaryExpression"++_BinaryExpression_operator = Core.Name "operator"++_BinaryExpression_left = Core.Name "left"++_BinaryExpression_right = Core.Name "right"++-- | A binary operator+data BinaryOperator =+ -- | ++ BinaryOperatorAdd |+ -- | -+ BinaryOperatorSubtract |+ -- | *+ BinaryOperatorMultiply |+ -- | /+ BinaryOperatorDivide |+ -- | %+ BinaryOperatorModulo |+ -- | **+ BinaryOperatorExponentiate |+ -- | ==+ BinaryOperatorEqual |+ -- | !=+ BinaryOperatorNotEqual |+ -- | ===+ BinaryOperatorStrictEqual |+ -- | !==+ BinaryOperatorStrictNotEqual |+ -- | <+ BinaryOperatorLessThan |+ -- | <=+ BinaryOperatorLessThanOrEqual |+ -- | >+ BinaryOperatorGreaterThan |+ -- | >=+ BinaryOperatorGreaterThanOrEqual |+ -- | &&+ BinaryOperatorAnd |+ -- | ||+ BinaryOperatorOr |+ -- | ??+ BinaryOperatorNullishCoalescing |+ -- | &+ BinaryOperatorBitwiseAnd |+ -- | |+ BinaryOperatorBitwiseOr |+ -- | ^+ BinaryOperatorBitwiseXor |+ -- | <<+ BinaryOperatorLeftShift |+ -- | >>+ BinaryOperatorRightShift |+ -- | >>>+ BinaryOperatorUnsignedRightShift |+ -- | in+ BinaryOperatorIn |+ -- | instanceof+ BinaryOperatorInstanceof+ deriving (Eq, Ord, Read, Show)++_BinaryOperator = Core.Name "hydra.typeScript.syntax.BinaryOperator"++_BinaryOperator_add = Core.Name "add"++_BinaryOperator_subtract = Core.Name "subtract"++_BinaryOperator_multiply = Core.Name "multiply"++_BinaryOperator_divide = Core.Name "divide"++_BinaryOperator_modulo = Core.Name "modulo"++_BinaryOperator_exponentiate = Core.Name "exponentiate"++_BinaryOperator_equal = Core.Name "equal"++_BinaryOperator_notEqual = Core.Name "notEqual"++_BinaryOperator_strictEqual = Core.Name "strictEqual"++_BinaryOperator_strictNotEqual = Core.Name "strictNotEqual"++_BinaryOperator_lessThan = Core.Name "lessThan"++_BinaryOperator_lessThanOrEqual = Core.Name "lessThanOrEqual"++_BinaryOperator_greaterThan = Core.Name "greaterThan"++_BinaryOperator_greaterThanOrEqual = Core.Name "greaterThanOrEqual"++_BinaryOperator_and = Core.Name "and"++_BinaryOperator_or = Core.Name "or"++_BinaryOperator_nullishCoalescing = Core.Name "nullishCoalescing"++_BinaryOperator_bitwiseAnd = Core.Name "bitwiseAnd"++_BinaryOperator_bitwiseOr = Core.Name "bitwiseOr"++_BinaryOperator_bitwiseXor = Core.Name "bitwiseXor"++_BinaryOperator_leftShift = Core.Name "leftShift"++_BinaryOperator_rightShift = Core.Name "rightShift"++_BinaryOperator_unsignedRightShift = Core.Name "unsignedRightShift"++_BinaryOperator_in = Core.Name "in"++_BinaryOperator_instanceof = Core.Name "instanceof"++-- | A block statement { ... }+type BlockStatement = [Statement]++_BlockStatement = Core.Name "hydra.typeScript.syntax.BlockStatement"++-- | A break statement+type BreakStatement = (Maybe Identifier)++_BreakStatement = Core.Name "hydra.typeScript.syntax.BreakStatement"++-- | A function call expression+data CallExpression =+ CallExpression {+ -- | The function being called+ callExpressionCallee :: Expression,+ -- | The arguments+ callExpressionArguments :: [Expression],+ -- | Whether using optional chaining (?.)+ callExpressionOptional :: Bool}+ deriving (Eq, Ord, Read, Show)++_CallExpression = Core.Name "hydra.typeScript.syntax.CallExpression"++_CallExpression_callee = Core.Name "callee"++_CallExpression_arguments = Core.Name "arguments"++_CallExpression_optional = Core.Name "optional"++-- | A catch clause+data CatchClause =+ CatchClause {+ -- | The catch parameter (can be omitted in ES2019+)+ catchClauseParam :: (Maybe Pattern),+ catchClauseBody :: BlockStatement}+ deriving (Eq, Ord, Read, Show)++_CatchClause = Core.Name "hydra.typeScript.syntax.CatchClause"++_CatchClause_param = Core.Name "param"++_CatchClause_body = Core.Name "body"++-- | A class body+type ClassBody = [MethodDefinition]++_ClassBody = Core.Name "hydra.typeScript.syntax.ClassBody"++-- | A class declaration+data ClassDeclaration =+ ClassDeclaration {+ -- | Class name+ classDeclarationId :: Identifier,+ -- | Optional superclass+ classDeclarationSuperClass :: (Maybe Expression),+ -- | Class body+ classDeclarationBody :: ClassBody}+ deriving (Eq, Ord, Read, Show)++_ClassDeclaration = Core.Name "hydra.typeScript.syntax.ClassDeclaration"++_ClassDeclaration_id = Core.Name "id"++_ClassDeclaration_superClass = Core.Name "superClass"++_ClassDeclaration_body = Core.Name "body"++-- | A class declaration with optional JSDoc+data ClassDeclarationWithComments =+ ClassDeclarationWithComments {+ -- | The class declaration+ classDeclarationWithCommentsBody :: ClassDeclaration,+ -- | Optional JSDoc comment+ classDeclarationWithCommentsComments :: (Maybe DocumentationComment)}+ deriving (Eq, Ord, Read, Show)++_ClassDeclarationWithComments = Core.Name "hydra.typeScript.syntax.ClassDeclarationWithComments"++_ClassDeclarationWithComments_body = Core.Name "body"++_ClassDeclarationWithComments_comments = Core.Name "comments"++-- | A TypeScript comment+data Comment =+ -- | A single-line comment (// ...)+ CommentLine String |+ -- | A block comment, delimited by slash-star and star-slash+ CommentBlock String |+ -- | A documentation comment, delimited by slash-double-star and star-slash (JSDoc)+ CommentDocumentation DocumentationComment+ deriving (Eq, Ord, Read, Show)++_Comment = Core.Name "hydra.typeScript.syntax.Comment"++_Comment_line = Core.Name "line"++_Comment_block = Core.Name "block"++_Comment_documentation = Core.Name "documentation"++-- | A conditional (ternary) expression: test ? consequent : alternate+data ConditionalExpression =+ ConditionalExpression {+ conditionalExpressionTest :: Expression,+ conditionalExpressionConsequent :: Expression,+ conditionalExpressionAlternate :: Expression}+ deriving (Eq, Ord, Read, Show)++_ConditionalExpression = Core.Name "hydra.typeScript.syntax.ConditionalExpression"++_ConditionalExpression_test = Core.Name "test"++_ConditionalExpression_consequent = Core.Name "consequent"++_ConditionalExpression_alternate = Core.Name "alternate"++-- | A continue statement+type ContinueStatement = (Maybe Identifier)++_ContinueStatement = Core.Name "hydra.typeScript.syntax.ContinueStatement"++-- | A do-while statement+data DoWhileStatement =+ DoWhileStatement {+ doWhileStatementBody :: Statement,+ doWhileStatementTest :: Expression}+ deriving (Eq, Ord, Read, Show)++_DoWhileStatement = Core.Name "hydra.typeScript.syntax.DoWhileStatement"++_DoWhileStatement_body = Core.Name "body"++_DoWhileStatement_test = Core.Name "test"++-- | A documentation comment (JSDoc) with structured tags+data DocumentationComment =+ DocumentationComment {+ -- | The main description+ documentationCommentDescription :: String,+ -- | Documentation tags (@param, @returns, etc.)+ documentationCommentTags :: [DocumentationTag]}+ deriving (Eq, Ord, Read, Show)++_DocumentationComment = Core.Name "hydra.typeScript.syntax.DocumentationComment"++_DocumentationComment_description = Core.Name "description"++_DocumentationComment_tags = Core.Name "tags"++-- | A documentation tag (@param, @returns, @type, etc.)+data DocumentationTag =+ DocumentationTag {+ -- | Tag name (param, returns, type, etc.)+ documentationTagName :: String,+ -- | Optional type expression+ documentationTagType :: (Maybe TypeExpression),+ -- | Optional parameter name (for @param)+ documentationTagParamName :: (Maybe Identifier),+ -- | Tag description+ documentationTagDescription :: String}+ deriving (Eq, Ord, Read, Show)++_DocumentationTag = Core.Name "hydra.typeScript.syntax.DocumentationTag"++_DocumentationTag_name = Core.Name "name"++_DocumentationTag_type = Core.Name "type"++_DocumentationTag_paramName = Core.Name "paramName"++_DocumentationTag_description = Core.Name "description"++-- | Export all declaration (export * from ...)+data ExportAllDeclaration =+ ExportAllDeclaration {+ exportAllDeclarationExported :: (Maybe Identifier),+ exportAllDeclarationSource :: StringLiteral}+ deriving (Eq, Ord, Read, Show)++_ExportAllDeclaration = Core.Name "hydra.typeScript.syntax.ExportAllDeclaration"++_ExportAllDeclaration_exported = Core.Name "exported"++_ExportAllDeclaration_source = Core.Name "source"++-- | An export declaration+data ExportDeclaration =+ -- | Named exports (export {x, y as z})+ ExportDeclarationNamed NamedExport |+ -- | Default export (export default ...)+ ExportDeclarationDefault Expression |+ -- | Export a declaration (export const x = ...)+ ExportDeclarationDeclaration Statement |+ -- | Export all (export * from ...)+ ExportDeclarationAll ExportAllDeclaration+ deriving (Eq, Ord, Read, Show)++_ExportDeclaration = Core.Name "hydra.typeScript.syntax.ExportDeclaration"++_ExportDeclaration_named = Core.Name "named"++_ExportDeclaration_default = Core.Name "default"++_ExportDeclaration_declaration = Core.Name "declaration"++_ExportDeclaration_all = Core.Name "all"++-- | An export specifier (x as y)+data ExportSpecifier =+ ExportSpecifier {+ exportSpecifierLocal :: Identifier,+ exportSpecifierExported :: Identifier}+ deriving (Eq, Ord, Read, Show)++_ExportSpecifier = Core.Name "hydra.typeScript.syntax.ExportSpecifier"++_ExportSpecifier_local = Core.Name "local"++_ExportSpecifier_exported = Core.Name "exported"++-- | A TypeScript expression+data Expression =+ -- | A simple identifier+ ExpressionIdentifier Identifier |+ -- | A literal value+ ExpressionLiteral Literal |+ -- | An array expression [a, b, c]+ ExpressionArray ArrayExpression |+ -- | An object expression {a: 1, b: 2}+ ExpressionObject ObjectExpression |+ -- | A function expression+ ExpressionFunction FunctionExpression |+ -- | An arrow function expression+ ExpressionArrow ArrowFunctionExpression |+ -- | A function call expression+ ExpressionCall CallExpression |+ -- | A member access expression (obj.prop or obj[prop])+ ExpressionMember MemberExpression |+ -- | A conditional (ternary) expression+ ExpressionConditional ConditionalExpression |+ -- | A binary operation expression+ ExpressionBinary BinaryExpression |+ -- | A unary operation expression+ ExpressionUnary UnaryExpression |+ -- | An assignment expression+ ExpressionAssignment AssignmentExpression |+ -- | A sequence expression (a, b, c)+ ExpressionSequence [Expression] |+ -- | The 'this' keyword+ ExpressionThis |+ -- | A 'new' expression+ ExpressionNew CallExpression |+ -- | A yield expression+ ExpressionYield (Maybe Expression) |+ -- | An await expression+ ExpressionAwait Expression |+ -- | A spread expression (...x)+ ExpressionSpread SpreadElement |+ -- | A parenthesized expression+ ExpressionParenthesized Expression |+ -- | A TypeScript type assertion `<expr> as <type>`+ ExpressionAsExpression AsExpression+ deriving (Eq, Ord, Read, Show)++_Expression = Core.Name "hydra.typeScript.syntax.Expression"++_Expression_identifier = Core.Name "identifier"++_Expression_literal = Core.Name "literal"++_Expression_array = Core.Name "array"++_Expression_object = Core.Name "object"++_Expression_function = Core.Name "function"++_Expression_arrow = Core.Name "arrow"++_Expression_call = Core.Name "call"++_Expression_member = Core.Name "member"++_Expression_conditional = Core.Name "conditional"++_Expression_binary = Core.Name "binary"++_Expression_unary = Core.Name "unary"++_Expression_assignment = Core.Name "assignment"++_Expression_sequence = Core.Name "sequence"++_Expression_this = Core.Name "this"++_Expression_new = Core.Name "new"++_Expression_yield = Core.Name "yield"++_Expression_await = Core.Name "await"++_Expression_spread = Core.Name "spread"++_Expression_parenthesized = Core.Name "parenthesized"++_Expression_asExpression = Core.Name "asExpression"++-- | Left-hand side of a for-in or for-of statement+data ForInLeft =+ ForInLeftVariable VariableDeclaration |+ ForInLeftPattern Pattern+ deriving (Eq, Ord, Read, Show)++_ForInLeft = Core.Name "hydra.typeScript.syntax.ForInLeft"++_ForInLeft_variable = Core.Name "variable"++_ForInLeft_pattern = Core.Name "pattern"++-- | A for-in statement+data ForInStatement =+ ForInStatement {+ forInStatementLeft :: ForInLeft,+ forInStatementRight :: Expression,+ forInStatementBody :: Statement}+ deriving (Eq, Ord, Read, Show)++_ForInStatement = Core.Name "hydra.typeScript.syntax.ForInStatement"++_ForInStatement_left = Core.Name "left"++_ForInStatement_right = Core.Name "right"++_ForInStatement_body = Core.Name "body"++-- | Initialization clause of a for statement+data ForInit =+ ForInitVariable VariableDeclaration |+ ForInitExpression Expression+ deriving (Eq, Ord, Read, Show)++_ForInit = Core.Name "hydra.typeScript.syntax.ForInit"++_ForInit_variable = Core.Name "variable"++_ForInit_expression = Core.Name "expression"++-- | A for-of statement+data ForOfStatement =+ ForOfStatement {+ -- | Whether this is a for-await-of+ forOfStatementAwait :: Bool,+ forOfStatementLeft :: ForInLeft,+ forOfStatementRight :: Expression,+ forOfStatementBody :: Statement}+ deriving (Eq, Ord, Read, Show)++_ForOfStatement = Core.Name "hydra.typeScript.syntax.ForOfStatement"++_ForOfStatement_await = Core.Name "await"++_ForOfStatement_left = Core.Name "left"++_ForOfStatement_right = Core.Name "right"++_ForOfStatement_body = Core.Name "body"++-- | A for statement+data ForStatement =+ ForStatement {+ -- | Initialization+ forStatementInit :: (Maybe ForInit),+ -- | Test condition+ forStatementTest :: (Maybe Expression),+ -- | Update expression+ forStatementUpdate :: (Maybe Expression),+ forStatementBody :: Statement}+ deriving (Eq, Ord, Read, Show)++_ForStatement = Core.Name "hydra.typeScript.syntax.ForStatement"++_ForStatement_init = Core.Name "init"++_ForStatement_test = Core.Name "test"++_ForStatement_update = Core.Name "update"++_ForStatement_body = Core.Name "body"++-- | A function declaration+data FunctionDeclaration =+ FunctionDeclaration {+ -- | Function name+ functionDeclarationId :: Identifier,+ -- | Function parameters+ functionDeclarationParams :: [Pattern],+ -- | Function body+ functionDeclarationBody :: BlockStatement,+ -- | Whether the function is async+ functionDeclarationAsync :: Bool,+ -- | Whether the function is a generator+ functionDeclarationGenerator :: Bool}+ deriving (Eq, Ord, Read, Show)++_FunctionDeclaration = Core.Name "hydra.typeScript.syntax.FunctionDeclaration"++_FunctionDeclaration_id = Core.Name "id"++_FunctionDeclaration_params = Core.Name "params"++_FunctionDeclaration_body = Core.Name "body"++_FunctionDeclaration_async = Core.Name "async"++_FunctionDeclaration_generator = Core.Name "generator"++-- | A function declaration with optional JSDoc+data FunctionDeclarationWithComments =+ FunctionDeclarationWithComments {+ -- | The function declaration+ functionDeclarationWithCommentsBody :: FunctionDeclaration,+ -- | Optional JSDoc comment+ functionDeclarationWithCommentsComments :: (Maybe DocumentationComment)}+ deriving (Eq, Ord, Read, Show)++_FunctionDeclarationWithComments = Core.Name "hydra.typeScript.syntax.FunctionDeclarationWithComments"++_FunctionDeclarationWithComments_body = Core.Name "body"++_FunctionDeclarationWithComments_comments = Core.Name "comments"++-- | A function expression+data FunctionExpression =+ FunctionExpression {+ -- | Optional function name+ functionExpressionId :: (Maybe Identifier),+ -- | Function parameters+ functionExpressionParams :: [Pattern],+ -- | Function body+ functionExpressionBody :: BlockStatement,+ -- | Whether the function is async+ functionExpressionAsync :: Bool,+ -- | Whether the function is a generator+ functionExpressionGenerator :: Bool}+ deriving (Eq, Ord, Read, Show)++_FunctionExpression = Core.Name "hydra.typeScript.syntax.FunctionExpression"++_FunctionExpression_id = Core.Name "id"++_FunctionExpression_params = Core.Name "params"++_FunctionExpression_body = Core.Name "body"++_FunctionExpression_async = Core.Name "async"++_FunctionExpression_generator = Core.Name "generator"++-- | A function type expression+data FunctionTypeExpression =+ FunctionTypeExpression {+ -- | Type parameters (generics)+ functionTypeExpressionTypeParameters :: [TypeParameter],+ -- | Parameter types+ functionTypeExpressionParameters :: [TypeExpression],+ -- | Return type+ functionTypeExpressionReturnType :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_FunctionTypeExpression = Core.Name "hydra.typeScript.syntax.FunctionTypeExpression"++_FunctionTypeExpression_typeParameters = Core.Name "typeParameters"++_FunctionTypeExpression_parameters = Core.Name "parameters"++_FunctionTypeExpression_returnType = Core.Name "returnType"++-- | A TypeScript identifier (variable, function, class name, etc.)+newtype Identifier =+ Identifier {+ unIdentifier :: String}+ deriving (Eq, Ord, Read, Show)++_Identifier = Core.Name "hydra.typeScript.syntax.Identifier"++-- | An if statement+data IfStatement =+ IfStatement {+ ifStatementTest :: Expression,+ ifStatementConsequent :: Statement,+ ifStatementAlternate :: (Maybe Statement)}+ deriving (Eq, Ord, Read, Show)++_IfStatement = Core.Name "hydra.typeScript.syntax.IfStatement"++_IfStatement_test = Core.Name "test"++_IfStatement_consequent = Core.Name "consequent"++_IfStatement_alternate = Core.Name "alternate"++-- | An import clause (named, default, or namespace import)+data ImportClause =+ ImportClauseNamed ImportSpecifier |+ ImportClauseDefault ImportDefaultSpecifier |+ ImportClauseNamespace ImportNamespaceSpecifier+ deriving (Eq, Ord, Read, Show)++_ImportClause = Core.Name "hydra.typeScript.syntax.ImportClause"++_ImportClause_named = Core.Name "named"++_ImportClause_default = Core.Name "default"++_ImportClause_namespace = Core.Name "namespace"++-- | An import declaration+data ImportDeclaration =+ ImportDeclaration {+ -- | What to import+ importDeclarationSpecifiers :: [ImportClause],+ -- | The module to import from+ importDeclarationSource :: StringLiteral}+ deriving (Eq, Ord, Read, Show)++_ImportDeclaration = Core.Name "hydra.typeScript.syntax.ImportDeclaration"++_ImportDeclaration_specifiers = Core.Name "specifiers"++_ImportDeclaration_source = Core.Name "source"++-- | A default import specifier (import x from ...)+newtype ImportDefaultSpecifier =+ ImportDefaultSpecifier {+ unImportDefaultSpecifier :: Identifier}+ deriving (Eq, Ord, Read, Show)++_ImportDefaultSpecifier = Core.Name "hydra.typeScript.syntax.ImportDefaultSpecifier"++-- | A namespace import specifier (import * as x from ...)+newtype ImportNamespaceSpecifier =+ ImportNamespaceSpecifier {+ unImportNamespaceSpecifier :: Identifier}+ deriving (Eq, Ord, Read, Show)++_ImportNamespaceSpecifier = Core.Name "hydra.typeScript.syntax.ImportNamespaceSpecifier"++-- | A named import specifier (import {x as y} from ...)+data ImportSpecifier =+ ImportSpecifier {+ importSpecifierImported :: Identifier,+ importSpecifierLocal :: Identifier}+ deriving (Eq, Ord, Read, Show)++_ImportSpecifier = Core.Name "hydra.typeScript.syntax.ImportSpecifier"++_ImportSpecifier_imported = Core.Name "imported"++_ImportSpecifier_local = Core.Name "local"++-- | A TypeScript interface declaration (interface Foo<T> extends Bar { ... })+data InterfaceDeclaration =+ InterfaceDeclaration {+ -- | Interface name+ interfaceDeclarationName :: Identifier,+ -- | Generic parameters+ interfaceDeclarationTypeParameters :: [TypeParameter],+ -- | Interfaces this one extends+ interfaceDeclarationExtends :: [TypeExpression],+ -- | Property signatures (the interface body)+ interfaceDeclarationMembers :: [PropertySignature]}+ deriving (Eq, Ord, Read, Show)++_InterfaceDeclaration = Core.Name "hydra.typeScript.syntax.InterfaceDeclaration"++_InterfaceDeclaration_name = Core.Name "name"++_InterfaceDeclaration_typeParameters = Core.Name "typeParameters"++_InterfaceDeclaration_extends = Core.Name "extends"++_InterfaceDeclaration_members = Core.Name "members"++-- | An intersection type (A & B & C)+type IntersectionTypeExpression = [TypeExpression]++_IntersectionTypeExpression = Core.Name "hydra.typeScript.syntax.IntersectionTypeExpression"++-- | A labeled statement+data LabeledStatement =+ LabeledStatement {+ labeledStatementLabel :: Identifier,+ labeledStatementBody :: Statement}+ deriving (Eq, Ord, Read, Show)++_LabeledStatement = Core.Name "hydra.typeScript.syntax.LabeledStatement"++_LabeledStatement_label = Core.Name "label"++_LabeledStatement_body = Core.Name "body"++-- | A literal value+data Literal =+ -- | A string literal+ LiteralString StringLiteral |+ -- | A numeric literal+ LiteralNumber NumericLiteral |+ -- | A boolean literal (true or false)+ LiteralBoolean Bool |+ -- | The null literal+ LiteralNull |+ -- | The undefined literal+ LiteralUndefined |+ -- | A BigInt literal (e.g., 123n)+ LiteralBigInt Integer |+ -- | A template literal+ LiteralTemplate TemplateLiteral+ deriving (Eq, Ord, Read, Show)++_Literal = Core.Name "hydra.typeScript.syntax.Literal"++_Literal_string = Core.Name "string"++_Literal_number = Core.Name "number"++_Literal_boolean = Core.Name "boolean"++_Literal_null = Core.Name "null"++_Literal_undefined = Core.Name "undefined"++_Literal_bigInt = Core.Name "bigInt"++_Literal_template = Core.Name "template"++-- | A member access expression+data MemberExpression =+ MemberExpression {+ -- | The object+ memberExpressionObject :: Expression,+ -- | The property+ memberExpressionProperty :: Expression,+ -- | Whether using bracket notation (obj[prop])+ memberExpressionComputed :: Bool,+ -- | Whether using optional chaining (?.)+ memberExpressionOptional :: Bool}+ deriving (Eq, Ord, Read, Show)++_MemberExpression = Core.Name "hydra.typeScript.syntax.MemberExpression"++_MemberExpression_object = Core.Name "object"++_MemberExpression_property = Core.Name "property"++_MemberExpression_computed = Core.Name "computed"++_MemberExpression_optional = Core.Name "optional"++-- | A method definition in a class+data MethodDefinition =+ MethodDefinition {+ -- | Method name+ methodDefinitionKey :: Expression,+ -- | Method function+ methodDefinitionValue :: FunctionExpression,+ -- | Method kind+ methodDefinitionKind :: MethodKind,+ -- | Whether the key is computed+ methodDefinitionComputed :: Bool,+ -- | Whether the method is static+ methodDefinitionStatic :: Bool}+ deriving (Eq, Ord, Read, Show)++_MethodDefinition = Core.Name "hydra.typeScript.syntax.MethodDefinition"++_MethodDefinition_key = Core.Name "key"++_MethodDefinition_value = Core.Name "value"++_MethodDefinition_kind = Core.Name "kind"++_MethodDefinition_computed = Core.Name "computed"++_MethodDefinition_static = Core.Name "static"++-- | The kind of a class method+data MethodKind =+ MethodKindConstructor |+ MethodKindMethod |+ MethodKindGet |+ MethodKindSet+ deriving (Eq, Ord, Read, Show)++_MethodKind = Core.Name "hydra.typeScript.syntax.MethodKind"++_MethodKind_constructor = Core.Name "constructor"++_MethodKind_method = Core.Name "method"++_MethodKind_get = Core.Name "get"++_MethodKind_set = Core.Name "set"++-- | A top-level item in a module+data ModuleItem =+ ModuleItemStatement Statement |+ ModuleItemImport ImportDeclaration |+ ModuleItemExport ExportDeclaration |+ -- | A top-level interface declaration+ ModuleItemInterface InterfaceDeclaration |+ -- | A top-level type alias declaration+ ModuleItemTypeAlias TypeAliasDeclaration+ deriving (Eq, Ord, Read, Show)++_ModuleItem = Core.Name "hydra.typeScript.syntax.ModuleItem"++_ModuleItem_statement = Core.Name "statement"++_ModuleItem_import = Core.Name "import"++_ModuleItem_export = Core.Name "export"++_ModuleItem_interface = Core.Name "interface"++_ModuleItem_typeAlias = Core.Name "typeAlias"++-- | A module item with optional documentation+data ModuleItemWithComments =+ ModuleItemWithComments {+ -- | The module item+ moduleItemWithCommentsBody :: ModuleItem,+ -- | Optional documentation comment+ moduleItemWithCommentsComments :: (Maybe DocumentationComment)}+ deriving (Eq, Ord, Read, Show)++_ModuleItemWithComments = Core.Name "hydra.typeScript.syntax.ModuleItemWithComments"++_ModuleItemWithComments_body = Core.Name "body"++_ModuleItemWithComments_comments = Core.Name "comments"++-- | Named exports (export {x, y as z})+data NamedExport =+ NamedExport {+ namedExportSpecifiers :: [ExportSpecifier],+ namedExportSource :: (Maybe StringLiteral)}+ deriving (Eq, Ord, Read, Show)++_NamedExport = Core.Name "hydra.typeScript.syntax.NamedExport"++_NamedExport_specifiers = Core.Name "specifiers"++_NamedExport_source = Core.Name "source"++-- | A numeric literal (integer or floating-point)+data NumericLiteral =+ -- | An integer literal+ NumericLiteralInteger I.Int64 |+ -- | A floating-point literal+ NumericLiteralFloat Double+ deriving (Eq, Ord, Read, Show)++_NumericLiteral = Core.Name "hydra.typeScript.syntax.NumericLiteral"++_NumericLiteral_integer = Core.Name "integer"++_NumericLiteral_float = Core.Name "float"++-- | An object expression {a: 1, b: 2}+type ObjectExpression = [Property]++_ObjectExpression = Core.Name "hydra.typeScript.syntax.ObjectExpression"++-- | An object destructuring pattern {a, b: c}+data ObjectPattern =+ ObjectPattern {+ -- | The property patterns+ objectPatternProperties :: [ObjectPatternProperty]}+ deriving (Eq, Ord, Read, Show)++_ObjectPattern = Core.Name "hydra.typeScript.syntax.ObjectPattern"++_ObjectPattern_properties = Core.Name "properties"++-- | A property in an object pattern+data ObjectPatternProperty =+ ObjectPatternPropertyProperty Property |+ ObjectPatternPropertyRest RestElement+ deriving (Eq, Ord, Read, Show)++_ObjectPatternProperty = Core.Name "hydra.typeScript.syntax.ObjectPatternProperty"++_ObjectPatternProperty_property = Core.Name "property"++_ObjectPatternProperty_rest = Core.Name "rest"++-- | An object type with property signatures+type ObjectTypeExpression = [PropertySignature]++_ObjectTypeExpression = Core.Name "hydra.typeScript.syntax.ObjectTypeExpression"++-- | A parameterized type (e.g., Array<T>, Map<K, V>)+data ParameterizedTypeExpression =+ ParameterizedTypeExpression {+ parameterizedTypeExpressionBase :: TypeExpression,+ parameterizedTypeExpressionArguments :: [TypeExpression]}+ deriving (Eq, Ord, Read, Show)++_ParameterizedTypeExpression = Core.Name "hydra.typeScript.syntax.ParameterizedTypeExpression"++_ParameterizedTypeExpression_base = Core.Name "base"++_ParameterizedTypeExpression_arguments = Core.Name "arguments"++-- | A binding pattern (for destructuring)+data Pattern =+ -- | A simple identifier binding+ PatternIdentifier Identifier |+ -- | An object destructuring pattern+ PatternObject ObjectPattern |+ -- | An array destructuring pattern+ PatternArray ArrayPattern |+ -- | A pattern with default value+ PatternAssignment AssignmentPattern |+ -- | A rest element (...x)+ PatternRest RestElement |+ -- | A pattern with a TypeScript type annotation (`x: T`)+ PatternTyped TypedPattern+ deriving (Eq, Ord, Read, Show)++_Pattern = Core.Name "hydra.typeScript.syntax.Pattern"++_Pattern_identifier = Core.Name "identifier"++_Pattern_object = Core.Name "object"++_Pattern_array = Core.Name "array"++_Pattern_assignment = Core.Name "assignment"++_Pattern_rest = Core.Name "rest"++_Pattern_typed = Core.Name "typed"++-- | A TypeScript program (module)+data Program =+ Program {+ -- | The module items+ programBody :: [ModuleItem],+ -- | Whether this is a module or script+ programSourceType :: SourceType}+ deriving (Eq, Ord, Read, Show)++_Program = Core.Name "hydra.typeScript.syntax.Program"++_Program_body = Core.Name "body"++_Program_sourceType = Core.Name "sourceType"++-- | A property in an object expression+data Property =+ Property {+ -- | Property key (identifier, literal, or computed)+ propertyKey :: Expression,+ -- | Property value+ propertyValue :: Expression,+ -- | Property kind (init, get, set)+ propertyKind :: PropertyKind,+ -- | Whether the key is computed [expr]+ propertyComputed :: Bool,+ -- | Whether using shorthand syntax {x} for {x: x}+ propertyShorthand :: Bool}+ deriving (Eq, Ord, Read, Show)++_Property = Core.Name "hydra.typeScript.syntax.Property"++_Property_key = Core.Name "key"++_Property_value = Core.Name "value"++_Property_kind = Core.Name "kind"++_Property_computed = Core.Name "computed"++_Property_shorthand = Core.Name "shorthand"++-- | The kind of an object property+data PropertyKind =+ -- | A normal property initialization+ PropertyKindInit |+ -- | A getter+ PropertyKindGet |+ -- | A setter+ PropertyKindSet+ deriving (Eq, Ord, Read, Show)++_PropertyKind = Core.Name "hydra.typeScript.syntax.PropertyKind"++_PropertyKind_init = Core.Name "init"++_PropertyKind_get = Core.Name "get"++_PropertyKind_set = Core.Name "set"++-- | A property signature in an object type+data PropertySignature =+ PropertySignature {+ -- | Property name+ propertySignatureName :: Identifier,+ -- | Property type+ propertySignatureType :: TypeExpression,+ -- | Whether the property is optional+ propertySignatureOptional :: Bool,+ -- | Whether the property is readonly+ propertySignatureReadonly :: Bool,+ -- | Optional JSDoc documentation comment to emit above this property+ propertySignatureComments :: (Maybe DocumentationComment)}+ deriving (Eq, Ord, Read, Show)++_PropertySignature = Core.Name "hydra.typeScript.syntax.PropertySignature"++_PropertySignature_name = Core.Name "name"++_PropertySignature_type = Core.Name "type"++_PropertySignature_optional = Core.Name "optional"++_PropertySignature_readonly = Core.Name "readonly"++_PropertySignature_comments = Core.Name "comments"++-- | A qualified name like 'module.submodule.name'+type QualifiedName = [Identifier]++_QualifiedName = Core.Name "hydra.typeScript.syntax.QualifiedName"++-- | A rest element pattern (...x)+newtype RestElement =+ RestElement {+ unRestElement :: Pattern}+ deriving (Eq, Ord, Read, Show)++_RestElement = Core.Name "hydra.typeScript.syntax.RestElement"++-- | A return statement+type ReturnStatement = (Maybe Expression)++_ReturnStatement = Core.Name "hydra.typeScript.syntax.ReturnStatement"++-- | Whether the program is a module or script+data SourceType =+ SourceTypeModule |+ SourceTypeScript+ deriving (Eq, Ord, Read, Show)++_SourceType = Core.Name "hydra.typeScript.syntax.SourceType"++_SourceType_module = Core.Name "module"++_SourceType_script = Core.Name "script"++-- | A spread element (...x)+newtype SpreadElement =+ SpreadElement {+ unSpreadElement :: Expression}+ deriving (Eq, Ord, Read, Show)++_SpreadElement = Core.Name "hydra.typeScript.syntax.SpreadElement"++-- | A TypeScript statement+data Statement =+ -- | An expression statement+ StatementExpression Expression |+ -- | A block statement+ StatementBlock BlockStatement |+ -- | An empty statement (;)+ StatementEmpty |+ -- | A debugger statement+ StatementDebugger |+ -- | A return statement+ StatementReturn ReturnStatement |+ -- | A break statement+ StatementBreak BreakStatement |+ -- | A continue statement+ StatementContinue ContinueStatement |+ -- | An if statement+ StatementIf IfStatement |+ -- | A switch statement+ StatementSwitch SwitchStatement |+ -- | A throw statement+ StatementThrow ThrowStatement |+ -- | A try statement+ StatementTry TryStatement |+ -- | A while statement+ StatementWhile WhileStatement |+ -- | A do-while statement+ StatementDoWhile DoWhileStatement |+ -- | A for statement+ StatementFor ForStatement |+ -- | A for-in statement+ StatementForIn ForInStatement |+ -- | A for-of statement+ StatementForOf ForOfStatement |+ -- | A variable declaration+ StatementVariableDeclaration VariableDeclaration |+ -- | A function declaration+ StatementFunctionDeclaration FunctionDeclaration |+ -- | A class declaration+ StatementClassDeclaration ClassDeclaration |+ -- | A labeled statement+ StatementLabeled LabeledStatement+ deriving (Eq, Ord, Read, Show)++_Statement = Core.Name "hydra.typeScript.syntax.Statement"++_Statement_expression = Core.Name "expression"++_Statement_block = Core.Name "block"++_Statement_empty = Core.Name "empty"++_Statement_debugger = Core.Name "debugger"++_Statement_return = Core.Name "return"++_Statement_break = Core.Name "break"++_Statement_continue = Core.Name "continue"++_Statement_if = Core.Name "if"++_Statement_switch = Core.Name "switch"++_Statement_throw = Core.Name "throw"++_Statement_try = Core.Name "try"++_Statement_while = Core.Name "while"++_Statement_doWhile = Core.Name "doWhile"++_Statement_for = Core.Name "for"++_Statement_forIn = Core.Name "forIn"++_Statement_forOf = Core.Name "forOf"++_Statement_variableDeclaration = Core.Name "variableDeclaration"++_Statement_functionDeclaration = Core.Name "functionDeclaration"++_Statement_classDeclaration = Core.Name "classDeclaration"++_Statement_labeled = Core.Name "labeled"++-- | A statement with optional documentation+data StatementWithComments =+ StatementWithComments {+ -- | The statement+ statementWithCommentsBody :: Statement,+ -- | Optional documentation comment+ statementWithCommentsComments :: (Maybe DocumentationComment)}+ deriving (Eq, Ord, Read, Show)++_StatementWithComments = Core.Name "hydra.typeScript.syntax.StatementWithComments"++_StatementWithComments_body = Core.Name "body"++_StatementWithComments_comments = Core.Name "comments"++-- | A string literal with quote style+data StringLiteral =+ StringLiteral {+ -- | The string value+ stringLiteralValue :: String,+ -- | Whether to use single quotes (true) or double quotes (false)+ stringLiteralSingleQuote :: Bool}+ deriving (Eq, Ord, Read, Show)++_StringLiteral = Core.Name "hydra.typeScript.syntax.StringLiteral"++_StringLiteral_value = Core.Name "value"++_StringLiteral_singleQuote = Core.Name "singleQuote"++-- | A case clause in a switch statement+data SwitchCase =+ SwitchCase {+ -- | The test expression (Nothing for default)+ switchCaseTest :: (Maybe Expression),+ -- | The statements to execute+ switchCaseConsequent :: [Statement]}+ deriving (Eq, Ord, Read, Show)++_SwitchCase = Core.Name "hydra.typeScript.syntax.SwitchCase"++_SwitchCase_test = Core.Name "test"++_SwitchCase_consequent = Core.Name "consequent"++-- | A switch statement+data SwitchStatement =+ SwitchStatement {+ switchStatementDiscriminant :: Expression,+ switchStatementCases :: [SwitchCase]}+ deriving (Eq, Ord, Read, Show)++_SwitchStatement = Core.Name "hydra.typeScript.syntax.SwitchStatement"++_SwitchStatement_discriminant = Core.Name "discriminant"++_SwitchStatement_cases = Core.Name "cases"++-- | A static part of a template literal+data TemplateElement =+ TemplateElement {+ -- | The raw string value+ templateElementValue :: String,+ -- | Whether this is the last element+ templateElementTail :: Bool}+ deriving (Eq, Ord, Read, Show)++_TemplateElement = Core.Name "hydra.typeScript.syntax.TemplateElement"++_TemplateElement_value = Core.Name "value"++_TemplateElement_tail = Core.Name "tail"++-- | A template literal (backtick string with interpolations)+data TemplateLiteral =+ TemplateLiteral {+ -- | The static string parts+ templateLiteralQuasis :: [TemplateElement],+ -- | The interpolated expressions+ templateLiteralExpressions :: [Expression]}+ deriving (Eq, Ord, Read, Show)++_TemplateLiteral = Core.Name "hydra.typeScript.syntax.TemplateLiteral"++_TemplateLiteral_quasis = Core.Name "quasis"++_TemplateLiteral_expressions = Core.Name "expressions"++-- | A throw statement+newtype ThrowStatement =+ ThrowStatement {+ unThrowStatement :: Expression}+ deriving (Eq, Ord, Read, Show)++_ThrowStatement = Core.Name "hydra.typeScript.syntax.ThrowStatement"++-- | A try statement+data TryStatement =+ TryStatement {+ tryStatementBlock :: BlockStatement,+ tryStatementHandler :: (Maybe CatchClause),+ tryStatementFinalizer :: (Maybe BlockStatement)}+ deriving (Eq, Ord, Read, Show)++_TryStatement = Core.Name "hydra.typeScript.syntax.TryStatement"++_TryStatement_block = Core.Name "block"++_TryStatement_handler = Core.Name "handler"++_TryStatement_finalizer = Core.Name "finalizer"++-- | A tuple type ([A, B] or readonly [A, B])+type TupleTypeExpression = [TypeExpression]++_TupleTypeExpression = Core.Name "hydra.typeScript.syntax.TupleTypeExpression"++-- | A TypeScript type alias declaration (type Foo<T> = ...)+data TypeAliasDeclaration =+ TypeAliasDeclaration {+ -- | Alias name+ typeAliasDeclarationName :: Identifier,+ -- | Generic parameters+ typeAliasDeclarationTypeParameters :: [TypeParameter],+ -- | The right-hand-side type+ typeAliasDeclarationType :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_TypeAliasDeclaration = Core.Name "hydra.typeScript.syntax.TypeAliasDeclaration"++_TypeAliasDeclaration_name = Core.Name "name"++_TypeAliasDeclaration_typeParameters = Core.Name "typeParameters"++_TypeAliasDeclaration_type = Core.Name "type"++-- | A type annotation (for JSDoc comments or TypeScript)+newtype TypeAnnotation =+ TypeAnnotation {+ unTypeAnnotation :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_TypeAnnotation = Core.Name "hydra.typeScript.syntax.TypeAnnotation"++-- | A type expression+data TypeExpression =+ -- | A named type (e.g., 'string', 'number', 'MyClass')+ TypeExpressionIdentifier Identifier |+ -- | A literal type (e.g., 'hello', 42)+ TypeExpressionLiteral Literal |+ -- | An array type+ TypeExpressionArray ArrayTypeExpression |+ -- | A function type+ TypeExpressionFunction FunctionTypeExpression |+ -- | An object type+ TypeExpressionObject ObjectTypeExpression |+ -- | A tuple type (readonly [A, B, C])+ TypeExpressionTuple TupleTypeExpression |+ -- | A union type (A | B)+ TypeExpressionUnion UnionTypeExpression |+ -- | An intersection type (A & B)+ TypeExpressionIntersection IntersectionTypeExpression |+ -- | A parameterized type (e.g., Array<T>, Map<K, V>)+ TypeExpressionParameterized ParameterizedTypeExpression |+ -- | An optional type (T | undefined or T?)+ TypeExpressionOptional TypeExpression |+ -- | A readonly modifier (readonly T[], readonly [A, B])+ TypeExpressionReadonly TypeExpression |+ -- | The 'any' type+ TypeExpressionAny |+ -- | The 'unknown' type+ TypeExpressionUnknown |+ -- | The 'void' type+ TypeExpressionVoid |+ -- | The 'never' type+ TypeExpressionNever+ deriving (Eq, Ord, Read, Show)++_TypeExpression = Core.Name "hydra.typeScript.syntax.TypeExpression"++_TypeExpression_identifier = Core.Name "identifier"++_TypeExpression_literal = Core.Name "literal"++_TypeExpression_array = Core.Name "array"++_TypeExpression_function = Core.Name "function"++_TypeExpression_object = Core.Name "object"++_TypeExpression_tuple = Core.Name "tuple"++_TypeExpression_union = Core.Name "union"++_TypeExpression_intersection = Core.Name "intersection"++_TypeExpression_parameterized = Core.Name "parameterized"++_TypeExpression_optional = Core.Name "optional"++_TypeExpression_readonly = Core.Name "readonly"++_TypeExpression_any = Core.Name "any"++_TypeExpression_unknown = Core.Name "unknown"++_TypeExpression_void = Core.Name "void"++_TypeExpression_never = Core.Name "never"++-- | A type parameter (generic)+data TypeParameter =+ TypeParameter {+ -- | Parameter name+ typeParameterName :: Identifier,+ -- | Optional constraint (extends clause)+ typeParameterConstraint :: (Maybe TypeExpression),+ -- | Optional default type+ typeParameterDefault :: (Maybe TypeExpression)}+ deriving (Eq, Ord, Read, Show)++_TypeParameter = Core.Name "hydra.typeScript.syntax.TypeParameter"++_TypeParameter_name = Core.Name "name"++_TypeParameter_constraint = Core.Name "constraint"++_TypeParameter_default = Core.Name "default"++-- | A pattern with a TypeScript type annotation (`x: T`)+data TypedPattern =+ TypedPattern {+ -- | The underlying binding pattern+ typedPatternPattern :: Pattern,+ -- | The TypeScript type annotation+ typedPatternType :: TypeExpression}+ deriving (Eq, Ord, Read, Show)++_TypedPattern = Core.Name "hydra.typeScript.syntax.TypedPattern"++_TypedPattern_pattern = Core.Name "pattern"++_TypedPattern_type = Core.Name "type"++-- | A unary operation expression+data UnaryExpression =+ UnaryExpression {+ unaryExpressionOperator :: UnaryOperator,+ unaryExpressionArgument :: Expression,+ -- | Whether the operator is prefix (true) or postfix (false)+ unaryExpressionPrefix :: Bool}+ deriving (Eq, Ord, Read, Show)++_UnaryExpression = Core.Name "hydra.typeScript.syntax.UnaryExpression"++_UnaryExpression_operator = Core.Name "operator"++_UnaryExpression_argument = Core.Name "argument"++_UnaryExpression_prefix = Core.Name "prefix"++-- | A unary operator+data UnaryOperator =+ -- | -+ UnaryOperatorNegate |+ -- | ++ UnaryOperatorPlus |+ -- | !+ UnaryOperatorNot |+ -- | ~+ UnaryOperatorBitwiseNot |+ -- | typeof+ UnaryOperatorTypeof |+ -- | void+ UnaryOperatorVoid |+ -- | delete+ UnaryOperatorDelete |+ -- | +++ UnaryOperatorIncrement |+ -- | --+ UnaryOperatorDecrement+ deriving (Eq, Ord, Read, Show)++_UnaryOperator = Core.Name "hydra.typeScript.syntax.UnaryOperator"++_UnaryOperator_negate = Core.Name "negate"++_UnaryOperator_plus = Core.Name "plus"++_UnaryOperator_not = Core.Name "not"++_UnaryOperator_bitwiseNot = Core.Name "bitwiseNot"++_UnaryOperator_typeof = Core.Name "typeof"++_UnaryOperator_void = Core.Name "void"++_UnaryOperator_delete = Core.Name "delete"++_UnaryOperator_increment = Core.Name "increment"++_UnaryOperator_decrement = Core.Name "decrement"++-- | A union type (A | B | C)+type UnionTypeExpression = [TypeExpression]++_UnionTypeExpression = Core.Name "hydra.typeScript.syntax.UnionTypeExpression"++-- | A variable declaration (var, let, const)+data VariableDeclaration =+ VariableDeclaration {+ variableDeclarationKind :: VariableKind,+ variableDeclarationDeclarations :: [VariableDeclarator]}+ deriving (Eq, Ord, Read, Show)++_VariableDeclaration = Core.Name "hydra.typeScript.syntax.VariableDeclaration"++_VariableDeclaration_kind = Core.Name "kind"++_VariableDeclaration_declarations = Core.Name "declarations"++-- | A variable declarator (id = init)+data VariableDeclarator =+ VariableDeclarator {+ variableDeclaratorId :: Pattern,+ variableDeclaratorInit :: (Maybe Expression)}+ deriving (Eq, Ord, Read, Show)++_VariableDeclarator = Core.Name "hydra.typeScript.syntax.VariableDeclarator"++_VariableDeclarator_id = Core.Name "id"++_VariableDeclarator_init = Core.Name "init"++-- | The kind of variable declaration+data VariableKind =+ VariableKindVar |+ VariableKindLet |+ VariableKindConst+ deriving (Eq, Ord, Read, Show)++_VariableKind = Core.Name "hydra.typeScript.syntax.VariableKind"++_VariableKind_var = Core.Name "var"++_VariableKind_let = Core.Name "let"++_VariableKind_const = Core.Name "const"++-- | A while statement+data WhileStatement =+ WhileStatement {+ whileStatementTest :: Expression,+ whileStatementBody :: Statement}+ deriving (Eq, Ord, Read, Show)++_WhileStatement = Core.Name "hydra.typeScript.syntax.WhileStatement"++_WhileStatement_test = Core.Name "test"++_WhileStatement_body = Core.Name "body"