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.

3 Replies to “Sanctuary JS”

  1. PureScript is amazing. Sadly, I’m still in the middle of the PureScript book. I swear I’ve had to re-read some of the chapters 4 times for most of it to “click”. It’s a big jump from Elm which was much more comfortable.

    … that and I work in a big company which is “mostly OOP”; a bit challenging when you’re one of the few lone FP cats. That said, I’m teaching the youth, so hopefully someday.

  2. Oh, I can sympathize! If you have an abundance of time on your hands, I’ve heard nothing but good things about Haskell Programming from First Principles ( I’ve seen people read this to grok PureScript.

    My fave compile-to-js language is F# via Fable ( If you dig the Elm Architecture, Fable has a library called Fable-Elmish (

    Been reading since the Flash days…it’s fun to watch others navigate the current front end waters. Good luck!

Comments are closed.