avatar

Jamie Hargreaves

Data Engineer

Pragmatic Functional Programming in Python - Part 5: Why You Shouldn't Use Monads

Should we bother with Monads in Python? 🔗In my previous posts in this series I’ve talked at some length about the basics of Functors, Applicatives and Monads in Python, as well as how they fit into functional programming more broadly. To me, the fact that it’s taken this long to give what I would consider to be a sufficiently detailed explanation of how they work is quite telling. Not only that, but I only spoke about two Monads in any detail, Either and IO, but I brushed over the fact that there are all sorts of other Monads designed to tackle different problems and, whilst similar, all these Monads do work differently.

Pragmatic Functional Programming in Python - Part 4: Monads

It’s about time 🔗In the previous posts in the series, we worked up to talking about Mondas by first discussing the idea of Functors and Applicatives, which I said were pre-requisite to properly understanding Monads. We’re finally ready then to talk about Monads, unfortunately it may be a little anti-climactic because, as you might have guessed, you’ve been looking at a Monad all along. Throughout the series, we’ve been looking at Either and how it could be used in exception handling.

Pragmatic Functional Programming in Python - Part 3: Applicatives

We’re still not talking about Monads?! 🔗In the last post in this series we talked about Functors and how they could help keep functions pure (in our case when dealing with exceptions), and how they provided a mechanism to compose functions with their map method. We also talked about the road to understanding Monads and how an understanding of Functors and Applicatives was fundamental to that journey. So, before we finally talk about Monads, let’s talk about Applicatives.

Pragmatic Functional Programming in Python - Part 2: Functors

I thought we were going to talk about Monads? 🔗Monads are probably the most off-putting concept in functional programming (FP), or at least they were for me. Despite how complicated they can seem at first, I don’t think “being complicated” is the reason that Monads are so off-putting, I think it’s because they’re almost universally explained in the context of Haskell. I won’t go too deep on Haskell here (would that I could), but the TL;DR is that Haskell is a popular, purely functional programming language.

Pragmatic Functional Programming in Python - Part 1: What Makes Code Functional?

Who cares? 🔗Before we get into any of the details of functional programming (FP), let’s clear up the most important question: who cares? When I’m writing code, I want it to satisfy two main requirements: Easy to read and understand Easy to test If a programming paradigm can’t help with these requirements, then I’m not interested. Luckily, I think FP can help achieve both. That’s great, but why another blog?

DynamoDB Write Concurrency In Python

Overview 🔗One of the things I’ve always found a little frustrating about Amazon’s Boto3 library is the lack of asynchrony. Whilst languages like Java and Node.js are able to utilise genuine (official), asynchrony, the Python library is completely synchronous for most of its operations. Depending on what you’re trying to do with it, that might not be much of a problem but if, for example, you want to write a large number of records to a service like DynamoDB (or maybe read or write lots of files with Amazon S3, or any other I/O heavy activity you can think of), then you’re left with two options: either put up with synchronous writes (admittedly, greatly sped up with batching, but still…gross), or use a multi-threading approach - either way, you’re stuck with the poor man’s asynchrony.

Blogging with AWS - Part 2: Implementing a CI/CD Pipeline

Overview 🔗In Part 1 we walked through the process to build and deploy a static website on Amazon S3 using Terraform. At the end of that post, we deployed our content manually to S3 using the hugo deploy command and this was very easy to do, enough so that a CI/CD pipeline is probably overkill. Despite this, deploying a CI/CD pipeline is still fun and I think it’s a great way to learn how to implement one in AWS if you’re not familiar.

Blogging with AWS - Part 1: Building and Hosting the Blog

Overview 🔗This post walks through the process of building and deploying a static blog (or any static website, for that matter), using Hugo, and AWS services like Amazon S3 and CloudFront, as well as showing how to utilise Terraform to deploy the necessary AWS resources as code. In Part 2, we’ll look at how to implement a CI/CD pipeline in AWS. Before we get into things, you can find the full source code for this blog on GitHub.