Skip to content
Merged
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .sampo/changesets/borrow-local-scopes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-can: minor
---

Borrow module data and local binding maps during canonicalization instead of cloning the full environment at each scope. Preserve shadowing, diagnostics, and error recovery.
6 changes: 6 additions & 0 deletions .sampo/changesets/bounded-trait-lookup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cargo/nash-can: patch
cargo/nash-solve: patch
---

Use ordered map ranges for trait candidate lookup, evidence construction, entailment, and missing-implementation suggestions. Preserve candidate order without a second index.
12 changes: 12 additions & 0 deletions .sampo/changesets/concise-source-aware-diagnostics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
cargo/nash-parse: minor
cargo/nash-constrain: minor
cargo/nash-solve: patch
cargo/nash-report: minor
cargo/nash-language-server: minor
cargo/nash-cli: minor
---

Use concise diagnostics with full expected/actual type comparisons, expectation-origin labels, and stable codes independent of display titles. Retain parser opening positions for closing-delimiter reports. Support arbitrary secondary labels and related reports across source files.

Extend diagnostic JSON with code, severity, labels, suggestions, and related reports. JSON messages now contain styled prose without embedded source drawings; consumers should render the structured labels. LSP diagnostic codes now use stable identifiers instead of titles and include secondary and related source locations.
8 changes: 8 additions & 0 deletions .sampo/changesets/direct-ast-inference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cargo/nash-constrain: minor
cargo/nash-solve: minor
cargo/nash-driver: patch
cargo/nash-report: patch
---

Infer directly from the canonical AST into the existing union-find and predicate engine. Remove the allocated constraint tree and intermediate inference Type, preserving schemes, evidence, rank ownership, recursive-group sequencing, and complete diagnostics. Pass canonical modules directly to the solver.
5 changes: 5 additions & 0 deletions .sampo/changesets/parser-accumulators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-parse: patch
---

Accumulate function arguments and binary operators without cloning partial chains. Keep parser arena allocation linear in operator-chain length.
6 changes: 6 additions & 0 deletions .sampo/changesets/parser-nesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cargo/nash-parse: patch
cargo/nash-report: patch
---

Report excessive expression, pattern, and type nesting before stack exhaustion. Parse flat sequences and nested comments with loops.
6 changes: 6 additions & 0 deletions .sampo/changesets/parser-text-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cargo/nash-parse: minor
cargo/nash-driver: patch
---

Require UTF-8 text at the parser boundary instead of arbitrary bytes. Remove unchecked string conversions and pass source text directly from the driver.
5 changes: 5 additions & 0 deletions .sampo/changesets/remove-interface-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-driver: minor
---

Remove unused disk interface-cache APIs, serialization, and cache metadata. Preserve in-memory exports, kind contracts, and fingerprints returned by compilation.
10 changes: 10 additions & 0 deletions .sampo/changesets/source-coordinates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
cargo/nash-region: minor
cargo/nash-source: minor
cargo/nash-parse: minor
cargo/nash-can: patch
cargo/nash-report: minor
cargo/nash-language-server: patch
---

Use source-sized coordinates and diagnostic widths throughout parsing and reporting. Check LSP coordinate conversion instead of truncating. Reject oversized Unicode escapes without integer overflow, and make arbitrary lookahead offsets safe.
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ We use **bumpalo** for arena allocation:
```rust
let bump = Bump::new();
let src: &str = bump.alloc_str(&file_contents);
let mut parser = Parser::new(&bump, src.as_bytes());
let mut parser = Parser::new(&bump, src);
```

### AST Type Guidelines

**Inline small `Copy` types** - don't put them behind `&'a`:
- Small enums (e.g., `VarType`, `Associativity`) - just store the value
- Newtypes around primitives (e.g., `Precedence(u16)`) - just store the value
- `Region` (8 bytes of integers) - same size as a pointer, no benefit to indirection
- `Region` uses native-size source coordinates (32 bytes on 64-bit hosts); keep it inline in AST nodes.

**Use `&'a T` for**:
- Large types
Expand Down
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license = "Apache-2.0"

[workspace.dependencies]
async-trait = "0.1"
bincode = "1"
bumpalo = { version = "3.19.1", features = ["collections"] }
clap = { version = "4.5.60", features = ["derive"] }
color-print = "0.3.7"
Expand Down
15 changes: 8 additions & 7 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component specs in [`docs/`](docs/); chunked implementation plans in
## Pipeline

```
parse -> canonicalize -> kinds -> constrain/solve (+ traits) -> nitpick
parse -> canonicalize -> kinds -> direct inference (+ traits) -> nitpick
-> macro expansion (loop) -> Core IR -> optimize -> UPLC
```

