These are chat archives for ramda/ramda

27th
Jun 2016
Vladimir Starkov
@iamstarkov
Jun 27 2016 12:43
hey, can we do not bundle everything for commonjs consumers?
Screen Shot 2016-06-27 at 14.34.59.png
296 line, 446 line, 4074 line — all of this is pretty inconvenient

this is much better

tap (node_modules/.store/ramda@0.21.0/_/src/map.js:10:9)
node_modules/.store/ramda@0.21.0/_/src/pipeP.js:10:28
f1 (node_modules/.store/ramda@0.21.0/_/src/pipe.js:13:27)
node_modules/.store/ramda@0.21.0/_/src/map.js:10:22
node_modules/.store/ramda@0.21.0/_/src/ifElse.js:10:35
node_modules/.store/ramda@0.21.0/_/src/filter.js:20:35
node_modules/.store/ramda@0.21.0/_/src/when.js:15:27

than actual stack trace:

tap (node_modules/.store/ramda@0.21.0/_/dist/ramda.js:4074:9)
node_modules/.store/ramda@0.21.0/_/dist/ramda.js:466:28
f1 (node_modules/.store/ramda@0.21.0/_/dist/ramda.js:446:27)
node_modules/.store/ramda@0.21.0/_/dist/ramda.js:296:22
node_modules/.store/ramda@0.21.0/_/dist/ramda.js:296:35
node_modules/.store/ramda@0.21.0/_/dist/ramda.js:296:35
node_modules/.store/ramda@0.21.0/_/dist/ramda.js:48:27
Vladimir Starkov
@iamstarkov
Jun 27 2016 12:48
@CrossEye @davidchambers what do you think?
Scott Sauyet
@CrossEye
Jun 27 2016 13:28
Well, it
's already available that way. Only with the somewhat annoying 'src' node in the name.
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:29
yep
Scott Sauyet
@CrossEye
Jun 27 2016 13:29
We've talked about removing that, but no one has done anything about it. It doesn't sound hard. Want to take a stab at it?
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:29
yep, i want
Scott Sauyet
@CrossEye
Jun 27 2016 13:29
It should only be in the bit where we build the NPM package.
Go for it!
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:31
not sure its that easy
Scott Sauyet
@CrossEye
Jun 27 2016 13:31
No? I haven'
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:31
i will try to do smth with ramda publishing
Scott Sauyet
@CrossEye
Jun 27 2016 13:31
t looked that carefully, but it seems like it should be pretty straightforward.
ok
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:32
my approach is to bundle-minify for client-side usage, and plain commonjs for nodejs usage
is it good enough?
right now there is Makefile and template which are a bit strange

my approach is to bundle-minify for client-side usage, and plain commonjs for nodejs usage

@CrossEye is that fine?

Scott Sauyet
@CrossEye
Jun 27 2016 13:34
Well, I was thinking that in the package that is generated for NPM, we copy the src folder. If we flatten that into the root instead, I think we pretty well do what's needed.
Then require('ramda/map').
This doesn't publish the individual packages like lodash-map. I don't think I'm ready for that.
Vladimir Starkov
@iamstarkov
Jun 27 2016 13:38
no, i'm also not ready for individual packages
what im talking about is we do not need dist folder in nodejs land
Hardy Jones
@joneshf
Jun 27 2016 14:20
@jethrolarson , @xgrommx , @davidchambers , You have to be careful though, the Applicative effects of Maybe might not be what you want in some cases.
Scott Sauyet
@CrossEye
Jun 27 2016 14:20
I think we should export only LICENSE.txt, README.md, package.json, ramda.js, ramda.min.js, and the contents of the src dir. I don't particularly care whether ramda.js and ramda.min.js are in a distdir or not.
Hardy Jones
@joneshf
Jun 27 2016 14:20
λ: sequenceA [Just 10, Just 20, Just 30] <&> sum
Just 60
λ: sequenceA [Just 10, Nothing, Just 30] <&> sum
Nothing
If you actually do want it to not sum anything when you have a Nothing, then for sure sequence is what you want.
But you still want some sort of value even in the presence of Nothing, you have to change your function to sort of "ignore" the applicative effects.
λ: foldMap (maybe mempty Sum) [Just 10, Just 20, Just 30]
Sum {getSum = 60}
λ: foldMap (maybe mempty Sum) [Just 10, Nothing, Just 30]
Sum {getSum = 40}
only in haskell since I am too lazy to write foldMap and Sum.
Hardy Jones
@joneshf
Jun 27 2016 14:32

Which sort of makes sense if you look at some types.

λ: :t sequenceA
sequenceA :: (Applicative f, Traversable t) => t (f a) -> f (t a)
λ: :t foldMap
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

sequenceA is saying, I know how to traverse the data type you give me, and I know its value has Applicative effects , so i'm going to apply the effects while I traverse the data type.
foldMap is saying, I know how to fold the data type you give me, and I know how to turn each value into a monoidal value, so I'm going to fold the container while accumulating the monoidal values.

If the Applicative effects are, "early exit", then you wind up with the chance of having Nothing.
But yeah, totally depends on what you're trying to encode.
Hardy Jones
@joneshf
Jun 27 2016 14:42

Also, this is pretty interesting:

λ: foldMap (foldMap Sum) [Just 10, Nothing, Just 30]
Sum {getSum = 40}

Mostly because you can rewrite it to be more elegant:

λ: (foldMap . foldMap $ Sum) [Just 10, Nothing, Just 30]
Sum {getSum = 40}
λ: (foldMap . foldMap $ Sum) [Right 10, Left "wat", Right 30]
Sum {getSum = 40}
λ: (foldMap . foldMap $ Sum) [Identity 10, Identity 20, Identity 30]
Sum {getSum = 60}
λ: (foldMap . foldMap $ Sum) [[10, 20, 30], [], [1..10]]
Sum {getSum = 115}
...
David Chambers
@davidchambers
Jun 27 2016 16:04

@joneshf, the Sanctuary equivalents are elegant too:

> S.reduce(S.reduce(S.add), 0, [S.Just(10), S.Nothing(), S.Just(30)])
40
> S.reduce(S.reduce(S.add), 0, [S.Right(10), S.Left('wat'), S.Right(30)])
40
> S.reduce(S.reduce(S.add), 0, [[10, 20, 30], [], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
115

Without a Sum type we need to specify the default value, but that's not onerous.

@ram-bot
S.reduce(S.reduce(S.add), 0, [S.Just(10), S.Nothing(), S.Just(30)])
ram-bot
@ram-bot
Jun 27 2016 16:04
40
Lewis
@6ewis
Jun 27 2016 17:20
hi
is there a way to add a custome initial index number to addIndex?
David Chambers
@davidchambers
Jun 27 2016 17:58
There is not, @6ewis, but you could use R.range to create your own index list then R.zip.
Lewis
@6ewis
Jun 27 2016 19:12

const voila = R.either(R.isNil, (array) => R.all(R.isNil)(R.values(array)))

voila(1)

This message was deleted
it will returns true, even though i expected false. (I think because both args evaluates) what's the best way to write it
Denis Stoyanov
@xgrommx
Jun 27 2016 20:11
@joneshf sequenceA is just smth like mapM id or traverse id