These are chat archives for ramda/ramda

29th
May 2016
Chet Harrison
@ChetHarrison
May 29 2016 04:22
hey @joneshf ! sorry we have a holiday weekend here can we connect on Tuesday?
Hardy Jones
@joneshf
May 29 2016 06:33
sure
andretshurotshka
@goodmind
May 29 2016 10:23
@Bradcomp I can't use merge in this case, because with it I can't do this:
let transformations = {
   chat_id: defaultTo(1),
   text: defaultTo('hi'),
   reply: compose(JSON.stringify, defaultTo({}))
}
Tushar Mathur
@tusharmath
May 29 2016 14:14
Hellos, I am new to Ramda and going thru the the learning curve. I have the following function that I want to make point free —
const matches = value => R.where({type: R.equals(value)})
Brad Compton (he/him)
@Bradcomp
May 29 2016 15:55
@goodmind That makes sense, I was just mentioning it in case.
@tusharmath That looks pretty good to me! There are a couple of built ins that could help you though... http://goo.gl/psu614
checkout whereEq and propEq
Tushar Mathur
@tusharmath
May 29 2016 16:02
Wow! thanks @Bradcomp There are some really awesome functions in ramda
Brad Compton (he/him)
@Bradcomp
May 29 2016 16:12

@goodmind I might still consider doing the operation in two steps (I know... performance).

compose(evolve(transformations), merge(defaults)) may be a little clearer than the pickAll solution

Tushar Mathur
@tusharmath
May 29 2016 16:52
Is there a function to convert args to array ? (a, b, c, d) => [a, b, c, d]
Tushar Mathur
@tusharmath
May 29 2016 16:54
I couldn't figure out how to use it in this case
@joneshf Do i need to use arguments ?
Hardy Jones
@joneshf
May 29 2016 16:54
Array.prototype.slice.call(arguments);
Or some such
Tushar Mathur
@tusharmath
May 29 2016 16:56
Needs to be curried though
Hardy Jones
@joneshf
May 29 2016 17:05
what needs to be curried?
Brad Compton (he/him)
@Bradcomp
May 29 2016 17:11
R.unapply
Brad Compton (he/him)
@Bradcomp
May 29 2016 17:11
R.apply
Tushar Mathur
@tusharmath
May 29 2016 17:11
Perfect!
Denis Stoyanov
@xgrommx
May 29 2016 19:08
@tusharmath (...args) => ...) or R.unapply(R.identity)
@ram-bot
R.unapply(R.identity)(1,2,3)
ram-bot
@ram-bot
May 29 2016 19:08
[ 1, 2, 3 ]
Tushar Mathur
@tusharmath
May 29 2016 19:09
Great!
Thanks!
Tushar Mathur
@tusharmath
May 29 2016 19:11
@xgrommx You've always got the best links to read from :+1:
Łukasz
@paroxyzm
May 29 2016 19:12
Why is the signature of pipeK: Chain m => ((a → m b), (b → m c), …, (y → m z)) → (m a → m z)
shouldn't it be: Chain m => ((a → m b), (b → m c), …, (y → m z)) → (a → m z)
?
Denis Stoyanov
@xgrommx
May 29 2016 19:13
@tusharmath thx :+1:
@paroxyzm hm, it's Kleisli composition
@paroxyzm (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
Łukasz
@paroxyzm
May 29 2016 19:15
So it kinda like second one
Denis Stoyanov
@xgrommx
May 29 2016 19:17
@paroxyzm exist right and left version of Kleisli composition <=< and >=>
Brad Compton (he/him)
@Bradcomp
May 29 2016 19:18
@paroxyzm See here for a discussion of that exact issue: ramda/ramda#1781
Łukasz
@paroxyzm
May 29 2016 19:22
Thanks, I assumed it's the same as in haskell
Taylor Hurt
@thurt
May 29 2016 19:23
general question on ramda-fantasy: which type signature to use? someone once said IO monad is overkill for web pages (hence signature 3)
consoleLog
//:: IO(String -> _)
//:: String -> IO _
//:: String -> _
Taylor Hurt
@thurt
May 29 2016 19:58
In regards to signatures 1 and 2 I havent heard any opinions on which is preferred in what IO situations, or whether one is more idiomatic than the other
LeonineKing1199
@LeonineKing1199
May 29 2016 20:12

Is there a function to convert args to array ? (a, b, c, d) => [a, b, c, d]

I think it's easier to convert arguments to an array by calling R.values on it. It's just an object. I'm curious if the length field winds up there but I don't think it does.

Edit: values will work but you could just as easily use Array.from which has the boon of being vanilla JS so it doesn't even require Ramda.

Rafe
@rjmk
May 29 2016 21:17
@joneshf That's really cool! I haven't looked into GADTs really but will do so. Is basically the idea behind the dependent types -> GADT conversion that we don't really need any information on the value of the arguments to the constructor, we just need to inspect the type a bit more deeply?