These are chat archives for ramda/ramda

2nd
Jun 2016
Ronn
@ronnross
Jun 02 2016 02:43
Hi I'm trying to pipe some functions together like so
var result = R.pipe(
  R.identity(window),
  R.pluck("navigator")
);

console.log(result)
but when result is logged out it another function function (){return n.apply(this,arguments)}
How would one get the value out of result?
Gabe Johnson
@gabejohnson
Jun 02 2016 02:47
result()?
Ronn
@ronnross
Jun 02 2016 02:49
when I run result() I get
"TypeError: t.apply is not a function
    at https://cdn.jsdelivr.net/ramda/0.18.0/ramda.min.js:6:4815
    at https://cdn.jsdelivr.net/ramda/0.18.0/ramda.min.js:6:124
    at meceyacoqe.js:8:38"
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 02:52
R.identity
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 02:53
Identity takes a single parameter, so R.identity(window) returns window, which is probably not a function
Ronn
@ronnross
Jun 02 2016 02:55
Oh I think I see. Returns just the window value.
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 02:55
pipe will return a function, which should take some arguments
Logging the result of calling pipe should always log a function.
Ronn
@ronnross
Jun 02 2016 02:57
Awesome I have it worked out now. Thanks @Bradcomp
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 02:58
Great!
Ronn
@ronnross
Jun 02 2016 02:59
I was also using pluck wrong I think. I think pluck only works with list that contain objects. Not on an object itself. Is that correct?
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 03:00
Yes
R.prop
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 03:00
R.prop('navigator', window) will return window.navigator
Ronn
@ronnross
Jun 02 2016 03:01
great thanks again
Tushar Mathur
@tusharmath
Jun 02 2016 09:14
Is there a function that converts args into named params —
const toNamed = ([a, b, c]) => ({a, b, c})
R.zipObj i think
Sorry :D
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 13:53
R.apply
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 13:54
:point_up: Does that do what you want @tusharmath ?
@ram-bot
R.apply((a, b) => a + b)[1, 2]
ram-bot
@ram-bot
Jun 02 2016 13:55
undefined
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 13:55
huh
Gabe Johnson
@gabejohnson
Jun 02 2016 13:55
you put the array outside of the call
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 13:57
I saw that right before you said it
@ram-bot
R.apply((a, b) => a + b)([1, 2])
ram-bot
@ram-bot
Jun 02 2016 13:57
3
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 13:57
Thanks
Gabe Johnson
@gabejohnson
Jun 02 2016 14:00
n+2 eyes are better than 2
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 14:03
lol... maybe I should do coffee before coding next time
Raine Virta
@raine
Jun 02 2016 14:16
I still don't see how it's relevant to the question
Gabe Johnson
@gabejohnson
Jun 02 2016 14:21
@tusharmath can you give an example usage?
Michael Litchard
@mlitchard
Jun 02 2016 14:55
Hi guys. Just discovered ramda. Very nice.
I was wishing for a ramda-based test suite where we compose an action from smaller actions and then execute
Ronn
@ronnross
Jun 02 2016 15:06
Hey still very new to Ramda and functional, I was hoping someone could check out this piece of code and maybe give advice?

let getUserAgent = 
  R.once
    ( R.pipe
      ( R.prop("navigator")
      , R.prop("userAgent")))

let getOs = 
      agent => 
        ({ name: getOsName(agent)
        , version: getOsVersion(agent)})

let os = 
  R.pipe
    ( getUserAgent
    , getOs) 

l(os(window));
This piece of code is parsing out the os name and version from the userAgent off the window object.
Lewis
@6ewis
Jun 02 2016 15:45
@ronnross what's l()
Ronn
@ronnross
Jun 02 2016 15:45
oh sorry it is just console.log
Ricardo Pallas
@RPallas92
Jun 02 2016 15:48
I’m lifting a function to operate with folktale/data.task. Is it possible is there an error with lifting if the task rejects?
Lewis
@6ewis
Jun 02 2016 15:49
@ronnross it looks good to me
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 15:50
@ronnross Looks pretty good. check out R.path for accessing a nested property. i.e.
let getUserAgent = R.once(R.path(['navigator', 'userAgent']));
Ronn
@ronnross
Jun 02 2016 15:51
Thanks everyone
Lewis
@6ewis
Jun 02 2016 15:51
@ronnross you're doing better than I ever did when I started with it
Ronn
@ronnross
Jun 02 2016 15:51
Hey thanks
Tushar Mathur
@tusharmath
Jun 02 2016 18:41
@Bradcomp @gabejohnson R.zipObj works well.
Gabe Johnson
@gabejohnson
Jun 02 2016 18:46
const toNamed = R.zipObj([‘a’,’b’,’c’])
?
This message was deleted
Tushar Mathur
@tusharmath
Jun 02 2016 18:49
Yes
Gabe Johnson
@gabejohnson
Jun 02 2016 18:51
just watching a talk about elm. love the currying!
Emilio Srougo
@Emilios1995
Jun 02 2016 21:29
Hi people! I have a problem.
How transform this: [1, 2, 3, 4, 5, 6, 7, 8, 9]
to this: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Denis Stoyanov
@xgrommx
Jun 02 2016 21:30
@ram-bot
R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7, 8, 9])
ram-bot
@ram-bot
Jun 02 2016 21:30
[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]
Denis Stoyanov
@xgrommx
Jun 02 2016 21:31
@Emilios1995 splitEvery
Emilio Srougo
@Emilios1995
Jun 02 2016 21:31
That's convenient. Thanks!
David Chambers
@davidchambers
Jun 02 2016 21:36
Little gist on the beauty of monads (with Ramda and Sanctuary). You may find it helpful. :)
Scott Sauyet
@CrossEye
Jun 02 2016 21:37
@mlitchard: sounds great. When do you think you can complete it? :smile:
Brad Compton (he/him)
@Bradcomp
Jun 02 2016 21:49
@davidchambers That is really nice!
Scott Sauyet
@CrossEye
Jun 02 2016 21:49
@LeonineKing1199: sorry, been offline a few days. We have a curry that works great with functions which properly report their true arity. We have curryN which let's us specify the arity to which we'd like to curry the function, regardless of the arity it reports. It would be nice to also have some clean mechanism that would specify something to the effect of "arity 3, but the third one is optional", so that it would be called when we supplied two or three parameters. Even better would be if it still also allowed an easy technique to call it with only two and not automatically fire the underlying function. But that last might be too much to hope for. Those are my ideas anyway.
LeonineKing1199
@LeonineKing1199
Jun 02 2016 21:50

Awesome. Now that's something we can work with :)

I think if we play off of Ramda's isPlaceholder mechanism with an isOptional type, we might get what you want. Maybe.

Scott Sauyet
@CrossEye
Jun 02 2016 21:55
I'm not particularly hopeful myself. But I really like your enthusiasm!
@davidchambers: That's excellent!
LeonineKing1199
@LeonineKing1199
Jun 02 2016 21:57
I now know what you're talking about though. The invocation mechanism vs. allowing extra currying is an interesting problem and it's a feature that'd I'd like to see.
We can drum something up.
David Chambers
@davidchambers
Jun 02 2016 22:21
Thanks, @Bradcomp and @CrossEye. I'm getting better at explaining the idea with practice.
LeonineKing1199
@LeonineKing1199
Jun 02 2016 22:50
Actually, that is a more straight-forward use of monads. You can probably get all the OOP kids on-board by saying, "imagine a class that has methods that takes functions and applies them to the encapsulated data"