These are chat archives for ramda/ramda

15th
Sep 2015
Irakli Safareli
@safareli
Sep 15 2015 10:41
anything like this in ramda?
var func = function(f,...args){
  return function(){
    return f.apply(this,args)
  }
}
func(console.log,'log this only')('dont log this');
Scott Sauyet
@CrossEye
Sep 15 2015 11:04
@safareli: I would call that thunk, and no we don't have it. A PR would be welcome, though.
Danielle McLean
@00dani
Sep 15 2015 11:08
Also you probably can't just pass console.log around like that? console.log.bind(console) or something's needed.
Raine Virta
@raine
Sep 15 2015 11:09
00Davo: it has worked in some environments without binding
Danielle McLean
@00dani
Sep 15 2015 11:09
Ah, yes, it works in Node. Fair enough. :p
hemanth.hm
@hemanth
Sep 15 2015 11:39
Maybe function with R ?
any reason for using a loop in _map.js ? Why not do it with recursion? (functional way)
Asaf
@asaf-romano
Sep 15 2015 11:48
@CrossEye isn't thunk the same as partial in that case?
hemanth.hm
@hemanth
Sep 15 2015 12:02
right place to talk about ramda-fantasy ?
Raine Virta
@raine
Sep 15 2015 12:32
@asaf-romano I think the difference is that partial sends also the args applied later on
Scott Sauyet
@CrossEye
Sep 15 2015 12:39
@hemanth: Yes, this is the right place.
Scott Sauyet
@CrossEye
Sep 15 2015 12:44
@asaf-romano: You're right that partial can be used as thunk, although as @raine points out, it does have some subtle differences. I never use partial so it doesn't come to mind.
Raine Virta
@raine
Sep 15 2015 12:48
func(require('treis')(console.log), 'log this only')('dont log this');
partial(require('treis')(console.log), 'log this only')('dont log this')
treis output:
bound test 0: 'log this only'
log this only
bound test => undefined
bound test 0: 'log this only'
           1: 'dont log this'