Expand All @@ -24,10 +24,10 @@ produce UPLC programs; all dependencies inline into each program.
| `nash-parse` | parser + Elm error hierarchy | extend ([plans/01](plans/01-syntax.md)) |
| `nash-ast` | canonical AST | extend |
| `nash-can` | canonicalization, interfaces | extend |
| `nash-constrain` | constraint generation, kinds | extend |
| `nash-solve` | solver, traits, defaulting | extend |
| `nash-constrain` | union-find types, canonical instantiation, type errors | done |
| `nash-solve` | direct AST inference, traits, defaulting | extend |
| `nash-nitpick` | exhaustiveness and redundancy | done ([plans/05](plans/05-nitpick.md)) |
| `nash-report` | diagnostics (Elm prose -> miette) | done ([plans/06](plans/06-diagnostics.md)) |
| `nash-report` | concise diagnostics (terminal, JSON, LSP) | done ([plans/06](plans/06-diagnostics.md)) |
| `nash-ir` | Core IR + passes | new ([plans/07](plans/07-codegen.md), [08](plans/08-optimizer.md)) |
| `nash-codegen` | Can -> Core -> UPLC | new ([plans/07](plans/07-codegen.md)) |
| `nash-test` | test runner, fuzzing, shrinking | new ([plans/10](plans/10-testing.md)) |
Expand All @@ -46,7 +46,8 @@ Done:

- [x] Parser (Elm `Parse/*` port, full syntax error hierarchy)
- [x] Canonicalization (Elm `Canonicalize/*` port, SCC, interfaces)
- [x] Type inference (Elm `Type/*` port: constraints, rank-based solver, records, aliases)
- [x] Type inference (direct AST inference, rank-based solver, records, aliases)
- [x] Frontend hardening and direct-inference parity ([verification](docs/frontend-hardening-verification.md))
- [x] Project config, driver, dependency-ordered builds, interface cache
- [x] `nash check`
- [x] UPLC runtime (`nash-plutus`): conformance suite passes
Expand All @@ -60,7 +61,7 @@ Planned, in execution order (each links to its plan):
- [x] 03 Traits: qualified types, resolution, superclasses, defaults, multi-param, orphan rules, literal traits + defaulting, evidence — [plans/03-traits.md](plans/03-traits.md) (default imports deferred to Plan 12)
- [x] 04 Representation: remove row polymorphism and Elm supertypes, builtin type inventory, record encoding — [plans/04-representation.md](plans/04-representation.md)
- [x] 05 Exhaustiveness (`Nitpick/PatternMatches` port) — [plans/05-nitpick.md](plans/05-nitpick.md)
- [x] 06 Diagnostics (`nash-report`, Elm `Reporting/*` port onto miette) — [plans/06-diagnostics.md](plans/06-diagnostics.md)
- [x] 06 Diagnostics (`nash-report`, concise source labels, stable codes, JSON/LSP) — [plans/06-diagnostics.md](plans/06-diagnostics.md); [concise diagnostics refactor](plans/diagnostics-refactor.md) complete
- [ ] 07 Codegen: Core IR, monomorphization, decision trees, recursion, Data casts, UPLC lowering — [plans/07-codegen.md](plans/07-codegen.md)
- [ ] 08 Optimizer: inlining, builtin force caching, DCE, case-of-known-ctor/constant folding — [plans/08-optimizer.md](plans/08-optimizer.md)
- [ ] 09 Validators + `nash build` — [plans/09-validators-build.md](plans/09-validators-build.md)
Expand All @@ -80,7 +81,7 @@ Later: LSP features, web playground, package registry (pubgrub), TypeScript code
| `AST/Source.hs` | `crates/nash-source/src/lib.rs` |
| `AST/Canonical.hs` | `crates/nash-ast/src/lib.rs` |
| `Canonicalize/*` | `crates/nash-can/src/*` |
| `Type/Type.hs`, `Type/Constrain/*` | `crates/nash-constrain/src/*` |
| `Type/Type.hs`, `Type/Constrain/*` | `crates/nash-constrain/src/*`, `crates/nash-solve/src/solve/*` |
| `Type/{Solve,Unify,Occurs}.hs` | `crates/nash-solve/src/*` |
| `Nitpick/PatternMatches.hs` | `crates/nash-nitpick` |
| `Reporting/{Doc,Report,Render,Suggest}.hs`, `Reporting/Error/*` | `crates/nash-report` |
Expand Down
4 changes: 1 addition & 3 deletions crates/nash-can/src/entailment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ impl<'a> Resolver<'_, 'a> {
let mut selected = None;
for (key, info) in self
.tables
.impls
.iter()
.filter(|(key, _)| Some(key.trait_) == wanted.trait_)
.impls_for(wanted.trait_.ok_or(Failure::Missing)?)
{
if let nash_ast::head::Match::Yes(arguments) = nash_ast::head::matches(
&mut nash_ast::head::Canonical,
Expand Down
Loading
Loading