These are chat archives for ramda/ramda

28th
Sep 2016
Risto Novik
@riston
Sep 28 2016 08:57
Ramda repl is broken currently, unable to download the libraries? http://ramdajs.com/repl/
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 09:15
Yeah, sanctuary is not defined
Denis Stoyanov
@xgrommx
Sep 28 2016 09:32
I got the same result now
Stefano Vozza
@svozza
Sep 28 2016 10:03
@syaiful6 looks like https://wzrd.in/ where sanctuary is hosted is down
that site is returning a 502 with an nginx error
Alastair Hole
@afhole
Sep 28 2016 10:33
@dtipson Not sure I follow you, are you referring to Haskell's on? My limited understanding is that it can apply a function to two values before passing the results to a third function
Denis Stoyanov
@xgrommx
Sep 28 2016 10:45
@afhole on has another behaviour
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
like sortBy (compareonfst) a b
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:14
Can anybody recommend a good refactoring for this? The REPL is broken, so I'll paste it here:
const getClientNameLabel = (copy, resource) =>
  R.join(' ', [copy.linkLabelSecondary, resource.clientName]);
Denis Stoyanov
@xgrommx
Sep 28 2016 11:15
@aaronmcadam useWith
@aaronmcadam useWith(R.unapply(R.join(' ')), [prop('linkLabelSecondary'), prop('clientName')])(copy, resource) try it
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:18
Sweet, thanks @xgrommx !
The answer wasn't converge! This is where you tell me useWith is implemented with converge… :D
Denis Stoyanov
@xgrommx
Sep 28 2016 11:19
@aaronmcadam no, converge will be implemented with lift not useWith
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:19
No, I mean useWith. I know converge is implemented with lift, thanks to you
Denis Stoyanov
@xgrommx
Sep 28 2016 11:20
how can I find in gitter by keyword?
Francis
@FrancisVega
Sep 28 2016 11:22
tip: for fast coding testing I'm using codepen while REPL is down...
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:23
Doh, thanks :)
Denis Stoyanov
@xgrommx
Sep 28 2016 11:23
I use mancy =)
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:23
ohh looks nice
Denis Stoyanov
@xgrommx
Sep 28 2016 11:25
@aaronmcadam you don't need web page with mancy =)
Craig Dallimore
@craigdallimore
Sep 28 2016 11:25
Hang in there, I'm working on getting a temporary repl available while the browserify-cdn is down.
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 11:26
Cool, thanks @craigdallimore!
Craig Dallimore
@craigdallimore
Sep 28 2016 11:27
Offline support is certainly something I'm thinking about
and use https://rawgit.com/ramda/ramda/master/dist/ramda.js for actual last version =)
Ahh, shortlinks won't work properly
Sorry, best I can achieve in a lunchbreak - will attempt to do better after work
Denis Stoyanov
@xgrommx
Sep 28 2016 11:54
Mancy - REPL(0) 2016-09-28 14-53-49.png
Alastair Hole
@afhole
Sep 28 2016 11:57
@xgrommx I'm not sure of the distinction, I fear I may be over my head. It's not just straight function application though is it?
In reference to @dtipson "isn't that basically what () is, in a way? It's just not available as an infix operator"
Not sure I follow
Denis Stoyanov
@xgrommx
Sep 28 2016 11:59
@afhole on = f => g => a => b => useWith(f, [g, g])(a, b)
Alastair Hole
@afhole
Sep 28 2016 11:59
Right
Confused by @dtipson's comment on infix ()
i.e. you can't do fn value nor can you do fn () value you have to do fn(value)
Denis Stoyanov
@xgrommx
Sep 28 2016 12:02
@afhole so imaginary you can use fn () value also fn $ value but this only for clarification.
Alastair Hole
@afhole
Sep 28 2016 12:03
OK
Denis Stoyanov
@xgrommx
Sep 28 2016 12:03
@afhole also it about (a -> b) -> a -> b
@afhole js doesn't has infix notation =(
Alastair Hole
@afhole
Sep 28 2016 12:04
Sure, so how does that relate to () being on? Is that was @dtipson meant? Or have I misunderstood (I really appreciate your patience! :) )
Is it to do with being able to partially apply function application if you have infix ()?
I am definitely in over my head ;)
Denis Stoyanov
@xgrommx
Sep 28 2016 13:00
@aaronmcadam
// converge/lift/sequence
converge(add, [add, multiply])(10, 20)
compose(sum, sequence(always)([add, multiply]))(10, 20)
lift(add)(add, multiply)(10, 20)

