Skip to content
0:00 / 0:00

#railwayorientedprogramming#f##errorhandling

Scott Wlaschin — Railway oriented programming

TechTrain

8.4K subscribers • 1 video on Hallway

YouTube
  • Recommended by 4 people: 3 in engineering communities and 1 curated list.
  • Presented by Scott Wlaschin, author of Domain Modeling Made Functional

Intermediate. Assumes working knowledge.

18K views5 years ago4 recommendations

Software designProgramming languagesFunctional programmingDesign patternsSoftware architecture

Scott Wlaschin explains functional error handling and pipeline design using his famous railway analogy.

Подробнее о фестивале TechTrain: jrg.su/YR8JKw — . When coding applications you cannot always stay on the "happy path". In a robust production-ready application you must deal with validation, logging, network errors, and other annoyances. How do you handle all this using a functional programming approach? This talk will provide a brief introduction to error handling in functional programming, using a fun and easy-to-understand railway analogy.

Why it's here

4 people recommend this

What people say. Highly recommended as the classic, clearest explanation of functional error handling and value-based control flows.

u/DavidRaabin r/ProgrammingLanguages • Recommends

On “If-fail-else Construct”

You ca re-think your code in a more functional way. First the function `user_exists` and `get_user` are not needed. Instead you provide just a `get_user` that can return an optional user. So it either is a user or none. Then you could filter an option by a predicate `is_banned`. And finally you can do what you need with a user. `login` and other stuff. Here is an F# inspired code. ``` User.get "fred" |> Option.filter User.isBanned |> Option.map User.login |> Option.map Log.user |> Option.map User.doSomethingWithUser ``` Instead of `Option` it also could be a `Result`. Haskell names it `Either`. Scott Waschlin named it Railway oriented programming

u/ImaginaryKarmaPointsin r/functionalprogramming • Recommends

On “Fp library for JS”

…IMO the bigger gains from FP come from restructuring code to make most operations into processing pipelines, and this is where the Algebraic Data Types come in handy - it took me quite a while to wrap my head around them however. For conceptual overview, Scott Wlaschin has some good videos (he uses F# instead of JS but concepts are the same) e.g. link to this video For Javascript examples, look up Brian Lonsdorf on Youtube. To really grok ADTs I found it helpful to follow along with the Crocks live coding videos, pausing to try out things on my own machine - link to this video…

programming-talkscurated list on GitHubRecommends

Under “Functional Programming”

Railway oriented programming: Error handling in functional languages [mirror](link to this video 00:56:55 by **Scott Wlaschin** (2014)

u/SIRHAMYin r/functionalprogramming • Recommends

On “Scott Wlaschin: Functional Core, Imperative Shell ”

Big fan of Scott Wlaschin's programming talks. Some other domains I think he has great ideas in: \* Domain Driven Design (made functional): [video \* Railway Oriented Programming (value-based control flows): [video \* His F# guides: https://fsharpforfunandprofit.com/why-use-fsharp/ Also I his book on DDD is my favorite on the subject - simple and powerful: https://hamy.xyz/labs/2024-01\_best-book-ddd

u/asieradzkin r/dotnet • Mentions

On “Is it just me who despises generic repository pattern”

This is solved with Railway Oriented Programming : ) When will you guys check out the amazing topic by Scott Wlaschin? [video