Frequently asked questions (FAQs)
This section answers some questions that might come to your mind.
Where can I learn more about railway-oriented programming?
Scott Wlaschin's blog post Railway oriented programming comes with lots of examples and illustrations as well as videos and slides from his talks.
Should I replace all raised exceptions with trcks.Result?
No, you should not. Scott Wlaschin's blog post Against Railway-Oriented Programming lists eight scenarios where raising or not catching an exception is the better choice.
Which static type checkers does trcks
support?
trcks
is compatible with current versions of mypy
and pyright
.
Other type checkers may work as well.
Which alternatives to trcks
are there?
returns supports
object-oriented style and functional style (like trcks
).
It provides
the returns.result.Result container (and multiple other containers) for synchronous code and
the returns.future.Future and the returns.future.FutureResult container for asynchronous code.
Whereas the returns.result.Result container is pretty similar to trcks.Result,
the returns.future.Future container and the returns.future.FutureResult container deviate
from collections.abc.Awaitable and trcks.AwaitableResult.
Other major differences are:
returns
provides do notation and dependency injection.- The authors of
returns
recommend usingmypy
along with their suggestedmypy
configuration and their custommypy
plugin.
Expression supports
object-oriented style ("fluent syntax") and
functional style (like trcks
).
It provides the expression.core.result.Result class (and multiple other container classes)
for synchronous code.
The expression.core.result.Result class is pretty similar to trcks.Result and trcks.oop.ResultWrapper.
An AsyncResult
type based on collections.abc.AsyncGenerator
will be added in a future version.
Which libraries inspired trcks
?
trcks
is mostly inspired
by the Python libraries mentioned in the previous section and
by the TypeScript library fp-ts.