These are chat archives for ramda/ramda

26th
Apr 2016
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 08:50

hi all, using Ramda with KefirJs/RxJs its amazingly productive but debugging is a nightmare (mile long error stack traces) so I made a small AST parser that replaces all Ramda functions with a wrapper that records the initial file path, line and char location. Do you guys see any issues with this?
Here's how the wrapper looks like: https://github.com/dumconstantin/ramda-loader/blob/master/src/wrapper.js

In essence from: var add10 = add(10) it produces var add10 = __ramdaDebugWrapper('/path/to/file.js', 23, 1, 'add', add)(10)

Jigar Gosar
@jigargosar
Apr 26 2016 09:02
He guys, there is a manual for ramda, WTF!
I discoverd it right now :(
Why isn’t there a link on home page or doc!!!
:cry: I have been struggling for months
Jigar Gosar
@jigargosar
Apr 26 2016 09:08
Got excited too fast, only 2 pages :(
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 09:08
can you post a link?
I found it in git repo
reverse eng the url
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 09:09
nice!
thanks!
Jigar Gosar
@jigargosar
Apr 26 2016 09:09
Got excited too fast, only 2 pages :(
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 09:09
more to come :)
Scott Christopher
@scott-christopher
Apr 26 2016 09:41
@IvanPeng2015 I'm still not 100% sure I understand the purpose of the function, though if I understand correctly it is possible to remove the fn parameter and end up with a point-free version ... it's just not pretty :)
It also requires some modified Ramda functions to get a version of compose that always produces a unary function.
@ram-bot
const add_     = a => b => a + b
const compose_ = f => g => x => f(g(x))
const flip_    = f => x => y => f(y)(x)
const reduce_  = f => z => xs =>
  xs.length === 0 ? z : reduce_(f)(f(z)(xs[0]))(xs.slice(1))

// reduce left that defaults to zero
const reduceZ = flip_(reduce_)(0)

// a => fn => b => a + fn(b))
const addWith = flip_(compose_(compose_)(add_))

// (fn, xs) => reduce((acc, x) => acc + fn(x), 0, xs)
const sumWith = compose_(reduceZ)(addWith)

const vdi = d => y => d ? y.key || 0 : y.name || 0

const vdiData = [[{key: 4, name: 10}, {key: 5, name: 11}, {key: 6, name: 12}],
  [{key: 4, name: 10}, {key: 5, name: 11}, {key: 6, name: 12}],
  [{key: 4, name: 10}, {key: 5, name: 11}, {key: 6, name: 12}],
  [{name: 1}]];

// (fn, xss) => sumWith(sumWith(fn))(xs)
const vdiz = compose_(sumWith)(sumWith)

vdiz(vdi(true))(vdiData)
ram-bot
@ram-bot
Apr 26 2016 09:44
45
Scott Christopher
@scott-christopher
Apr 26 2016 09:46
So while it was fun to solve, I wouldn't perhaps suggest this as an ideal solution :D
Scott Christopher
@scott-christopher
Apr 26 2016 09:56
Actually, looking at your function, the R.pipe(R.concat([]), aprop(fn)) can be replaced with aprop(fn) because R.concat([], someList) === someList
Which makes your aprop and vdiz the same function, because (fn => aprop(fn)) === aprop
So you can achieve the same thing as your existing function with the following:
const vdiz = R.converge(R.reduce(R.add,0), [R.map]);
vdiz(vdiz(vdi(true)))(vdiData);
Denis Stoyanov
@xgrommx
Apr 26 2016 10:00
@scott-christopher pretty similar to my experiment https://github.com/xgrommx/from-combinators-to-fp
Scott Christopher
@scott-christopher
Apr 26 2016 10:01
Yep, compose_ and flip_ are just B and C respectively :)
Denis Stoyanov
@xgrommx
Apr 26 2016 10:02
@scott-christopher I love way of combinators to fp) It make me more clear.
Scott Christopher
@scott-christopher
Apr 26 2016 10:03
I have to admit B(B)(add) was bending my mind for a little while.
Denis Stoyanov
@xgrommx
Apr 26 2016 10:05
@scott-christopher I have to extended S for many arguments https://github.com/xgrommx/from-combinators-to-fp/blob/master/src/combinators.js#L11 because I need use in compose first function with arity = n. https://github.com/xgrommx/from-combinators-to-fp/blob/master/src/index.js#L23
Tobias Pflug
@gilligan
Apr 26 2016 10:48
Has anyone considered having some reference links on the ramdajs webpage like "projects using ramdajs" or whatever.. ?
Vladimir Starkov
@iamstarkov
Apr 26 2016 11:52
Vladimir Starkov
@iamstarkov
Apr 26 2016 11:57
apparently same link presented in wiki https://github.com/ramda/ramda/wiki
Tobias Pflug
@gilligan
Apr 26 2016 12:04
@iamstarkov i don't think you get what I meant.. obviously you can find statistics about what packages have a ramda dependency - i was more thinking along the lines of listing some companies or popular projects prominently on the ramda homepage
which is something rather different from npmjs figures
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 12:32
@raine @davidchambers hmmm... I added ramda-loader to the Ramda Home Wiki page https://github.com/ramda/ramda/wiki/Home/_history, but I didn't think it would just appear there without review/acceptance from someone :) ...
Tobias Pflug
@gilligan
Apr 26 2016 13:00
@dumconstantin With the debug=true flag you'll get you'll get the precise location -- little typing error
Constantin Dumitrescu
@dumconstantin
Apr 26 2016 13:49
@gilligan the the mind slip :) thanks! rewrote the README.md just now and eliminated the sentence
Gleb Bahmutov
@bahmutov
Apr 26 2016 16:44
@xgrommx I loved,loved,loved your combinators-to-fp source - this single file can (if commented) make a super killer blog post!
Denis Stoyanov
@xgrommx
Apr 26 2016 17:28
@bahmutov glad to know it will be interesting for someone =) for me it was like a fun =)
@bahmutov also take a look on a new section https://github.com/xgrommx/awesome-functional-programming#combinators
@bahmutov and probably it is very interesting huge list of combinators http://www.angelfire.com/tx4/cus/combinator/birds.html
Gleb Bahmutov
@bahmutov
Apr 26 2016 17:45
+1
David Chambers
@davidchambers
Apr 26 2016 22:43

Cross-post from Sanctuary room:

I just published a post, Seeking refuge from unsafe JavaScript. It tells the story of how we came to use Ramda at Plaid, and the events which led to the creation of Sanctuary.

(You may like to give :heart: on HN.)