These are chat archives for ramda/ramda

6th
Dec 2016
Urmas Talimaa
@urmastalimaa
Dec 06 2016 07:04
@xgrommx what do you mean, monadic join is `a (a b) -> a b`.
I was responding to how to take that n and "split it" into two values? which is exactly what the W combinator does.
Denis Stoyanov
@xgrommx
Dec 06 2016 08:39
Denis Stoyanov
@xgrommx
Dec 06 2016 08:45
@urmastalimaa
``````join :: Monad m => m (m a) -> m a
join :: ((->) r) (((->) r) a) -> ((->) r) a
join :: (r -> (r -> a)) -> (r -> a)
join :: (r -> r -> a) -> (r -> a)
join :: (r -> r -> a) -> r -> a
-- use Alpha conversion where r = a, a = b
join :: (a -> a -> b) -> a -> b
W == join -- if m is an function``````
Denis Stoyanov
@xgrommx
Dec 06 2016 11:18
why Ramda doesn't has `reduce1` aka `foldl1`?
Denis Stoyanov
@xgrommx
Dec 06 2016 11:23
now I should use my custom version of `reduce1`
``````const parse = compose(split('\n'));
const reduce1 = curry((f, [h, ...t]) => reduce(f, h, t))

compose(
join(''),
map(compose(
reduce1(minBy(length)),
values,
groupBy(identity)
)),
transpose,
parse
)(input)``````
Alastair Hole
@afhole
Dec 06 2016 11:47
Is the best (only?) way to make an update inside an object with lenses?
Any tips for naming lenses?
Dec 06 2016 11:55
Hi everyone, I'm refactoring a build script. I've managed to `compose` the main part of it, but I'd like to also compose the `start` and `finish`. My main issue though, is I need to pass the name of the module to the function and have it available to final function in the pipeline (`finish`). Is there a way I can make this work without having to pass along the string in each function? Here's my code: https://goo.gl/hVFJna
Keith Alexander
@kwijibo
Dec 06 2016 12:43
is it possible to combine lens operations for efficiency? ie, if you want to update an object 50 times, and you don't want to mutate the original object, but you only want to create one new copy of the object, not 50
Denis Stoyanov
@xgrommx
Dec 06 2016 12:56
One line for solve 6 day of Aoc
``````const reduce1 = curry((f, [h, ...t]) => reduce(f, h, t))

traverse(always, fn => compose(join(''), map(compose(head, reduce1(fn(length)), values, groupBy(identity))), transpose, split('\n')), [maxBy, minBy])(input)``````
but this one is more readable :smile:
``````const reduce1 = curry((f, [h, ...t]) => reduce(f, h, t))

traverse(always, fn => compose(
join(''),
map(
compose(
reduce1(fn(length)),
values,
groupBy(identity)
)
),
transpose,
split('\n')
), [maxBy, minBy])(input)``````
Suntharesan Mohan
@vanthiyathevan
Dec 06 2016 14:27
Hello,
Why does ramda return null when returning function for map?
Kurt Milam
@kurtmilam
Dec 06 2016 14:32
@afhole There's also the `assoc`/`disassoc` family, `applySpec` and `evolve`, depending on what you're trying to accomplish.
Yosbel Marín
@yosbelms
Dec 06 2016 14:59
@kwijibo `evolve`, `applySpec`
Dec 06 2016 21:29
can you point free something like this without not using jsx ? `const Container = children => (<ul>{children}</ul>);`
Kurt Milam
@kurtmilam
Dec 06 2016 21:35
You could put the tags in an array and join them with the input to the function.
`join(['<ul>', '</ul>'])(input)`
LeonineKing1199
@LeonineKing1199
Dec 06 2016 21:52
What do you think you gain by making that point-free?
Kurt Milam
@kurtmilam
Dec 06 2016 21:53
I'm trying to earn my point-free crafts badge.
Dec 06 2016 21:53
I just get annoyed by JSX
LeonineKing1199
@LeonineKing1199
Dec 06 2016 21:54

I'm trying to earn my point-free crafts badge.

:laughing:

The deal with point-free is that it makes a lot more sense in the Haskell context where all you have to do is look at type signatures and you can follow the progression with just a glance. That's why it's good in Haskell.
However, JS has no such mechanism.
So the fetishization of point-free in JS can oftentimes be dangerous and erase useful information.
Dec 06 2016 21:55
Not having to even create the Container function, so I could just pipe my `li`s into some `ul` function
Kurt Milam
@kurtmilam
Dec 06 2016 21:58
`const ul = join(['<ul>', '</ul>'])` doesn't do the trick?
Dec 06 2016 21:58
It would
Kurt Milam
@kurtmilam
Dec 06 2016 21:59
You'd have to flip it - I got that wrong:
`const ul = flip(join)(['<ul>', '</ul>'])`
Dec 06 2016 21:59
But now I think it should be like `const Container = (el, children) => (el{children}el)`
`pipe(map(foos), Container(<ul>))`
(but with working syntax)
Kurt Milam
@kurtmilam
Dec 06 2016 22:02
dunno, something like `pipe(map(foos), join(''), ul)` might work, but that specific code probably won't :D
I'm not really familiar enough with React to have any idea whether there's a React-specific reason that a solution like that wouldn't work or be optimal, though.
LeonineKing1199
@LeonineKing1199
Dec 06 2016 22:05
I hate to be point-free fuddy duddy but instead of one nice clean function, you have a pipe with 3 functions now. Ask yourself, is this a more readable, understandable and performant implementation vs just one nice read-it-in-one-line function?
Or is this just code golf?
'Cause code golf is always fine
Erik Sutherland
@MrRacoon
Dec 06 2016 22:09
`[String] -> (a -> b) -> {k:v} -> {k:v}` which could apply a function to a nested part of an object, using path-like nature?
like lenses over function `over(path, fn, obj)` (sans the lenses)
Dec 06 2016 22:12
curry curmudgeon
Kurt Milam
@kurtmilam
Dec 06 2016 22:12
fore!
LeonineKing1199
@LeonineKing1199
Dec 06 2016 22:15
Ironically enough, one of the biggest things about FP isn't making things point-free.
But rather, it's about natural transformations
Here, a natural transformation is the mapping of one functor to another
If you read the historical notes here, you can see that's what it's all about.
Turning a Maybe into a List, turning something into something else.
It's all about taking a category with a set of morphisms and transforming it with functors and then transforming those transformations.
Point-free code is a nice syntax but the more root purpose of FP was to create these abstractions that define how types transform from one to the other.
Dec 06 2016 22:17
My pipe is already there, transforming stuff, I just chopped off the beginning for the example code ;(
LeonineKing1199
@LeonineKing1199
Dec 06 2016 22:17
/rant
Dec 06 2016 22:18
And I saw my future of having ContainerUL, ContainerOL, ContainerDiv...
Because now it's best practice to have xml markup in javascript again ??
Dec 06 2016 22:20
:(
Maybe nicer than jsx if yr into functions ;)
LeonineKing1199
@LeonineKing1199
Dec 06 2016 22:23

Because now it's best practice to have xml markup in javascript again ??

Actually, I'd love it if everything was xhtml

Then I could use an XML parser to parse HTML XD
There's only like one good HTTP parser and it's some Java code.
pro `h`