These are chat archives for ramda/ramda

5th
Apr 2016
Scott Sauyet
@CrossEye
Apr 05 2016 00:55
Anyone believe that the lodash/fp numbers are real?: https://twitter.com/sjfloat/status/717010007649361922
Hardy Jones
@joneshf
Apr 05 2016 01:20
R.nth
Hardy Jones
@joneshf
Apr 05 2016 01:20
R.lift
Hardy Jones
@joneshf
Apr 05 2016 01:20
R.liftN
Hardy Jones
@joneshf
Apr 05 2016 01:20
meh, that doesn't help
In any case...
nth has an additional type signature: Number → String → String
So lift(nth) :: [Number] -> [String] -> [String]
You can always try it and see what you get
@ram-bot R.lift(R.nth)([3, 1, 2, 2, 5, 0, 1], [['g','e','s','m','s','a']])
ram-bot
@ram-bot
Apr 05 2016 01:25
[ 'm', 'e', 's', 's', 'a', 'g', 'e' ]
Drew
@dtipson
Apr 05 2016 01:25
No, I know that's what it does, it's the second argument that requires an extra level that isn't the final signature I'm looking for
Hardy Jones
@joneshf
Apr 05 2016 01:26
it doesn't require it though
Drew
@dtipson
Apr 05 2016 01:30
it's a really cool use of lift, just happen to have a reason to wrap Array.of around the last argument so it can be passed as a flat Array
Risto Novik
@riston
Apr 05 2016 07:44
R.find
Lewis
@6ewis
Apr 05 2016 12:04
@joneshf what does lift do
Barney Carroll
@barneycarroll
Apr 05 2016 12:06
R.lift
Lewis
@6ewis
Apr 05 2016 13:39
anyone use gulp/browserify by any chances?
James Forbes
@JAForbes
Apr 05 2016 13:42
yep
wait, is that a and or an or
I don't use gulp, just browserify
Hardy Jones
@joneshf
Apr 05 2016 14:00
@6ewis in the easy case, it takes a function of arity n and n arrays, then applies the function to every permutation of the arrays.
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 14:00
I use Gulp and Browserify @6ewis
Hardy Jones
@joneshf
Apr 05 2016 14:00
This message was deleted
@ram-bot
R.lift((x, y) => `first: ${x}, second: ${y}`)([1,2,3], [4,5,6])
ram-bot
@ram-bot
Apr 05 2016 14:01
[ 'first: 1, second: 4',
  'first: 1, second: 5',
  'first: 1, second: 6',
  'first: 2, second: 4',
  'first: 2, second: 5',
  'first: 2, second: 6',
  'first: 3, second: 4',
  'first: 3, second: 5',
  'first: 3, second: 6' ]
Hardy Jones
@joneshf
Apr 05 2016 14:02
@ram-bot
R.lift((x, y, z) => `first: ${x}, second: ${y}, third: ${z}`)([1,2,3], [4,5,6], [7, 8])
ram-bot
@ram-bot
Apr 05 2016 14:02
[ 'first: 1, second: 4, third: 7',
  'first: 1, second: 4, third: 8',
  'first: 1, second: 5, third: 7',
  'first: 1, second: 5, third: 8',
  'first: 1, second: 6, third: 7',
  'first: 1, second: 6, third: 8',
  'first: 2, second: 4, third: 7',
  'first: 2, second: 4, third: 8',
  'first: 2, second: 5, third: 7',
  'first: 2, second: 5, third: 8',
  'first: 2, second: 6, third: 7',
  'first: 2, second: 6, third: 8',
  'first: 3, second: 4, third: 7',
  'first: 3, second: 4, third: 8',
  'first: 3, second: 5, third: 7',
  'first: 3, second: 5, third: 8',
  'first: 3, second: 6, third: 7',
  'first: 3, second: 6, third: 8' ]
