These are chat archives for ramda/ramda

22nd
Sep 2016
Juan Soto
@sotojuan
Sep 22 2016 00:43

future of JS is functional

lol

Might wanna look into another language.
tbh I don't see how async/await make stuff less "functional", guess I'm missing it.
Drew
@dtipson
Sep 22 2016 01:24
I think js offers a pretty nice mix of the capability for the FP style but also imperative breakouts for cases where mutation might be more performant. The problem is that mutation is the common thing, whereas it should be an occasional indulgence, usually employed as an internal to functional methods. Though obviously its sheer popularity/ubiquity plays a part in that mix being seen as a good idea or not.
I can imagine hundreds of years from now where programmers look back at the craze for JS as being sort of weird a historical quirk, like how teens went mad for the Beatles in the 60s
Juan Soto
@sotojuan
Sep 22 2016 01:50
the only thing i see lacking is immutable data by default yeah
elixir is functional but not haskell-type, not sure if it offers many escape hatches but its pretty practical and easy
i think JS is messy and fun, people do all sort of crazy stuff with it i like it
Drew
@dtipson
Sep 22 2016 02:11
I mean, yes. http://candybox2.net/
Steve
@stevenmathews
Sep 22 2016 05:50
Hi everyone. Trying to learn ramda by rewriting functions I have written as ramda functions composed together.
Find it easier when the data gets passed in as one argument. How would I rewrite such a function?
function tallyPredictions (acc, prediction) {
  return ifElse(
    has(prediction),
    assoc(prediction, inc(acc[prediction])),
    assoc(prediction, 1)
  )(acc)
}
Steve
@stevenmathews
Sep 22 2016 06:06
Updated the onTrue function to over(lensProp(prediction), inc)
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 13:32
Is there a better way to merge 2 objects based on props? https://goo.gl/UrK04r
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 13:39
Hi @Bradcomp, would you have a moment to look at this for me please? https://goo.gl/UrK04r
Brad Compton (he/him)
@Bradcomp
Sep 22 2016 13:42
Well, I dunno about better, but there's always lift / converge ;) https://goo.gl/LDOznL
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 13:43
I was trying lift, but I couldn't figure it out :D
Thanks, that helps a lot :)
Brad Compton (he/him)
@Bradcomp
Sep 22 2016 13:45
Here's a more general solution using converge too! https://goo.gl/FetQI3
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 13:45
nice!
Denis Stoyanov
@xgrommx
Sep 22 2016 14:29
@aaronmcadam pointfree const mergeFields = compose(converge(unapply(mergeAll)), map(prop))
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 14:30
How can I make it work with props?
Rick Medina
@rickmed
Sep 22 2016 14:30
anyone knows a decent tco library/transpiler?
Aaron Mc Adam
@aaronmcadam
Sep 22 2016 14:30
I've settled on compose(apply(merge), props([…]))
doh I forgot about mergeAll, no need to apply
Thanks @xgrommx, that helps
Fernando Montoya
@montogeek
Sep 22 2016 19:48
Thanks @craigdallimore @rickmed
LeonineKing1199
@LeonineKing1199
Sep 22 2016 20:03

anyone knows a decent tco library/transpiler?

I did do a quick search for it but it wasn't very fruitful. I guess because of the mechanics of JS, you're better off replacing recursion with loops or only using recursion in places where your stack depth has a known, finite limit (i.e. don't loop arbitrarily over arrays using recursion, basically).

Steve
@stevenmathews
Sep 22 2016 20:40
@xgrommx You seem like you know stuff :-), are you able to help with
my question above, function is being passed into an xstream fold function.