Algebraic Types
I’m a math nerd. I’m also a language nerd - both for programming languages and for natural languages.
A software engineer's ramblings
I’m a math nerd. I’m also a language nerd - both for programming languages and for natural languages.
This post is a followup to the previous post, which tried to illustrate that JavaScript Promises are an instance of a common interface that comes up in programming, called “monads”. In this post, I want to introduce some basic Haskell, talk a bit more about what it means to be a monad[^trap], and show some of the ideas that were briefly mentioned in the last post.
I want to take you down the journey I went down when I initially learned about
JavaScript Promise
s for work. This post was originally supposed to be an
homage to “You Could Have Invented
Monads”
because I found it enlightening when I taught myself Haskell. However, I’ve
convinced multiple teams (at multiple jobs) that some of our headaches would go
away if we started using Promise
s, and I’ve given some presentations on the
subject. I’ve written tens of thousands of lines of code in Promise
-using
applications. So I’d say I’m relatively familiar with them and the problems
they solve at this point, and this post sort of evolved into half “why
callbacks suck, and how Promise
s are better” and half “why Promise
s are
as nice as they are - and what else is that nice”. So without further ado…