These are chat archives for ramda/ramda

21st
Feb 2015
Scott Sauyet
@CrossEye
Feb 21 2015 00:17
It is wonderful to hear about people using it. It's funny as @buzzdecafe and I, who work together for a large, very slow company, aren't actually using it in our day jobs yet. But we expect that to change relatively soon.
Scott Sauyet
@CrossEye
Feb 21 2015 00:24
@davidchambers is being modest. When he discovered Ramda, we had the basic ideas down, but he has since become the most active contributor, and has improved the library phenomenally!
Nathan
@terakilobyte
Feb 21 2015 00:25
@CrossEye I can say that the developers at fcc love ramda and want to use it in our more advanced topics
Scott Sauyet
@CrossEye
Feb 21 2015 00:26
I imagine that's not the Federal Communications Commission.
Nathan
@terakilobyte
Feb 21 2015 00:26
we just need to learn it better ourselves first, but we're planning a series of programming challenges centered around it
Free Code Camp, sorry
Scott Sauyet
@CrossEye
Feb 21 2015 00:26
np
cool. Let us know how we can help.
Nathan
@terakilobyte
Feb 21 2015 00:27
I was thinking about inviting someone who knows it well to join in a live streaming session, working through some challenges we have using ramda instead of using built in methods, but that is a ways off
I do have one question, it goes back to a question I was asking in here a few days ago (apologies to @davidchambers for not getting back, was in the process of moving back to korea). I can't seem to understand how ifElse works
Scott Sauyet
@CrossEye
Feb 21 2015 00:29
Sounds interesting. There are quite a few good people. @DrBoolean and @begriffs have co-taught a course using Ramda several times, so they might be good choices, but many of the regulars contributors have the skills, too, I imagine.
Nathan
@terakilobyte
Feb 21 2015 00:31
var doWork = function doWork(str) {
  if (doesItHaveSpacesOrUnderScores(str)) {
    return spinalThis(str);
  } else {
    return spinalThat(str);
  }
};
I was trying to get this doWork function down to an ifElse but kept getting can't read length of undefined or call
Scott Sauyet
@CrossEye
Feb 21 2015 00:32
Looks like it should be doWork = R.ifElse(doesItHaveSpacesOrUnderScores, spinalThis, spinalThat);
Nathan
@terakilobyte
Feb 21 2015 00:32
I could show the other functions, though you'd all probably laugh at me. I recently finished the course at FreeCodeCamp and since then joined as a developer and built up a challenge framework and a bunch of other stuff
Scott Sauyet
@CrossEye
Feb 21 2015 00:33
That's how ifElse is supposed to work.
Nathan
@terakilobyte
Feb 21 2015 00:33
alright I've give it a try. I probably was doing something stupid
Scott Sauyet
@CrossEye
Feb 21 2015 00:34
The main restriction on ifElse is that the same arguments are passed to the predicate as to the two branch functions. It makes sense when generating a simple function, but doesn't always capture the full ideas of an if-block.
Nathan
@terakilobyte
Feb 21 2015 00:58
@CrossEye yeah I keep running into the same issue, Cannot read property 'apply' of undefined
Scott Sauyet
@CrossEye
Feb 21 2015 01:18
hmm, I'm seeing it too. Let me see why.
But a simple case works fine. Odd.
Nathan
@terakilobyte
Feb 21 2015 01:20
and I actually discovered ramda by watching the course on frontend masters by @drboolean!
and fell in love with the idea of fp at the same time
yeah this is an image of using ifElse in the challenge framework I built
I've renamed the functions a bit as I wasn't happy with them
Scott Sauyet
@CrossEye
Feb 21 2015 01:33
Wonder if you're having the same issue I was. R.toUpperCase was renamed R.toUpper. Similarly, R.toLower
Nathan
@terakilobyte
Feb 21 2015 01:34
I'll give it a try but the doWork function works
I also haven't been able to get 0.10.0
Scott Sauyet
@CrossEye
Feb 21 2015 01:34
why not?
Nathan
@terakilobyte
Feb 21 2015 01:35
from the cdn, I can only get 0.8.0
Scott Sauyet
@CrossEye
Feb 21 2015 01:35
uh oh. I haven't checked that. It's on NPM.
I think that might be my fault. I may have dropped the ball on that one around 0.9.0.
I believe the other CDN is working.
Nathan
@terakilobyte
Feb 21 2015 01:36
I'll give it a try, and then try through npm
David Chambers
@davidchambers
Feb 21 2015 01:37
It looks like the issue is the use of R.to{Lower,Upper}Case as @CrossEye mentioned. Update the function names and the example works.
I started trying to fix the CDN, had my old machine crap out, and then forgot entirely about it. I'll try to fix that this weekend.
Nathan
@terakilobyte
Feb 21 2015 01:44
thanks. Is there a donate button anywhere to help with the hosting costs? I'm still getting the undefined message, going through and checking all the function names
Scott Sauyet
@CrossEye
Feb 21 2015 01:50
No donate button. Done out of our own love for this stuff. But any time you feel like stopping by and giving a hand, we'd appreciate it! :smile:
Nathan
@terakilobyte
Feb 21 2015 01:56
Oh I'd definitely be interested in helping, though looking through the source code I can tell you guys way outclass my current skill level!
David Chambers
@davidchambers
Feb 21 2015 02:01
Contributing would be a great way to upskill, and we're all quite friendly.
Hardy Jones
@joneshf
Feb 21 2015 14:36
Question about ramda-fantasy
is there a purpose to having Reader rather than just putting the functions on Function?
It seemslike it'd be a bit more cumbersome to use the abstraction that way
Hardy Jones
@joneshf
Feb 21 2015 14:42
I mean, the only reason Reader exists in haskell is because it's a specific case of ReaderT
but Reader r a = r -> a
Hardy Jones
@joneshf
Feb 21 2015 14:52

The reason I'm asking is because functions like ifElse could be written with ramda-fantasy:

var ifElse = function(pred, tru, fls, x) {
  return Reader(function(b, t, f) { return b ? t : f; }).ap(pred).ap(tru).ap(fls).run(x);
}

BUt if it were on Function, we could just say:

var ifElse = R.liftN(3, function(b, t, f) { return b ? t : f; })
Of course, since this is Apply we're dealing with here, everything is strictly evaluated
so it computes both the then and else branches
BUt you could use Chain and make it lazy so it would only compute one branch
Hardy Jones
@joneshf
Feb 21 2015 14:58
I guess my point is that you're not really getting much from the Reader abstraction unless you actually start with ReaderT
Hardy Jones
@joneshf
Feb 21 2015 15:03
no wait
it's actually worse than that I think
Hardy Jones
@joneshf
Feb 21 2015 15:14
var ifElse = function(pred, tru, fls, x) {
  return Reader(function(b, t, f) { return b ? t : f; }).ap(Reader(pred)).ap(Reader(tru)).ap(Reader(fls)).run(x);
}
or something
Hardy Jones
@joneshf
Feb 21 2015 15:40
hmm, I can't actually get Reader to work
oh I see
Hardy Jones
@joneshf
Feb 21 2015 15:45
it's not taking arguments
Scott Sauyet
@CrossEye
Feb 21 2015 22:38
Reader was a contribution from a community member. I'm not sure if @buzzdecafe was following it entirely. I know that I didn't. Part of that is that I'm still a rank beginner with Haskell, so half the times I don't know what some of these types are for.