Hardy Jones
@joneshf
Apr 05 2016 14:02
and so on
It's more general than that though.
and the result depends wholy on the Apply effects of the arguments you pass to it.
for instance...
@ram-bot
R.lift((x, y) => `first: ${x}, second: ${y}`)(S.Just(1), S.Just(2))
ram-bot
@ram-bot
Apr 05 2016 14:07
Just("first: 1, second: 2")
Hardy Jones
@joneshf
Apr 05 2016 14:07
@ram-bot
R.lift((x, y) => `first: ${x}, second: ${y}`)(Nothing, S.Just(2))
ram-bot
@ram-bot
Apr 05 2016 14:07
ReferenceError: Nothing is not defined
Hardy Jones
@joneshf
Apr 05 2016 14:07
@ram-bot
R.lift((x, y) => `first: ${x}, second: ${y}`)(S.Nothing, S.Just(2))
ram-bot
@ram-bot
Apr 05 2016 14:07
Error: First argument to _arity must be a non-negative integer no greater than ten
Hardy Jones
@joneshf
Apr 05 2016 14:07
beh
@ram-bot
R.lift((x, y) => `first: ${x}, second: ${y}`)(S.Nothing(), S.Just(2))
ram-bot
@ram-bot
Apr 05 2016 14:08
Nothing()
Hardy Jones
@joneshf
Apr 05 2016 14:13
Or one of my favorite examples:
Julien Goux
@jgoux
Apr 05 2016 14:15
Hello
Hardy Jones
@joneshf
Apr 05 2016 14:22
hmm, something wrong with my implmentation, so ignore that last example :D
@jgoux hi!
Dalibor Novak
@BorePlusPlus
Apr 05 2016 18:18
Hello - a quick one. I am sure it was probably mulled over a few times already, but how does one create a flatMap in ramda?
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 18:19
R.chain
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 18:20
@BorePlusPlus chain is flatMap in Ramda
Dalibor Novak
@BorePlusPlus
Apr 05 2016 18:20
Cheers guys - I am sure there is a reasonable explanation behind the name as well :)
oh it was just one guy - well in that case Cheers @Bradcomp
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 18:21
I ran into the exact same thing a few weeks ago
I know there is a reason for the name, but I am not saturated in FP enough to know what that reason is.
Dalibor Novak
@BorePlusPlus
Apr 05 2016 18:22
I am in the same place.
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 18:23
Drew
@dtipson
Apr 05 2016 18:36
Array.prototype.flatMap is a proposal for ES(8?) There are a lot of fights over coordination of namespaces
Once a particular method on a common type is officially defined, things get super complicated fast, especially if the implementation differs.
Drew
@dtipson
Apr 05 2016 18:41
with languages like Haskell, knowing that something is an Applicative means that you can rely on it having a predictable interface for that
but with javascript, methods like .map for the core Functor method don't HAVE to be named .map They could be named, say, .then
while still obeying the Functor laws. Or you could have something with a .map method that doesn't obey the laws. Hence the fight over making sure that anything using a particular namespace across types has exactly the same signature, and if not, moving to a different namespace
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 18:51
@dtipson So chain is a safer function name than flatMap, in terms of dynamically dispatching?
Drew
@dtipson
Apr 05 2016 18:52
right
Because within months, Array.flatMap could get approved and made official with a slightly different syntax than chain
I filed an issue requesting that .ap be defined on native Arrays if .flatMap/.flatten will be: bterlson/proposal-flatMap#10
Drew
@dtipson
Apr 05 2016 18:57
their flatMap seems roughly to fit what ramda and fantasy-land expect
Not to hate on the choice of "then" for promises: it IS a slightly different thing, since it combines both map/flatmap. But javascript forces those conflicts
Lewis
@6ewis
Apr 05 2016 19:20
@Bradcomp talking about chain, what do you think is the diff between chaining and composition
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 19:21
@6ewis Do you mean chain like Ramda's chain, or like the underscore / lodash version?
Drew
@dtipson
Apr 05 2016 19:22
I still need to study composeK some more to have a good sense of that. :)
Lewis
@6ewis
Apr 05 2016 19:23
@Bradcomp chain like underscore
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 19:31
To me, compose / pipe can be easier to reason about. Function composition makes sense to me. _.chain seems more ad hoc, but with compose I know what's going on under the surface. They have similar functionality though, I think it might just be preference.
I'm weird though. I prefer compose to pipe in most cases (right to left vs. left to right), even though I think that may be a minority view (not sure though).
Lewis
@6ewis
Apr 05 2016 19:34
@Bradcomp =) sounds like you were made for FP
Drew
@dtipson
Apr 05 2016 19:34
.map and .chain basically handle callback functions with different signatures. Both can be imagined as forms of composition (but underscore/lodash's _.chain is composition on the level of a map rather than chain/flatMap operation)
John-David Dalton
@jdalton
Apr 05 2016 19:35
@Bradcomp You'll dig Why using _.chain is a mistake.
Drew
@dtipson
Apr 05 2016 19:36
I'm with you on compose @Bradcomp . Not just because of the compose(f,g) = f(g(x)) thing, but also just intuitively, if you think about passing in the variable when you run a composition, it gets pushed in from the right, so you can think of it as encountering the rightmost function first.
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 19:38
@dtipson EXACTLY. The data starts at the end and moves left.
Drew
@dtipson
Apr 05 2016 19:42
yeah, it squishes together into a result. It sort of depends on whatever weird mental model you have of what's happening: feeding something into a predefined pipe... is pipe. But composition is easier think about in some ways when you're feeding compositions and functions into other compositions and want to picture the result
Brad Compton (he/him)
@Bradcomp
Apr 05 2016 19:45
@jdalton :+1:
Denis Stoyanov
@xgrommx
Apr 05 2016 20:00
ramda should works with async iterator https://github.com/ReactiveX/IxJS#asynciterable
LeonineKing1199
@LeonineKing1199
Apr 05 2016 20:23
Do you even need generators to do that though?
Just have an array of promises and on each resolve, evaluate it according to the, um, I guess transformation stack?
Well, I guess generators give you a way to make a lazily-evaluated arbitrarily long sequence...
I think we should focus more on taking arrays of Promises and applying transformative and reductive functions on them.
Also, would this wait for all Promises to resolve or just happen as each one resolves?