trcks.oop and trcks.fp equivalence
trcks supports two equivalent programming styles:
trcks.oop (method chaining)
and trcks.fp (function composition).
This page maps common operations from one style to the other.
| Operation | trcks.oop |
trcks.fp |
|---|---|---|
| Wrap a value | Wrapper(core=x) |
start value of a pipe(...) call |
| Map a plain value | .map(f) |
pipe((x, f)) |
Map success to Result |
.map_success_to_result(f) |
r.map_success_to_result(f) |
| Map on success | .map_success(f) |
r.map_success(f) |
| Map on failure | .map_failure(f) |
r.map_failure(f) |
| Side effect on success | .tap_success(f) |
r.tap_success(f) |
| Failable side effect on success | .tap_success_to_result(f) |
r.tap_success_to_result(f) |
| Async success step | .map_success_to_awaitable_result(f) |
ar.map_success_to_awaitable_result(f) |
| Unwrap the result | .core |
result of pipe(...) |
The full set of element-wise and homogeneous-tuple variants is covered
in the
trcks.oop usage page,
the
trcks.fp usage page,
and the Reference section.