Monads in Python

Monads are a super interesting and useful design pattern often seen in functional programming languages such as Haskell. That being said, it is pretty simple to implement our own monads in Python. When talking about Monads, there are three “main” things that I use to describe in practical terms what a Monad is and what it does: Monads are essentially containers for values. In other words, you will have a Monad that will contain some arbitrary value or variable....

February 16, 2021 · 9 min

Decorators in Python

In python, you may have seen some syntax that looks a little like this: @something def foo(): pass The @something statement is called a decorator and is syntactic sugar allow you to concisely implement and use interesting concepts from functional programming called “Higher-order Functions” and “currying”. Before we get into how and why we might use decorators in Python, let’s talk about functional programming, Higher-Order Functions and currying. Currying Currying is a technique for taking a function that takes multiple inputs, and converting it into a sequence of single-input functions....

February 1, 2021 · 4 min