Skip to content

Railway-oriented programming with trcks.fp

Railway-oriented programming (ROP) is a pattern for composing functions that may fail, keeping error handling clean and explicit. This page covers the functional style: you build a pipeline from a start value and a sequence of functions, then run it with trcks.fp.composition.pipe — a "build a pipeline, then run it" mental model. Single-track and double-track code are both discussed. Synchronous and asynchronous code are also discussed.

Prerequisites

Overview matrix

Runtime and track Single value Homogeneous tuple
Sync and single-track pipe and identity tuple_
Sync and double-track result result_tuple
Async and single-track awaitable awaitable_tuple
Async and double-track awaitable_result awaitable_result_tuple
See also

The OOP usage page covers the same operations using method chaining instead of function composition.