log this only dont log this
bound test => undefined
as much is obvious from stdout
Tobias Pflug
@gilligan
Sep 15 2015 12:53
@scott-christopher hm, have to bug you again - how would I go about writing a property that says that for anything but functions the function f returns false ?
hemanth.hm
@hemanth
Sep 15 2015 13:07
@CrossEye Say you had to explain FP to someone who is new to it and you would have to chose an imperative code and convert it to functional paradigm, which code would you opt for?
and wrt to _.map in ramda's source a loop is been used instead of recursion, why is that so?
hemanth.hm
@hemanth
Sep 15 2015 13:12
blob
^ is a nice way to understand fantasy-land ;) ?
Scott Sauyet
@CrossEye
Sep 15 2015 13:14
@raine: Yes, it had additional behaviors, but it would serve as thunk if used without the additional parameters, I believe.
Raine Virta
@raine
Sep 15 2015 13:15
but you always don't have control over if additional parameters are passed
Danielle McLean
@00dani
Sep 15 2015 13:19
Perhaps Ramda should provide an R.nullary in the vein of R.unary and R.binary to address that problem?
Scott Sauyet
@CrossEye
Sep 15 2015 13:21
@hemanth: I think that's a good overview. But of course the laws for the functions are really what's important.
Asaf
@asaf-romano
Sep 15 2015 13:23
@CrossEye don't miss my last repl link :)
didn't expect this.
regarding partial, I stopped using it because i have two use cases for it: one that curry addresses much better, and one (thunk) that ES6 arrow functions address just as well, with fewer characters.
Raine Virta
@raine
Sep 15 2015 13:33
true, however a function may not always be curried if it's not yours
I happen to be working on something relevant to this https://gist.github.com/f97f58f680ae71de7218
Asaf
@asaf-romano
Sep 15 2015 13:35
it needs to be a third party function i cannot curry and that does not care about this
Interesting (the link)
Scott Sauyet
@CrossEye
Sep 15 2015 13:37
@hemanth: we tried the recursion route before, but it wasn't performant enough in JS. The predecessor to Ramda, called Eweda, had much prettier code...
@hemanth: I think you can use almost any code you like to convert, but I find it easier to work with plain data transformations.
Asaf
@asaf-romano
Sep 15 2015 13:39
@raine btw, you can do fn(...args)
Raine Virta
@raine
Sep 15 2015 13:39
asaf-romano: oh good point
always forget you can apply with spread
asaf-romano @asaf-romano heard that sentence in Hebrew too :)
Asaf
@asaf-romano
Sep 15 2015 13:41
I think I'm done spamming the github issue track for the time being.
Scott Sauyet
@CrossEye
Sep 15 2015 13:48
Interesting stuff, @raine!
hemanth.hm
@hemanth
Sep 15 2015 14:20
@CrossEye Thanks, any specific example?
Scott Sauyet
@CrossEye
Sep 15 2015 14:59
@hemanth: not offhand, but feel free to steal anything you like from http://fr.umio.us/ .
hemanth.hm
@hemanth
Sep 15 2015 15:00
@CrossEye I had landed on this before :)
hemanth.hm
@hemanth
Sep 15 2015 15:08
:+1:
Scott Sauyet
@CrossEye
Sep 15 2015 15:11
Well it's all my stuff there. Feel free to borrow whatever you like from there.
hemanth @hemanth is cheery-picking things for there.
Drew
@dtipson
Sep 15 2015 16:50
still very interested in thoughts on @Avaq's question. What he's doing (creating a lens that gets from one part of a tree but sets on another) is very interesting, but seems like something that could be more formalized/explicit. Like, a composed function that would take a data object and then internally use a lens/over to change just one prop, but with that R.over using a function that took the entire data object as an argument so that how that prop changed was dependent on some other part of the original data object. It feels like there's some lens-y, functional-y way to tackle that, but I can't think of how.
Irakli Safareli
@safareli
Sep 15 2015 16:59
so pull request for thunk will be ok? if so i'll do it tomorrow :3
https://gist.github.com/safareli/0bab78ae1046eba9c08f
Raine Virta
@raine
Sep 15 2015 18:05
@safareli it would have to be es5 though
Irakli Safareli
@safareli
Sep 15 2015 18:12
@rain ok
Asaf
@asaf-romano
Sep 15 2015 19:11
es3 even :)
arguments.slice and such
Tobias Pflug
@gilligan
Sep 15 2015 19:50
hum.. any suggestions for a function that creates an array of length n that will randomly contain a sequence of repeated integers ? like f(4) -> [1,2,2,3] ; f(4) -> [8,8,8,20]
i'll just fiddle together something with R.times
Raine Virta
@raine
Sep 15 2015 20:10
@gilligan put this to cookbook some time ago, might help https://github.com/ramda/ramda/wiki/Cookbook#get-n-function-calls-as-a-list
Tobias Pflug
@gilligan
Sep 15 2015 20:14
@raine thanks
Dave Keen
@ccapndave
Sep 15 2015 21:05
What is the Ramda equivalent of x => x === true ?
Danielle McLean
@00dani
Sep 15 2015 21:06
@ccapndave R.equals(true) should work.
Denis Stoyanov
@xgrommx
Sep 15 2015 21:07
@ccapndave Why not lamda?))
Dave Keen
@ccapndave
Sep 15 2015 21:08
Oh, yeah, R.equals(true) works
I dunno why not lambda really :) Just trying to Ramda everything for the sake of it
Denis Stoyanov
@xgrommx
Sep 15 2015 21:08
@ccapndave please provide all code where you use it
Dave Keen
@ccapndave
Sep 15 2015 21:10
Sure if you like
const loggedIn$ = observableFromStore<State>(store)
    .map(isLoggedInSelector)
    .distinctUntilChanged()
    .filter(R.equals(true));
A stream that emits when the user is logged in
Denis Stoyanov
@xgrommx
Sep 15 2015 21:11
@ccapndave :smile: I don't understand why not lamda.
Dave Keen
@ccapndave
Sep 15 2015 21:12
const loggedIn$ = observableFromStore<State>(store)
    .map(isLoggedInSelector)
    .distinctUntilChanged()
    .filter(x => x === true);
Like this you mean?
Denis Stoyanov
@xgrommx
Sep 15 2015 21:12
@ccapndave yes)
Dave Keen
@ccapndave
Sep 15 2015 21:12
No reason really
Both are equally readable
Denis Stoyanov
@xgrommx
Sep 15 2015 21:13
@ccapndave but use Ramda only comparison with true...
Dave Keen
@ccapndave
Sep 15 2015 21:14
The app is a mix of Rx and Ramda though so they are mixed and matched everywhere
Denis Stoyanov
@xgrommx
Sep 15 2015 21:15
@ccapndave :smile: