What does HackerNews think of sanctuary?

:see_no_evil: Refuge from unsafe JavaScript

Language: JavaScript

I wonder if this will be something that functional libraries like Ramda [1] or Sanctuary [2] will be able to benefit from.

One of the reasons these libraries don't work so well with TS is that it doesn't have ML-style whole program inference and hence doesn't work so well with patterns like currying. Hegel seems more capable in that regard.

[1] https://ramdajs.com/

[2] https://github.com/sanctuary-js/sanctuary

It can be idiomatic in Javascript if you choose a functional style.

I think Javascript has become a kitchen-sink language. It is, as you say, a language that affords many styles. If you pick a sub-set of the language that is functional you can see that currying is quite idiomatic in that context.

That being said I think library support is a necessity when choosing a more functional approach in Javascript as the "core" experience in JS caters to an imperative, C-derived language (as per many of the examples). If you work with Ramda you can get most of what you need today to make working with currying, and it's compositional capabilities, pleasant.

Consider R.curryN:

    const add = R.curryN(2, (a, b) => a + b)
You can now call this:

    add(1)(2)
    add(1)
    add(1, 2)
And you have options in terms of order of parameters:

    const sillyAdd2 = add(R.__, 2) // a silly example
    sillyAdd2(3) // => 5
And if you want even more flexibility there is Fantasyland[0] and Sanctuary[1] among others.

Javascript is fertile ground, in my experience, for getting developers to experiment with and adopt functional programming paradigms.

[0] https://github.com/fantasyland/fantasy-land

[1] https://github.com/sanctuary-js/sanctuary

Fantasy Land is a great project—proof of how extensible JavaScript can be. There are some very interesting related projects:

https://github.com/Avaq/Fluture is basically lazy and better promises. A+ spec got nothing on this.

https://github.com/sanctuary-js/sanctuary adds better typechecks, combinators, and types like Maybe.

https://github.com/origamitower/folktale An upcoming collection of similar tools for JavaScript.

And of course, there's Ramda.

I think these libraries may sound impossible to use at work at first, but if you play with them for fun, you can at least learn some cool techniques or paradigms.

I don't know where they came from, but these projects and libraries seem to be influenced by Haskell (maybe?):

https://github.com/folktale

https://github.com/sanctuary-js/sanctuary