Unboxed Tagged Angst

Type class based serialization is now standard in Scala JSON libaries such as Play JSON. All our web applications these days are designed as JSON APIs, with the UI being just an API client. We usually find we want a few different serialization formats. Here are two examples that came up recently: logged-in users can see more information than anonymous users; and, as we’re using Mongo, we want a serialization format for the database that includes more information than other clients can see. Thus we need to control which type class is used for serialization at each point.

Continue reading…

Collaborative Text Editing

The web applications I’ve been involved with over the last year or two have tended towards being richer, with more real-time interactions, and more collaboration. The mechanics of building collaborative applications aren’t so tough, but eventually you run into the problem of what to do with text. But good news: there are some smart algorithms to help you out, which you can implement in a couple of hundred lines of code.

Continue reading…

Scalaz Monad Transformers

Monad transformers allow us to stack monads. Say we have a monad, like Option, and we want to wrap it in another monad, like \/, in a convenient way (where convenient is to be defined shortly). Monad transformers let us do this. Scalaz comes with lots of monad transformers. Let’s see how to use them and the benefits they supply.

Continue reading…

CRDTs for fun and eventual profit

At Velocity I gave a talk on conflict-free replicated datatypes, or CRDTs for short. It wasn’t the best received talk I have ever given; it was my first time at Velocity and I misjudged the audience. However I have had a chance to redeem myself at Scala eXchange, where I gave what I think is a much better (and funnier) talk. Slides are here or you can watch the video, If you want the Velocity edition, the slides are here. The talks are mostly the same in terms of content, but there are differences in organisation and layout.

Continue reading…