Railway oriented programming in Scala

Click for: original source

An article by Pierre Jambet about his discovery of Railway Oriented Programming (ROP).

If you new to the concept of ROP, here is the blurb:

Many examples in functional programming assume that you are always on the “happy path”. But to create a robust real world application you must deal with validation, logging, network and service errors, and other annoyances. ROP tries to address these in clean functional way.

The article then tries to implement ROP with use of Either type:

  • Translating F# to Scala
  • The ROP DSL
  • Validation
  • One-track functions
  • Dead end functions & exception handling
  • Adding log

The article contains plenty of code examples with links to further reading. Excellent read for any fan of functional programming!

[Read More]

Tags scala software-architecture functional-programming code-refactoring software java