onrails logoonrails
Comparisons

Overview

How onrails relates to neverthrow, fp-ts, and Effect — and when to reach for each.

onrails is the typed railway data layer: Result / ResultAsync / Maybe as plain tagged unions, exhaustive pattern matching, a named-step Railway builder, and a neverthrow-compat tier — with zero runtime dependencies. It deliberately stops at the data model: no effect system, no dependency injection, no scheduler, no fibers.

That positioning is the whole comparison. onrails is broader than neverthrow (adds Maybe + pattern matching + the railway builder), lighter than fp-ts (no typeclasses, no HKT encoding, concrete monomorphic functions), and a fraction of Effect (no R requirements channel, no runtime, no Layer).

At a glance

onrailsneverthrowfp-tsEffect
ScopeResult + Maybe + matchResult onlyEither/Option/Task + typeclassesFull effect system
Runtime dependencynonenonenoneeffect runtime
Value modelplain tagged unionsclass instancestagged unionsEffect<A, E, R>
Error channeltyped Etyped EEither<E, A> (error-left)typed E + tagged errors
Dependency injection——Reader*Context / Layer
Concurrency / fibers———structured concurrency
Pattern matchingbuilt-in—per-type fold/matchMatch module
API styledata-first and curried; optional fluentfluent / OOpoint-free, curriedpipe + generators
Bundle footprinttiny, tree-shakeabletinymediumlarge
Learning curvelowlowhighhigh

How to choose

  • Want railway-typed errors without adopting a framework? onrails. It slots next to your existing stack (TanStack Query, Prisma, Zod, plain fetch) and owns nothing but the return type.
  • Already on neverthrow and happy? You barely need to move — onrails ships a drop-in compat tier and a codemod. Migrate for the tagged-union data model, Maybe, and pattern matching.
  • Want category-theory abstractions (Traversable, generic sequence, point-free everything)? fp-ts is more general — at a steeper cost.
  • Want one framework to own your runtime — DI, concurrency, resource safety, retries, observability? Effect is the platform. onrails is intentionally not that.

The pages below put the same task side by side in each library. Microbenchmarks against neverthrow and ts-pattern (method, limits, snapshot) are on Benchmarks.

On this page