Skip to content

feat: give a helper method its own type parameters - #119

Draft
moetemp wants to merge 3 commits into
moe/up/helper-resource-methodfrom
moe/up/helper-method-type-parameter
Draft

moetemp wants to merge 3 commits into
moe/up/helper-resource-methodfrom
moe/up/helper-method-type-parameter

Conversation

@moetemp

@moetemp moetemp commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR lets a helper method use a type parameter that its resource doesn't have.

/// @nexus.type-parameter
type value-t = placeholder;

/// @nexus.helper python="reduce_stream"
reduce: func(function: fold, initial: value-t, timeout: duration) -> stream-reduce;
  • The generated method is generic in value-t, and the resource stays generic in its own parameters only.
  • The types in the signature of a function argument count toward the method's type parameters.
  • The stream sample gets reduce on both Stream classes.

Why?

A fold over a Stream gives back a value of the caller's type. Without this change, value-t made the whole Stream generic in it.

How did you test it?

cargo validate passes. The stream tests check a typed reduce, and a unit test checks that the resource keeps only its own parameters.

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

moetemp and others added 3 commits November 14, 2026 01:33
A fold returns a value of the caller's type, which the Stream itself is not generic in. So
helper methods no longer make their resource generic, and each keeps its own type parameters.
Client and Workflow code can fold the Records into one value of their own type. The tests check
that the initial value sets the type of the result on both targets.
The guide and the architecture note say that a helper method doesn't make its resource generic.

Co-authored-by: Tim Conley <timothy.conley@temporal.io>
@moetemp
moetemp added this pull request to stack #120 November 14, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant