Skip to content

Add Junctions() API for simplified train definitions#14

Merged
Theauxm merged 1 commit intomainfrom
feat/junctions-api
Mar 23, 2026
Merged

Add Junctions() API for simplified train definitions#14
Theauxm merged 1 commit intomainfrom
feat/junctions-api

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented Mar 23, 2026

Summary

  • Add Junctions() virtual method on Train<TInput, TReturn> that returns TReturn directly, replacing the Activate(input).Chain<T>().Resolve() ceremony
  • Add implicit conversion operator on Monad<TInput, TReturn> so the chain result flows into the return type without explicit Resolve()
  • Expose Chain/Extract/ShortCircuit/AddServices/IChain as protected methods on Train that delegate to the internal Monad
  • RunInternal becomes virtual (was abstract) with a default implementation that calls Junctions() — fully backwards compatible

Before:

protected override async Task<Either<Exception, int>> RunInternal(string input) =>
    Activate(input).Chain<StringLengthJunction>().Resolve();

After:

protected override int Junctions() =>
    Chain<StringLengthJunction>();

Test plan

  • 12 new unit tests covering happy path, failure path, Extract, implicit conversion, and backwards compat
  • All 208 existing Trax.Core tests pass
  • Zero build warnings

Replace the Activate/Chain/Resolve ceremony with a single Junctions()
override that returns TReturn directly. The Monad gains an implicit
conversion operator so the chain result flows naturally into the return
type. Protected Chain/Extract/ShortCircuit methods on Train delegate to
the internal Monad, letting users call them without touching Monad
directly. RunInternal remains as a virtual fallback for advanced cases.
@Theauxm Theauxm merged commit eee00f3 into main Mar 23, 2026
1 check passed
@Theauxm Theauxm deleted the feat/junctions-api branch March 23, 2026 18:07
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented Mar 23, 2026

This PR is included in version 1.4.0

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