packages feed

hydra-java 0.18.0 → 0.18.1

raw patch · 6 files changed

+315/−51 lines, 6 filesdep ~hydra-jvmdep ~hydra-kernelPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: hydra-jvm, hydra-kernel

API changes (from Hackage documentation)

- Hydra.Java.Coder: dedupBindings :: Set Name -> [Binding] -> [Binding]
+ Hydra.Java.Coder: dedupBindingsWithBody :: Set Name -> [Binding] -> Term -> ([Binding], Term)
+ Hydra.Java.Decode.Gradle: antlrConfig :: Graph -> Term -> Either DecodingError AntlrConfig
+ Hydra.Java.Decode.Gradle: gradleBuildConfiguration :: Graph -> Term -> Either DecodingError GradleBuildConfiguration
+ Hydra.Java.Encode.Gradle: antlrConfig :: AntlrConfig -> Term
+ Hydra.Java.Encode.Gradle: gradleBuildConfiguration :: GradleBuildConfiguration -> Term
- Hydra.Java.Coder: bindingsToStatements :: JavaEnvironment -> [Binding] -> InferenceContext -> Graph -> Either Error ([BlockStatement], JavaEnvironment)
+ Hydra.Java.Coder: bindingsToStatements :: JavaEnvironment -> [Binding] -> Term -> InferenceContext -> Graph -> Either Error (([BlockStatement], JavaEnvironment), Term)

Files

