Sanctuary JS


Found this new (to me) FP library called Sanctuary.

Total Functions

It has total functions; unlike Ramda/Lodash it validates types at runtime; no need to check for the correct data type before using functions.

Information Preservation

It makes intelligent decisions around results being ADT’s. You get back a Maybe for things in Lodash that would report a String or undefined. A lot more clear and something you’d end up probably wrapping yourself anyway.

Currying: Only 1 Arg Per Function

Strong opinions that currying should be 1 argument per function. I’m on the fence about this, mainly because currying is a huge leap for some JavaScript programmers & having “the old way” to call functions normally like add(1, 2, 3) vs add(1)(2)(3) helps them out a lot to learn.

No this

Disallows this. It’s the worst thing in JavaScript & more divisive than politics.

Throws For Wrong Type

This kind of makes me rage is what they call invariants. Meaning, if you pass in the wrong type, it throws. Now, during unit testing + manual testing at runtime, this can help suss out bugs even if you’re using typings via Flow/TypeScript, etc. However, throwing Errors is a side effect, and it blows my mind a group smart enough to create Sanctuary would do this. Good news, tho, you can turn it off, heh!

Learn More

Read more about Sanctuary.

Functional Programming for OOP Developers: Part 2 – No Errors and Getting Things


In my journey to learn functional programming and drink deep of the kool-aid, I wanted to share my latest learnings. Specifically around the quest for no errors and how you get things.

I’ve also just recently applied these same concepts in Python, not just JavaScript, so I’ll mix and match the examples to show how the concepts are universal.

After reading this article, you should understand why errors aren’t helpful embedded in your code & avoiding them is good and why we use functions to get things instead of the old way of assigning variables. Check out the first article if you missed it.
Continue reading “Functional Programming for OOP Developers: Part 2 – No Errors and Getting Things”

Functional Programming for OOP Developers: Part 1

Yeah yeah yeah, tl;dr; and show me the code, yo!


I have been learning Functional Programming over the past year with a friend of mine. We’ve both cut our teeth on finding who to learn from, what articles are useful, and what actually translates into your day to day programming job. I’ve also learned a lot of natural problems that arise as you start a new project from scratch with an OOP background, or if you’re refactoring some OOP code to be more functional.

In this article, I wanted to share some of what I learned. Specifically what functional programming is, why it matters, how to use pure functions and list comprehensions in the real world. While I use JavaScript in this article, I’ve learned that the concepts and libraries supporting it are available in many programming languages.

Continue reading “Functional Programming for OOP Developers: Part 1”