A Real World Example of Functional Programming with fp-ts
summary
Refactors a real TypeScript airline reservation API into fp-ts types, replacing Promise with TaskEither to express failures explicitly and mapping validation failures to 422 and capacity rejections to 403. Uses fp-ts helpers like te.fromTask and change-error-type, converts promise-based getReservedSeats into a TaskEither, and promisifies results back for the existing handler. The migration uncovers mismatched behavior contracts, lets the type system catch incompatibilities during a refactor (capacity changed from number to a Task-returning function), and reduces runtime error handling.
AI-written summary · about
chapters (14)
- 0:00Introduction and speaker background
- 2:22What is functional programming
- 5:58Introduction to fp-ts library
- 8:44Real-world example overview
- 10:13Promise-based code limitations
- 13:45Promises vs functional programming
- 18:25Task Either in fp-ts
- 21:18Consuming functional code in API
- 25:09Refactoring with type safety
- 29:45Other fp types and benefits
- 30:29How to start using fp-ts today
- 32:17Why functional programming matters
- 33:23About the speaker's company
- 34:28Q&A session begins
related talks
43mHow to get away with functional programming in frontend applications
07mTyped Functional Programming in TypeScript with fp-ts
34m[Eng Sub]Is it Okay to Pursue Functional Programming on Frontend?
21mSuper TypeScript II Turbo – FP Remix
41mFunctional programming: Give it a chance!
33mRailway Oriented TypeScript
26mFunctional Programming for APIs
32mRailway Oriented TypeScript
