FP Complete

Iterators and Streams in Rust and Haskell

Streaming data is a problem domain I’ve played with a lot in Haskell. In Haskell, the closest we come to built-in streaming data support is laziness-by-default, which doesn’t fully capture streaming data. (I’m not going into those details today, but if you want to understand this better, there’s plenty of information in the conduit tutorial.) […]

A Tale of Two Brackets

This is a debugging story told completely out of order. In order to understand the ultimate bug, why it seemed to occur arbitrarily, and the ultimate resolution, there’s lots of backstory to cover. If you’re already deeply familiar with the inner workings of the monad-control package, you can probably look at a demonstration of the […]

Understanding ResourceT

This blog post came out of two unrelated sets of questions I received last week about usage of the resourcet library. For those unfamiliar with it, the library is often used in combination with the Conduit streaming data library; basically every conduit tutorial will quickly jump into usage of the resourcet library. Instead of just […]

The ReaderT Design Pattern

Often times I’ll receive or read questions online about “design patterns” in Haskell. A common response is that Haskell doesn’t have them. What many languages address via patterns, in Haskell we address via language features (like built-in immutability, lambdas, laziness, etc). However, I believe there is still room for some high-level guidance on structuring programs, […]

What pure functional programming is all about: Part 2

In the last post, we covered the following: What purity is and what it isn’t. We looked at functions and function composition. We’ve looked at how reasoning is easier if you only have functions. In this post, we’ll explore: SQL as a pure language, which is a familiar language to almost everybody. How pure languages […]

What pure functional programming is all about: Part 1

This is a technical post series about pure functional programming. The intended audience is general programmers who are familiar with closures and some functional programming. We’re going to be seeing how pure functional programming differs from regular “functional programming”, in a significant way. We’re going to be looking at a little language theory, type theory, […]

Partial patterns in do blocks: let vs return

This blog post is about a pattern (pun not intended) I’ve used in my code for a while, and haven’t seen discussed explicitly. A prime example is when doing simplistic parsing using the functions in Data.Text.Read. (And yes, this is a contrived example, and using parsec or attoparsec would be far better.) Full versions of […]

The typed-process library

In October of last year, I published a new library – typed-process. It builds on top of the veritable process package, and provides an alternative API (which I’ll explain in a bit). It’s not the first time I’ve written such a wrapper library; I first did so when creating Data.Conduit.Process, which is just a thin […]

Immutability, Docker, and Haskell’s ST type

In managing projects at FP Complete, I get to see both the software development and devops sides of our engineering practice. Over the years, I’ve been struck by the recurrence of a single word appearing repeatedly in both worlds: immutability. On the software side, one of the strongest tenets of functional programming is immutable data […]

MonadMask vs MonadBracket

The exceptions package provides three typeclasses for generalizing exception handling to monads beyond IO: MonadThrow is for monads which allow reporting an exception MonadCatch is for monads which also allow catching a throw exception MonadMask is for monads which also allow safely acquiring resources in the presence of asynchronous exceptions For reference, these are defined […]