// useWith, zip
useWith(add)([add(10), multiply(20)])(1, 2)
compose(apply(add), zipWith(call, [add(10), multiply(20)]), unapply(identity))(1, 2)
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 13:01
Thanks @xgrommx that helps
Alastair Hole
@afhole
Sep 28 2016 13:30
Hopefully @dtipson can elaborate
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 14:43
There's something I'm missing here, I know it:
const getMessage = (messages, errorStatus) => {
  if (errorStatus === 401) {
    return messages.unauthorised;
  }

  return messages.serverError;
};
I'm sure I've refactored a function like this before
Denis Stoyanov
@xgrommx
Sep 28 2016 14:47
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 14:48
I was trying ifElse, but I couldn't figure it out
It's another binary function, I'm still struggling with those
maybe I should use objects as arguments for everything instead to make them unary:D
Francis
@FrancisVega
Sep 28 2016 14:49
I'm interested how to use ifElse, I'm experimenting things in codepen...
Denis Stoyanov
@xgrommx
Sep 28 2016 14:52
@FrancisVega ifElse(condition, always(value1), always(value2))
@FrancisVega R.ifElse(R.gt(20), R.always('yes'), R.always('No'))(10)
Francis
@FrancisVega
Sep 28 2016 14:53
thanks so much!! @xgrommx :)
Denis Stoyanov
@xgrommx
Sep 28 2016 14:54
@FrancisVega everywhere everything is function :smile:
Francis
@FrancisVega
Sep 28 2016 14:55
I have to say I'm soooooo new in FP :S sorry about that
Denis Stoyanov
@xgrommx
Sep 28 2016 14:55
np
Francis
@FrancisVega
Sep 28 2016 14:56
maybe I have to talk in a FP gitter :P
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 14:56
Sorry @xgrommx, I think I'm nearly there… http://jsbin.com/kewodazobo/edit?js,console
Looks like ifElse is unary?
Denis Stoyanov
@xgrommx
Sep 28 2016 15:01
@aaronmcadam yes
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 15:02
hmm I can't figure out how to make it use one argument for the predicate and then use another for the behaviour.
Denis Stoyanov
@xgrommx
Sep 28 2016 15:03
@aaronmcadam really ugly version will be if you want pointfree =)
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 15:04
Yeah I thought so :)
Thanks though, I need more practice with binary and ternary funcs
jaawerth
@jaawerth
Sep 28 2016 15:11
@aaronmcadam Personally I like making an object or Map of error codes to message:
const applyError = R.ifElse((errMap, status) => errMap.howOwnProperty(status),  (obj, key) => obj[key], R.prop('defaultmsg'))
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 15:12
Yeah I had something like that before, but I decided to explicitly check
I was using propOr before
Thanks for the idea though @jaawerth :)
jaawerth
@jaawerth
Sep 28 2016 15:13
yeah that makes more sense, haha - though IMO for status codes, it's better to actually use cascading conditions ala if-else chains, since you might be interested in both specific statusCodes and ranges of statusCodes - for example, > 500 is a server error, etc. Depends on usecase, of course
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 15:13
That's true, for this, I only have 401 or 500 basically
so I thought I'd remove the dynamism because it wasn't really needed
If I was handling a lot more, I'd revert to a direct object mapping
Denis Stoyanov
@xgrommx
Sep 28 2016 15:30
don't try to make everything as pointfree.
Drew
@dtipson
Sep 28 2016 16:09
@afhole what I meant was that you could imagine a language syntax that would allow you to write out a function and then use an operator like () that says "apply the value on the right to the function on the left. That is. add () 2 would be the same as add(2). Some languages even offer that syntax. Haskell does sort of, I believe, but in practice it's redundant, because it's so central to the language that you don't even need an operator, you just type add 2
LeonineKing1199
@LeonineKing1199
Sep 28 2016 16:11
add(2) so all the C programmers aren't left behind XD
add(1)(2) reads more naturally for Old "C" McBeardson like me
Drew
@dtipson
Sep 28 2016 16:13
Though now that I look back at your comment, the link you sent took me to ($) , but you may have been talking about on (what was actually in the jumplink url) in which case I was talking about totally the wrong thing
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 16:13
Ever since I heard it that style being called "butts" (Brian Lonsdorf), I've tried to avoid it :D
LeonineKing1199
@LeonineKing1199
Sep 28 2016 16:14
Oh, you mean the "extra" parens?
It's true, you don't need them
Aaron Mc Adam
@aaronmcadam
Sep 28 2016 16:14
haha yeah
It never bothered me before :D
LeonineKing1199
@LeonineKing1199
Sep 28 2016 16:14
But if ghc accepts it, it's all good lol
Plus, I feel it's easier for C programmers to read it like that
add(a)(b) = a + b;
Drew
@dtipson
Sep 28 2016 16:15
I blame the behavior of html jumplinks for items at the end of pages for the confusion
Alastair Hole
@afhole
Sep 28 2016 16:32
@dtipson I think I see; excuse my ignorance, how does that relate to Haskell's on? I read your comment in reference to that, not certain if that's what you meant?
Ohhhhh I just read your second message
You were talking about $!
Mystery solved :)
@dtipson Yes I agree, fragments in the last viewport-height's worth of the page are a bit lacking - maybe they should add whitespace ala scroll acceleration bounce
Alastair Hole
@afhole
Sep 28 2016 16:38
I'd guess your viewport was about 800px in height then...
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:01
Is the Ramda REPL broken?
Brad Compton (he/him)
@Bradcomp
Sep 28 2016 18:03
Yeah :-(
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:03
Oh no!!!!!
Brad Compton (he/him)
@Bradcomp
Sep 28 2016 18:35
@ram-bot
map(inc, S.Just(1))
ram-bot
@ram-bot
Sep 28 2016 18:36
Just(2)
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:39
@ram-bot
ap(S.Just(inc), S.Just(1))
ram-bot
@ram-bot
Sep 28 2016 18:39
Just(2)
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:39
Yay!
Huh, so Rambot still has Sanctuary
I'm surprised the REPL doesn't
@ram-bot
while(true) {}
Is it gonna do it?
ram-bot
@ram-bot
Sep 28 2016 18:42
Script execution timed out.
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:42
Oh wow.
Time to abuse that into submission
@ram-bot
'use strict'; let i = 0; while (true) { ++i; } console.log(i);
ram-bot
@ram-bot
Sep 28 2016 18:43
Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:44
@ram-bot
'use strict'; let i = 0; while (true) { ++i; } console.log(i);
ram-bot
@ram-bot
Sep 28 2016 18:44
Script execution timed out.
LeonineKing1199
@LeonineKing1199
Sep 28 2016 18:45
Okay, I'll stop trying to hack the ramda bot
Paul
@pauloliver
Sep 28 2016 18:46
@ram-bot source
Craig Dallimore
@craigdallimore
Sep 28 2016 18:49
If you need a ramda repl in the meantime: https://craigdallimore.github.io/repl/
Shortlinks wont work I'm afraid.
Woah, rambot is awesome!
Brad Compton (he/him)
@Bradcomp
Sep 28 2016 19:41
This message was deleted
LeonineKing1199
@LeonineKing1199
Sep 28 2016 19:50
@ram-bot
global.Boolean = () => throw new Error();
ram-bot
@ram-bot
Sep 28 2016 19:50
Unexpected token throw
LeonineKing1199
@LeonineKing1199
Sep 28 2016 19:50
@ram-bot
global.Boolean = () => { throw new Error(); };
ram-bot
@ram-bot
Sep 28 2016 19:51
global is not defined
LeonineKing1199
@LeonineKing1199
Sep 28 2016 19:51
@ram-bot
window.Boolean = () => { throw new Error(); };
ram-bot
@ram-bot
Sep 28 2016 19:51
window is not defined
LeonineKing1199
@LeonineKing1199
Sep 28 2016 19:51
Good. Job. Ramda people.
Paul
@pauloliver
Sep 28 2016 19:51
@ram-bot status
ram-bot
@ram-bot
Sep 28 2016 19:51
All systems operational.
Denis Stoyanov
@xgrommx
Sep 28 2016 19:52
@ram-bot module
ram-bot
@ram-bot
Sep 28 2016 19:52
module is not defined
Denis Stoyanov
@xgrommx
Sep 28 2016 19:52
:smile:
LeonineKing1199
@LeonineKing1199
Sep 28 2016 19:56
The coding for the REPL is pretty legit!
My b, ram bot
Drew
@dtipson
Sep 28 2016 20:29
@afhole yep. and if you know how Haskell's on works (I don't!), you hardly needed a lecture on basic apply :)