CHANGELOG.md view
@@ -15,6 +15,144 @@  --- +## [0.18.1] - 2026-11-20++Textual-sources release: the whole `hydra-kernel` is now authored as textual `.hydra` files, including the+primitive library `hydra.core.lib.*`, and the textual syntax gains the sugar, parsers, and tooling needed to carry it.+Also lands translingual tail-call optimization for the Scala and TypeScript coders, named provisions and+primitive parameter names, the property-graph encoding of term graphs, and a large body of host-specific bootstrap+and CI fixes.++### Breaking changes++- **Type renames** ([#837](https://github.com/CategoricalData/hydra/issues/837)): four types whose variant names clashed with other kernel types are renamed.+  Any code, JSON, or `.hydra` text that names them must be updated.+  - `hydra.core.regex.QuantifierRange` is now `hydra.core.regex.Range`.+  - `hydra.ext.azure.dtld.SchemaPrimitive` is now `PrimitiveSchema`, and `SchemaComplex` is now `ComplexSchema`.+  - `hydra.rust.syntax.TypePath` is now `PathType`.+- **New primitive signature syntax in `.hydra`** ([#837](https://github.com/CategoricalData/hydra/issues/837)): a `primitive` definition names its parameters,+  `primitive ifElse ∀x.(p: boolean, t: lazy x, f: lazy x) : x`, instead of the old arrow chain+  (`primitive ifElse : ∀t. boolean → lazy t → lazy t → t`).+  Parameter and result descriptions move into `@param` and `@return` doc lines.+  The arrow-chain form is for `term` signatures only.+- **Raw `case` keyword is now `cases`** ([#810](https://github.com/CategoricalData/hydra/issues/810)): the textual-syntax case statement keyword matches `Term.cases`.+- **`hydra.core.json.bootstrap` is now `hydra.core.bootstrap`** ([#791](https://github.com/CategoricalData/hydra/issues/791)).+- **`and` and `or` are lazy in their second operand** ([#802](https://github.com/CategoricalData/hydra/issues/802)): both are marked lazy, mirroring `ifElse`, and the+  Java and Python hosts add thunk-accepting overloads.++### Highlights++- **The whole kernel is `.hydra`-sourced** ([#837](https://github.com/CategoricalData/hydra/issues/837), [#711](https://github.com/CategoricalData/hydra/issues/711), [#710](https://github.com/CategoricalData/hydra/issues/710), [#497](https://github.com/CategoricalData/hydra/issues/497)):+  every `hydra-kernel` module, including all `hydra.core.lib.*` primitive modules and the test modules, is sourced from+  `packages/hydra-kernel/src/main/hydra/**/*.hydra`; Phase 1 reads that text instead of the Haskell DSL.+  The Haskell DSL modules remain as a twin that must stay byte-identical (the dual-edit rule).+  `bin/verify-hydra-sources.sh` is the identity guard (it is not run by CI),+  and `heads/haskell/bin/print-hydra-sources.sh` regenerates the text from the DSL.+  A package may textually source only modules it owns.+- **Named primitive parameters** ([#837](https://github.com/CategoricalData/hydra/issues/837)): all 292 primitives print with named parameters and `@param`/`@return`+  descriptions, carried through the kernel metadata.+- **`parseModules`** ([#842](https://github.com/CategoricalData/hydra/issues/842)): `hydra.core.parse.packaging.parseModules` reads `.hydra` text into modules and is the+  supported entry point for downstream code generation from textual sources+  (see `docs/recipes/downstream-codegen.md`).+- **Kernel JSON on the classpath** ([#786](https://github.com/CategoricalData/hydra/issues/786)): the published `hydra-kernel` jar bundles the kernel's JSON modules, so+  Java downstream projects no longer need a source checkout to load the kernel.+- **Tail-call optimization on more hosts** ([#709](https://github.com/CategoricalData/hydra/issues/709)): shared `TcoLoopPlan`/`TcoStep` kernel types and a+  `lowerSelfTailRecursion` pass, consumed by the new Scala (`@tailrec`) and TypeScript lowerings.+- **Named provisions** ([#725](https://github.com/CategoricalData/hydra/issues/725)): primitives and tests carry named requirements and recommendations,+  spec prose is ported into module and primitive metadata, and the generated spec pages render comments and lifecycle.+- **Term graphs as property graphs** ([#738](https://github.com/CategoricalData/hydra/issues/738)): `hydra.pg.subtermGraph` encodes a term graph as a property graph,+  with specification pages (`docs/specification/pg/subterm-graph.md`).++### New features++- **Textual syntax sugar** ([#809](https://github.com/CategoricalData/hydra/issues/809), [#811](https://github.com/CategoricalData/hydra/issues/811)): nominal construction and elimination sugar+  (`record`/`inject`/`wrap {...}`, `project`/`unwrap [...]`), applied `case` sugar, and monadic `do` blocks+  (`do either`, `do list`, `do optional`, `do effect`).+- **Source spans** ([#815](https://github.com/CategoricalData/hydra/issues/815)): the parsers track source offsets and record term spans through the new+  `hydra.core.positions` module; spans are round-trip-exempt surface trivia.+- **Parsers and printers** ([#710](https://github.com/CategoricalData/hydra/issues/710), [#497](https://github.com/CategoricalData/hydra/issues/497)): `hydra.core.parse.core` (term, type, and type scheme parser),+  parse/print for packaging, doc-comment parsing into `EntityMetadata`, and `line:col` parse errors.+  A signature-level `lazy` keyword round-trips `Parameter.isLazy` ([#800](https://github.com/CategoricalData/hydra/issues/800)),+  and raw `cases(...)` accepts the `_` default field ([#822](https://github.com/CategoricalData/hydra/issues/822)).+- **JSON** ([#776](https://github.com/CategoricalData/hydra/issues/776), [#777](https://github.com/CategoricalData/hydra/issues/777)): `JsonWriterOptions` and `printJsonWith` for configurable JSON layout,+  and `\uXXXX` escapes with surrogate pairs in the JSON parser.+- **Error printers** ([#778](https://github.com/CategoricalData/hydra/issues/778)): real printers for inference and extraction errors replace placeholder constants.+- **Spec generator** ([#723](https://github.com/CategoricalData/hydra/issues/723)): the `hydra.RegenerateSpec` driver and `bin/regenerate-spec.sh` now exist,+  and the module-reference pages under `docs/specification/` are generated by them.+  The module reference is still partial (only the primitives and four kernel type modules are covered).+  Primitive pages show named signatures (`isAlpha(char: int32) → boolean`) with Parameters and Returns entries,+  type pages list fields and variants, and headings use local names so in-page links work.+- **Build system in Hydra** ([#788](https://github.com/CategoricalData/hydra/issues/788)): the lib-pass partition (`isLibModule`, `partitionLibModules`) moves into the+  translingual `hydra.build.modules`, consumed by the Java, Scala, and Haskell drivers.+- **Bootstrap matrix** ([#769](https://github.com/CategoricalData/hydra/issues/769)): `docs/bootstrap-matrix.md` persists the N×N cross-host generation matrix.+- **Build slot tooling** ([#730](https://github.com/CategoricalData/hydra/issues/730), [#814](https://github.com/CategoricalData/hydra/issues/814)): `with-stack-slot.sh` gains a second lane, priorities, pinning, and a memory guard,+  and scripts that run bare `stack` re-exec under it.+- **CI** ([#821](https://github.com/CategoricalData/hydra/issues/821), [#700](https://github.com/CategoricalData/hydra/issues/700)): an inference-cost guard (time and peak memory) and a dedicated haskell-tests job.++### Bug fixes++- [#799](https://github.com/CategoricalData/hydra/issues/799): shadow-renaming of variables was decoupled across three layers (`unshadowVariables`,+  `analyzeFunctionTermWithGather`, the Java coder's `dedupBindings`).+- [#803](https://github.com/CategoricalData/hydra/issues/803), [#804](https://github.com/CategoricalData/hydra/issues/804), [#805](https://github.com/CategoricalData/hydra/issues/805): printed import aliases and bare names now round-trip.+- [#798](https://github.com/CategoricalData/hydra/issues/798): a `Term.variable` encodes and decodes as `{"@var": "name"}` at any JSON position.+- [#817](https://github.com/CategoricalData/hydra/issues/817): `printFloat32`/`printFloat64` for subnormals in the Common Lisp, Emacs Lisp, and Clojure hosts.+- [#779](https://github.com/CategoricalData/hydra/issues/779): the Python coder no longer breaks on nested module names.+- [#752](https://github.com/CategoricalData/hydra/issues/752): `PropertyType.required` was hardcoded to true.+- [#751](https://github.com/CategoricalData/hydra/issues/751), [#832](https://github.com/CategoricalData/hydra/issues/832), [#838](https://github.com/CategoricalData/hydra/issues/838): the SHACL serializer emits blank nodes for anonymous shape references, RDF lists for+  `sh:in`/`sh:and`/`sh:or`/`sh:xone`, definition references under `sh:node`/`sh:not`/`sh:and`/`sh:or`/`sh:xone`,+  and qualified value shapes with their counts.+- [#754](https://github.com/CategoricalData/hydra/issues/754): IRI strings are escaped in the rdf4j serializer.+- [#748](https://github.com/CategoricalData/hydra/issues/748), [#781](https://github.com/CategoricalData/hydra/issues/781): `inferInGraphContext` routes through the discharge-and-finalize tail, and+  `inferModules` seeds its graph from both universe and target modules.+- [#764](https://github.com/CategoricalData/hydra/issues/764): `refreshModule` fails loudly on dropped bindings; binding dedup and primitive shadowing are fixed.+- [#649](https://github.com/CategoricalData/hydra/issues/649): the Python coder merges a type and a term that share a module path.+- [#780](https://github.com/CategoricalData/hydra/issues/780): generated Javadoc escapes backslashes and `*/`.+- [#782](https://github.com/CategoricalData/hydra/issues/782): simple Unicode case mapping on the Common Lisp and Emacs Lisp hosts.+- [#775](https://github.com/CategoricalData/hydra/issues/775): `mapSet` is unregistered on hosts that never implemented it.+- [#289](https://github.com/CategoricalData/hydra/issues/289), [#762](https://github.com/CategoricalData/hydra/issues/762), [#801](https://github.com/CategoricalData/hydra/issues/801): stale post-rename paths in the Go overlay imports, the TypeScript bootstrap driver,+  and the Common Lisp and Emacs Lisp test loaders.+- [#741](https://github.com/CategoricalData/hydra/issues/741), [#747](https://github.com/CategoricalData/hydra/issues/747), [#757](https://github.com/CategoricalData/hydra/issues/757), [#771](https://github.com/CategoricalData/hydra/issues/771), [#787](https://github.com/CategoricalData/hydra/issues/787), [#823](https://github.com/CategoricalData/hydra/issues/823), [#831](https://github.com/CategoricalData/hydra/issues/831): sync and cold-seed fixes+  (target assembly order, `hostOverrides` immunity, overlay hashing in the freshness gate, downstream assembly after+  overlay re-apply, the generator stamp's coder-copy component).+- [#736](https://github.com/CategoricalData/hydra/issues/736): CI pins JDK 11 for the Haskell job after `ubuntu-latest` moved to JDK 25.+- [#755](https://github.com/CategoricalData/hydra/issues/755): effects fixes (Type.effect encoder arms, Python `map_list`, Emacs Lisp loading).+- [#812](https://github.com/CategoricalData/hydra/issues/812): the Clojure/Scheme `testEnv` redirect applies to generated test trees only.+- [#768](https://github.com/CategoricalData/hydra/issues/768): the cold-seed driver step fails fast when its local fallback cannot succeed.+- [#825](https://github.com/CategoricalData/hydra/issues/825): `dist/haskell/hydra-kernel` is reseeded when stale relative to `dist/json`.+- [#839](https://github.com/CategoricalData/hydra/issues/839): the assemble freshness gate refreshes a stale input digest after a rebase instead of failing, and never rewrites a current one.+- [#826](https://github.com/CategoricalData/hydra/issues/826): Lisp coders reference nullary effect primitives by call.+- [#827](https://github.com/CategoricalData/hydra/issues/827): overlay variant-order tables are checked against `model.json`.+- [#772](https://github.com/CategoricalData/hydra/issues/772), [#756](https://github.com/CategoricalData/hydra/issues/756): several silent failures in the sync scripts and vitest/Scala drivers now fail loudly.++### Improvements++- Python DSL phantom types are threaded through combinator signatures ([#731](https://github.com/CategoricalData/hydra/issues/731), [#732](https://github.com/CategoricalData/hydra/issues/732), [#818](https://github.com/CategoricalData/hydra/issues/818)).+- Hackage and PyPI batch publish sets are derived from the package registry ([#573](https://github.com/CategoricalData/hydra/issues/573), [#577](https://github.com/CategoricalData/hydra/issues/577)).+- Pre-existing namespace leftovers from the 0.18.0 rename are cleaned up in Lisp, Scala, TypeScript, and Java bootstrap+  drivers ([#767](https://github.com/CategoricalData/hydra/issues/767), [#729](https://github.com/CategoricalData/hydra/issues/729)).+- `/bootstrap`, `/sync-default`, `/test`, and the pre-push gate default to Java and Python, with Haskell opt-in+  ([#773](https://github.com/CategoricalData/hydra/issues/773)); the bootstrap demo holds the build slot only for its own `stack` calls ([#797](https://github.com/CategoricalData/hydra/issues/797)).+- `bin/sync.sh` prints per-phase timing ([#824](https://github.com/CategoricalData/hydra/issues/824)), and the CI Haskell job is split to stay within the runner time limit.+- `with-stack-slot.sh` fails fast on low disk before a build ([#789](https://github.com/CategoricalData/hydra/issues/789)).+- `bin/verify-hydra-sources.sh --dsl` runs the dual-edit guard in reverse, regenerating from the Haskell DSL twins and+  comparing with the committed JSON ([#837](https://github.com/CategoricalData/hydra/issues/837)).+- `docs/hydra-lexicon.txt` prints primitives with named parameters, matching the generated spec pages+  ([#723](https://github.com/CategoricalData/hydra/issues/723)).++### Documentation++- `docs/specification/syntax.md` gains the module-level grammar, doc comments, import aliasing, file layout,+  `@param`/`@return`, and the named-parameter primitive signature.+- The kernel README, `docs/implementation.md`, `docs/build-system.md`, and the test and primitive recipes describe the+  `.hydra` sources and the dual-edit rule.+- The hand-written primitive spec pages use the `hydra.core.lib.*` namespace.+- Recipes and READMEs document the decoder/encoder fixpoint guard ([#760](https://github.com/CategoricalData/hydra/issues/760)), keeping derived modules out of+  re-inference ([#758](https://github.com/CategoricalData/hydra/issues/758)), the hydra-ext coder testing pattern ([#699](https://github.com/CategoricalData/hydra/issues/699)), scripts with no automated caller+  ([#714](https://github.com/CategoricalData/hydra/issues/714)), overlay-versus-prune ordering ([#645](https://github.com/CategoricalData/hydra/issues/645)), the Phase 1 memory envelope ([#592](https://github.com/CategoricalData/hydra/issues/592)),+  and the Rust coder's home in `hydra-rust` ([#382](https://github.com/CategoricalData/hydra/issues/382)).++---+ ## [0.18.0] - 2026-09-29  Module-naming systematization release: every kernel and package module moves onto a uniform@@ -48,9 +186,11 @@   JSON-Schema/Avro/GraphQL/GraphSON/Protobuf coders (extended integer widths, map-key handling), the   kernel's encode/decode generators (reversed type-parameter order on 2+-param polymorphic types), and   the Python coder (silently dropping a module's types when types and terms share a file path).-- **Self-hosted specification docs** ([#723](https://github.com/CategoricalData/hydra/issues/723)):-  the module-reference pages under `docs/specification/` are now generated directly from the kernel-  (`bin/regenerate-spec.sh`) via a new metadata-only doc coder, rather than hand-maintained.+- **Specification-docs generator, kernel side** ([#723](https://github.com/CategoricalData/hydra/issues/723)):+  a new metadata-only doc coder (`generateModuleDoc`) and `hydra.markdown` model, the translingual core+  for generating the module-reference pages under `docs/specification/`. *Erratum:* the Java driver that+  `bin/regenerate-spec.sh` invokes (`hydra.RegenerateSpec`) did not ship in 0.18.0, so the pages are still+  hand-maintained; the driver is pending under #723.  ### New features @@ -58,7 +198,7 @@   suite covering the minimal-core grammar (literals, classes, quantifiers, alternation, anchors,   grouping) across all 9 hosts. - **[#723](https://github.com/CategoricalData/hydra/issues/723)** `hydra.markdown` type module and-  `generateModuleDoc`, the metadata-only doc coder backing the self-generated spec pages.+  `generateModuleDoc`, the metadata-only doc coder intended to back self-generated spec pages. - **[#382](https://github.com/CategoricalData/hydra/issues/382)** the Rust coder is split out of   `hydra-ext` into its own first-class `hydra-rust` package. 
hydra-java.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           hydra-java-version:        0.18.0+version:        0.18.1 synopsis:       Hydra's Java coder: emit Java 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". Java support for Hydra category:       Data@@ -28,9 +28,11 @@ library   exposed-modules:       Hydra.Java.Coder+      Hydra.Java.Decode.Gradle       Hydra.Java.Dsl.Environment       Hydra.Java.Dsl.Language       Hydra.Java.Dsl.Syntax+      Hydra.Java.Encode.Gradle       Hydra.Java.Environment       Hydra.Java.Gradle       Hydra.Java.Language@@ -46,7 +48,7 @@   build-depends:       base >=4.19.0 && <4.22     , containers >=0.6.7 && <0.8-    , hydra-jvm ==0.18.0-    , hydra-kernel ==0.18.0+    , hydra-jvm ==0.18.1+    , hydra-kernel ==0.18.1     , scientific >=0.3.7 && <0.4   default-language: Haskell2010
src/main/haskell/Hydra/Java/Coder.hs view
@@ -299,12 +299,14 @@                     Util.qualifiedNameLocal = sanitized})       in (CoreNames.nameToFilePath Util.CaseConventionCamel Util.CaseConventionPascal (File.FileExtension "java") unq) -bindingsToStatements :: JavaEnvironment.JavaEnvironment -> [Model.Binding] -> Typing.InferenceContext -> Graph.Graph -> Either Errors.Error ([Syntax.BlockStatement], JavaEnvironment.JavaEnvironment)-bindingsToStatements env bindings cx g0 =+bindingsToStatements :: JavaEnvironment.JavaEnvironment -> [Model.Binding] -> Model.Term -> Typing.InferenceContext -> Graph.Graph -> Either Errors.Error (([Syntax.BlockStatement], JavaEnvironment.JavaEnvironment), Model.Term)+bindingsToStatements env bindings body0 cx g0 =        let aliases = JavaEnvironment.javaEnvironmentAliases env           g = JavaEnvironment.javaEnvironmentGraph env-          flatBindings = dedupBindings (JavaEnvironment.aliasesInScopeJavaVars aliases) (flattenBindings bindings)+          dedupResult = dedupBindingsWithBody (JavaEnvironment.aliasesInScopeJavaVars aliases) (flattenBindings bindings) body0+          flatBindings = Pairs.first dedupResult+          body = Pairs.second dedupResult           gExtended =                   Scoping.extendGraphForLet (\g1 -> \b -> Logic.ifElse (Predicates.isComplexBinding g1 b) (Just (Model.TermLiteral (Model.LiteralBoolean True))) Nothing) g (Model.Let {                     Model.letBindings = flatBindings,@@ -347,7 +349,7 @@                   JavaEnvironment.JavaEnvironment {                     JavaEnvironment.javaEnvironmentAliases = aliasesExtended,                     JavaEnvironment.javaEnvironmentGraph = gExtended}-      in (Logic.ifElse (Lists.isEmpty bindings) (Right ([], envExtended)) (Eithers.bind (Eithers.mapList (\names -> Eithers.bind (Eithers.mapList (\n -> toDeclInit aliasesExtended gExtended recursiveVars flatBindings n cx g) names) (\inits -> Eithers.bind (Eithers.mapList (\n -> toDeclStatement envExtended aliasesExtended gExtended recursiveVars thunkedVars flatBindings n cx g) names) (\decls -> Right (Lists.concat2 (Optionals.givens inits) decls)))) sorted) (\groups -> Right (Lists.concat groups, envExtended))))+      in (Logic.ifElse (Lists.isEmpty bindings) (Right (([], envExtended), body)) (Eithers.bind (Eithers.mapList (\names -> Eithers.bind (Eithers.mapList (\n -> toDeclInit aliasesExtended gExtended recursiveVars flatBindings n cx g) names) (\inits -> Eithers.bind (Eithers.mapList (\n -> toDeclStatement envExtended aliasesExtended gExtended recursiveVars thunkedVars flatBindings n cx g) names) (\decls -> Right (Lists.concat2 (Optionals.givens inits) decls)))) sorted) (\groups -> Right ((Lists.concat groups, envExtended), body))))  boundTypeVariables :: Model.Type -> [Model.Name] boundTypeVariables typ =@@ -880,21 +882,21 @@                     Lists.map (\ft ->                       let fname = Model.fieldTypeName ft                           fnameStr = Model.unName fname-                          typeArgs = Lists.map (\tp -> Utils.typeParameterToTypeArgument tp) tparams+                          typeArgs2 = Lists.map (\tp -> Utils.typeParameterToTypeArgument tp) tparams                           varName = Utils.variantClassName False elName fname                           varNameStr = Syntax.unIdentifier (Utils.nameToJavaName aliases varName)                           varLocalStr = Utils.sanitizeJavaName (Util.qualifiedNameLocal (CoreNames.qualifyName varName))                           linkVarNameStr = Strings.concat2 (Strings.concat2 elNameStr ".") varLocalStr-                          varRef = Utils.javaClassTypeToJavaType (Utils.nameToJavaClassType aliases False typeArgs varName Nothing)+                          varRef = Utils.javaClassTypeToJavaType (Utils.nameToJavaClassType aliases False typeArgs2 varName Nothing)                           param = Utils.javaTypeToJavaFormalParameter varRef (Model.Name "instance")-                          resultR = Utils.javaTypeToJavaResult (Syntax.TypeReference Utils.visitorTypeVariable)+                          resultR2 = Utils.javaTypeToJavaResult (Syntax.TypeReference Utils.visitorTypeVariable)                           comment =                                   Strings.concat [                                     "Visit the {@link ",                                     linkVarNameStr,                                     "} case."]                       in (comment, (Utils.interfaceMethodDeclaration [] [] JavaNames.visitMethodName [-                        param] resultR Nothing))) fields+                        param] resultR2 Nothing))) fields             visitorBody =                     Syntax.InterfaceBody (Lists.map (\p -> withInterfaceCommentString (Pairs.first p) (Pairs.second p)) visitorMethods)             visitor =@@ -1024,9 +1026,9 @@           _ -> Nothing) Nothing)))))) Nothing       _ -> Nothing -dedupBindings :: S.Set Model.Name -> [Model.Binding] -> [Model.Binding]-dedupBindings inScope bs =-    Optionals.withDefault [] (Optionals.map (\p ->+dedupBindingsWithBody :: S.Set Model.Name -> [Model.Binding] -> Model.Term -> ([Model.Binding], Model.Term)+dedupBindingsWithBody inScope bs body =+    Optionals.withDefault ([], body) (Optionals.map (\p ->       let b = Pairs.first p           rest = Pairs.second p           name = Model.bindingName b@@ -1038,10 +1040,16 @@                       Model.bindingName = (Model.bindingName b2),                       Model.bindingTerm = (Variables.substituteVariables subst (Model.bindingTerm b2)),                       Model.bindingTypeScheme = (Model.bindingTypeScheme b2)}) rest-        in (Lists.cons (Model.Binding {-          Model.bindingName = newName,-          Model.bindingTerm = (Model.bindingTerm b),-          Model.bindingTypeScheme = (Model.bindingTypeScheme b)}) (dedupBindings (Sets.insert newName inScope) rest2))) (Lists.cons b (dedupBindings (Sets.insert name inScope) rest)))) (Lists.uncons bs))+            body2 = Variables.substituteVariables subst body+            recResult = dedupBindingsWithBody (Sets.insert newName inScope) rest2 body2+        in (+          Lists.cons (Model.Binding {+            Model.bindingName = newName,+            Model.bindingTerm = (Model.bindingTerm b),+            Model.bindingTypeScheme = (Model.bindingTypeScheme b)}) (Pairs.first recResult),+          (Pairs.second recResult))) (+        let recResult = dedupBindingsWithBody (Sets.insert name inScope) rest body+        in (Lists.cons b (Pairs.first recResult), (Pairs.second recResult))))) (Lists.uncons bs))  detectAccumulatorUnification :: [Model.Type] -> Model.Type -> [Model.Name] -> M.Map Model.Name Model.Type detectAccumulatorUnification doms cod tparams =@@ -1259,10 +1267,11 @@                       let bindings = Typing.functionStructureBindings fs                           innerBody = Typing.functionStructureBody fs                           env3 = Typing.functionStructureEnvironment fs-                      in (Eithers.bind (bindingsToStatements env3 bindings cx g) (\bindResult ->-                        let bindingStmts = Pairs.first bindResult-                            env4 = Pairs.second bindResult-                        in (Eithers.bind (encodeTerm env4 innerBody cx g) (\jbody ->+                      in (Eithers.bind (bindingsToStatements env3 bindings innerBody cx g) (\bindResult ->+                        let bindingStmts = Pairs.first (Pairs.first bindResult)+                            env4 = Pairs.second (Pairs.first bindResult)+                            innerBody2 = Pairs.second bindResult+                        in (Eithers.bind (encodeTerm env4 innerBody2 cx g) (\jbody ->                           let lam1 =                                   Logic.ifElse (Lists.isEmpty bindings) (Utils.javaLambda lambdaVar jbody) (                                     let returnSt = Syntax.BlockStatementStatement (Utils.javaReturnStatement (Just jbody))@@ -1530,10 +1539,11 @@                         JavaEnvironment.JavaEnvironment {                           JavaEnvironment.javaEnvironmentAliases = aliases2,                           JavaEnvironment.javaEnvironmentGraph = (JavaEnvironment.javaEnvironmentGraph env2)}-            in (Eithers.bind (bindingsToStatements env2WithTypeParams bindings cx g) (\bindResult ->-              let bindingStmts = Pairs.first bindResult-                  env3 = Pairs.second bindResult-              in (Eithers.bind (Logic.ifElse (Maps.isEmpty overgenSubst) (Right body) (applyOvergenSubstToTermAnnotations overgenSubst body cx g)) (\body_ ->+            in (Eithers.bind (bindingsToStatements env2WithTypeParams bindings body cx g) (\bindResult ->+              let bindingStmts = Pairs.first (Pairs.first bindResult)+                  env3 = Pairs.second (Pairs.first bindResult)+                  body2 = Pairs.second bindResult+              in (Eithers.bind (Logic.ifElse (Maps.isEmpty overgenSubst) (Right body2) (applyOvergenSubstToTermAnnotations overgenSubst body2 cx g)) (\body_ ->                 let annotatedBody = propagateTypesInAppChain fixedCod fixedCod body_                 in (Eithers.bind (Eithers.mapList (\pair -> Eithers.bind (encodeType aliases2 Sets.empty (Pairs.first pair) cx g) (\jdom -> Right (Utils.javaTypeToJavaFormalParameter jdom (Pairs.second pair)))) (Lists.zip fixedDoms params)) (\jformalParams -> Eithers.bind (encodeType aliases2 Sets.empty fixedCod cx g) (\jcod ->                   let result = Utils.javaTypeToJavaResult jcod@@ -1600,10 +1610,11 @@         Model.TermLet v0 ->           let bindings = Model.letBindings v0               body = Model.letBody v0-          in (Logic.ifElse (Lists.isEmpty bindings) (encodeTermInternal env anns [] body cx g) (Eithers.bind (bindingsToStatements env bindings cx g) (\bindResult ->-            let bindingStmts = Pairs.first bindResult-                env2 = Pairs.second bindResult-            in (Eithers.bind (encodeTermInternal env2 anns [] body cx g) (\jbody ->+          in (Logic.ifElse (Lists.isEmpty bindings) (encodeTermInternal env anns [] body cx g) (Eithers.bind (bindingsToStatements env bindings body cx g) (\bindResult ->+            let bindingStmts = Pairs.first (Pairs.first bindResult)+                env2 = Pairs.second (Pairs.first bindResult)+                body2 = Pairs.second bindResult+            in (Eithers.bind (encodeTermInternal env2 anns [] body2 cx g) (\jbody ->               let returnSt = Syntax.BlockStatementStatement (Utils.javaReturnStatement (Just jbody))                   block = Syntax.Block (Lists.concat2 bindingStmts [                         returnSt])@@ -1777,10 +1788,11 @@         Model.TermLet v0 ->           let letBindings = Model.letBindings v0               letBody = Model.letBody v0-          in (Eithers.bind (bindingsToStatements env letBindings cx g) (\bindResult ->-            let letStmts = Pairs.first bindResult-                envAfterLet = Pairs.second bindResult-            in (Eithers.bind (encodeTermTCO envAfterLet funcName paramNames tparams tcoVarRenames tcoDepth letBody cx g) (\tcoBodyStmts -> Right (Lists.concat2 letStmts tcoBodyStmts)))))+          in (Eithers.bind (bindingsToStatements env letBindings letBody cx g) (\bindResult ->+            let letStmts = Pairs.first (Pairs.first bindResult)+                envAfterLet = Pairs.second (Pairs.first bindResult)+                letBody2 = Pairs.second bindResult+            in (Eithers.bind (encodeTermTCO envAfterLet funcName paramNames tparams tcoVarRenames tcoDepth letBody2 cx g) (\tcoBodyStmts -> Right (Lists.concat2 letStmts tcoBodyStmts)))))         _ ->           let gathered2 = Analysis.gatherApplications term               args2 = Pairs.first gathered2@@ -1825,10 +1837,11 @@                           let bindings = Typing.functionStructureBindings fs                               innerBody = Typing.functionStructureBody fs                               env4 = Typing.functionStructureEnvironment fs-                          in (Eithers.bind (bindingsToStatements env4 bindings cx g) (\bindResult ->-                            let bindingStmts = Pairs.first bindResult-                                env5 = Pairs.second bindResult-                            in (Eithers.bind (encodeTerm env5 innerBody cx g) (\jret ->+                          in (Eithers.bind (bindingsToStatements env4 bindings innerBody cx g) (\bindResult ->+                            let bindingStmts = Pairs.first (Pairs.first bindResult)+                                env5 = Pairs.second (Pairs.first bindResult)+                                innerBody2 = Pairs.second bindResult+                            in (Eithers.bind (encodeTerm env5 innerBody2 cx g) (\jret ->                               let returnStmt = Syntax.BlockStatementStatement (Utils.javaReturnStatement (Just jret))                               in (Right (Lists.concat2 bindingStmts [                                 returnStmt]))))))))) (\bodyStmts ->@@ -2506,10 +2519,11 @@             rawBody = Typing.functionStructureBody fs             innerBody = annotateBodyWithCod cod rawBody             env2 = Typing.functionStructureEnvironment fs-        in (Eithers.bind (bindingsToStatements env2 bindings cx g) (\bindResult ->-          let bindingStmts = Pairs.first bindResult-              env3 = Pairs.second bindResult-          in (Eithers.bind (encodeTerm env3 innerBody cx g) (\jret ->+        in (Eithers.bind (bindingsToStatements env2 bindings innerBody cx g) (\bindResult ->+          let bindingStmts = Pairs.first (Pairs.first bindResult)+              env3 = Pairs.second (Pairs.first bindResult)+              innerBody2 = Pairs.second bindResult+          in (Eithers.bind (encodeTerm env3 innerBody2 cx g) (\jret ->             let returnStmt = Syntax.BlockStatementStatement (Utils.javaReturnStatement (Just jret))                 allStmts = Lists.concat2 bindingStmts [                       returnStmt]@@ -3184,10 +3198,11 @@             let bindings = Typing.functionStructureBindings fs                 innerBody = Typing.functionStructureBody fs                 env4 = Typing.functionStructureEnvironment fs-            in (Eithers.bind (bindingsToStatements env4 bindings cx g) (\bindResult ->-              let bindingStmts = Pairs.first bindResult-                  env5 = Pairs.second bindResult-              in (Eithers.bind (encodeTerm env5 innerBody cx g) (\jret ->+            in (Eithers.bind (bindingsToStatements env4 bindings innerBody cx g) (\bindResult ->+              let bindingStmts = Pairs.first (Pairs.first bindResult)+                  env5 = Pairs.second (Pairs.first bindResult)+                  innerBody2 = Pairs.second bindResult+              in (Eithers.bind (encodeTerm env5 innerBody2 cx g) (\jret ->                 let param = Utils.javaTypeToJavaFormalParameter jdom lambdaParam                     returnStmt = Syntax.BlockStatementStatement (Utils.javaReturnStatement (Just jret))                     allStmts = Lists.concat2 bindingStmts [
+ src/main/haskell/Hydra/Java/Decode/Gradle.hs view
@@ -0,0 +1,57 @@+-- Note: this is an automatically generated file. Do not edit.++-- | Term decoders for hydra.java.gradle++module Hydra.Java.Decode.Gradle where++import qualified Hydra.Core.Decode.File as File+import qualified Hydra.Core.Decode.Packaging as Packaging+import qualified Hydra.Core.Errors as Errors+import qualified Hydra.Core.Extract.Model as ExtractModel+import qualified Hydra.Core.Graph as Graph+import qualified Hydra.Core.Lexical as Lexical+import qualified Hydra.Core.Overlay.Haskell.Lib.Eithers as Eithers+import qualified Hydra.Core.Model as Model+import qualified Hydra.Core.Rewriting as Rewriting+import qualified Hydra.Core.Util as Util+import qualified Hydra.Java.Gradle as Gradle+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)+import qualified Data.Scientific as Sci+import Data.Void++-- | Decoder for hydra.java.gradle.AntlrConfig+antlrConfig :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Gradle.AntlrConfig+antlrConfig cx raw =+    Eithers.either (\err -> Left err) (\stripped -> case stripped of+      Model.TermRecord v0 ->+        let fieldMap = ExtractModel.toFieldMap v0+        in (Eithers.bind (ExtractModel.requireField "arguments" (ExtractModel.decodeList (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of+          Model.TermLiteral v1 -> case v1 of+            Model.LiteralString v2 -> Right v2+            _ -> Left (Errors.DecodingError "expected string literal")+          _ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2))) fieldMap cx) (\field_arguments -> Eithers.bind (ExtractModel.requireField "outputDirectory" File.filePath fieldMap cx) (\field_outputDirectory -> Right (Gradle.AntlrConfig {+          Gradle.antlrConfigArguments = field_arguments,+          Gradle.antlrConfigOutputDirectory = field_outputDirectory}))))+      _ -> Left (Errors.DecodingError "expected a record of type hydra.java.gradle.AntlrConfig")) (ExtractModel.stripWithDecodingError cx raw)++-- | Decoder for hydra.java.gradle.GradleBuildConfiguration+gradleBuildConfiguration :: Graph.Graph -> Model.Term -> Either Errors.DecodingError Gradle.GradleBuildConfiguration+gradleBuildConfiguration cx raw =+    Eithers.either (\err -> Left err) (\stripped -> case stripped of+      Model.TermRecord v0 ->+        let fieldMap = ExtractModel.toFieldMap v0+        in (Eithers.bind (ExtractModel.requireField "dependencies" (ExtractModel.decodeList Packaging.packageDependency) fieldMap cx) (\field_dependencies -> Eithers.bind (ExtractModel.requireField "excludes" (ExtractModel.decodeList (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of+          Model.TermLiteral v1 -> case v1 of+            Model.LiteralString v2 -> Right v2+            _ -> Left (Errors.DecodingError "expected string literal")+          _ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2))) fieldMap cx) (\field_excludes -> Eithers.bind (ExtractModel.requireField "extraSourceDirs" (ExtractModel.decodeList File.filePath) fieldMap cx) (\field_extraSourceDirs -> Eithers.bind (ExtractModel.requireField "plugins" (ExtractModel.decodeList (\cx2 -> \raw2 -> Eithers.either (\err -> Left err) (\stripped2 -> case stripped2 of+          Model.TermLiteral v1 -> case v1 of+            Model.LiteralString v2 -> Right v2+            _ -> Left (Errors.DecodingError "expected string literal")+          _ -> Left (Errors.DecodingError "expected literal")) (ExtractModel.stripWithDecodingError cx2 raw2))) fieldMap cx) (\field_plugins -> Eithers.bind (ExtractModel.requireField "antlr" (ExtractModel.decodeMaybe antlrConfig) fieldMap cx) (\field_antlr -> Right (Gradle.GradleBuildConfiguration {+          Gradle.gradleBuildConfigurationDependencies = field_dependencies,+          Gradle.gradleBuildConfigurationExcludes = field_excludes,+          Gradle.gradleBuildConfigurationExtraSourceDirs = field_extraSourceDirs,+          Gradle.gradleBuildConfigurationPlugins = field_plugins,+          Gradle.gradleBuildConfigurationAntlr = field_antlr})))))))+      _ -> Left (Errors.DecodingError "expected a record of type hydra.java.gradle.GradleBuildConfiguration")) (ExtractModel.stripWithDecodingError cx raw)
+ src/main/haskell/Hydra/Java/Encode/Gradle.hs view
@@ -0,0 +1,50 @@+-- Note: this is an automatically generated file. Do not edit.++-- | Term encoders for hydra.java.gradle++module Hydra.Java.Encode.Gradle where++import qualified Hydra.Core.Encode.File as File+import qualified Hydra.Core.Encode.Packaging as Packaging+import qualified Hydra.Core.Overlay.Haskell.Lib.Lists as Lists+import qualified Hydra.Core.Overlay.Haskell.Lib.Optionals as Optionals+import qualified Hydra.Core.Model as Model+import qualified Hydra.Java.Gradle as Gradle+import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, lines, map, pure, sum, unlines)+import qualified Data.Scientific as Sci+import Data.Void++-- | Encoder for hydra.java.gradle.AntlrConfig+antlrConfig :: Gradle.AntlrConfig -> Model.Term+antlrConfig x =+    Model.TermRecord (Model.Record {+      Model.recordTypeName = (Model.Name "hydra.java.gradle.AntlrConfig"),+      Model.recordFields = [+        Model.Field {+          Model.fieldName = (Model.Name "arguments"),+          Model.fieldTerm = ((\xs -> Model.TermList (Lists.map (\x2 -> Model.TermLiteral (Model.LiteralString x2)) xs)) (Gradle.antlrConfigArguments x))},+        Model.Field {+          Model.fieldName = (Model.Name "outputDirectory"),+          Model.fieldTerm = (File.filePath (Gradle.antlrConfigOutputDirectory x))}]})++-- | Encoder for hydra.java.gradle.GradleBuildConfiguration+gradleBuildConfiguration :: Gradle.GradleBuildConfiguration -> Model.Term+gradleBuildConfiguration x =+    Model.TermRecord (Model.Record {+      Model.recordTypeName = (Model.Name "hydra.java.gradle.GradleBuildConfiguration"),+      Model.recordFields = [+        Model.Field {+          Model.fieldName = (Model.Name "dependencies"),+          Model.fieldTerm = ((\xs -> Model.TermList (Lists.map Packaging.packageDependency xs)) (Gradle.gradleBuildConfigurationDependencies x))},+        Model.Field {+          Model.fieldName = (Model.Name "excludes"),+          Model.fieldTerm = ((\xs -> Model.TermList (Lists.map (\x2 -> Model.TermLiteral (Model.LiteralString x2)) xs)) (Gradle.gradleBuildConfigurationExcludes x))},+        Model.Field {+          Model.fieldName = (Model.Name "extraSourceDirs"),+          Model.fieldTerm = ((\xs -> Model.TermList (Lists.map File.filePath xs)) (Gradle.gradleBuildConfigurationExtraSourceDirs x))},+        Model.Field {+          Model.fieldName = (Model.Name "plugins"),+          Model.fieldTerm = ((\xs -> Model.TermList (Lists.map (\x2 -> Model.TermLiteral (Model.LiteralString x2)) xs)) (Gradle.gradleBuildConfigurationPlugins x))},+        Model.Field {+          Model.fieldName = (Model.Name "antlr"),+          Model.fieldTerm = ((\opt -> Model.TermOptional (Optionals.map antlrConfig opt)) (Gradle.gradleBuildConfigurationAntlr x))}]})
src/main/haskell/Hydra/Java/Serde.hs view
@@ -1040,7 +1040,7 @@ -- | Sanitize a string for use in a Java comment sanitizeJavaComment :: String -> String sanitizeJavaComment s =-    Strings.join "&gt;" (Strings.splitOn ">" (Strings.join "&lt;" (Strings.splitOn "<" (Strings.join "&amp;" (Strings.splitOn "&" s)))))+    Strings.join "*&#47;" (Strings.splitOn "*/" (Strings.join "&#92;" (Strings.splitOn "\\" (Strings.join "&gt;" (Strings.splitOn ">" (Strings.join "&lt;" (Strings.splitOn "<" (Strings.join "&amp;" (Strings.splitOn "&" s)))))))))  shiftExpressionToExpr :: Syntax.ShiftExpression -> Ast.Expr shiftExpressionToExpr e =