Railway Oriented Programming


https://medium.com/elixirlabs/railway-oriented-programming-in-elixir-with-pattern-matching-on-function-level-and-pipelining-e53972cede98

The common recommendation in Elixir is to let it crash (more accurately it is let a supervisor handle the error ). This is normally the case when you have small processes.

There is another pattern that can be used.

If all of your functions return {:ok, something} or {:error, reason} then technically the function is a Monad. This allows pipelines in which data and errors can be passed through cleanly.

Railway oriented programming takes this a stage further by having defined pipelines that have a good and an error route. It is possible for errors to be handled and returned to the good track.

https://zohaib.me/railway-programming-pattern-in-elixir/ 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s