Flattening Scala Play Controllers with For Comprehensions and Eithers

It's been a little over a year since I've started programming in Scala professionally - so I wanted to come back to this blog and focus on a Scala centric post with some real world application.

I have found that some of the Play controller code I need to write can get very pyramid-shaped in nature, since most of the steps that interact with IO return options, which need to send sensible error messages back to the client in the case of `None`. Let's take a look at a contrived example function:

Read More

Pattern Matching in Elm

One of the great things about some functional programming languages is pattern matching. At its core, it is a way to deconstruct the elements of your program and to do something meaningful with said deconstruction. In this blog post, I'm going to demonstrate how to create a singly linked list and a few functions that operate on it using the language, Elm.

Read More

Immutable.js bindings for Ramda

We use both Ramda and Immutable.js extensively in production to get the benefit of persistent data structures, immutability, and a very nice funcitonal api for our code. That said, sometimes it is difficult to reconcile the two libraries. Here I explore how to use R.invoker to create ramda bindings for immutable, as well as a link to my github repo that hopes to serve as a lib for those wanting to use Immutable and JS objects interchangeable with Ramda without losing the structural sharing benefits of Immutable.js

Read More