These are chat archives for ramda/ramda

27th
Mar 2017
Matt McKellar-Spence
@MattMS
Mar 27 2017 01:25
Thanks for all the info @m59peacemaker I'm totally with you on minimising what is in each package so I think your library sounds like a better fit.
Regarding the Ramda stuff, I've seen some discussion on making it so you could do groupBy = require('ramda/groupBy') but currently I think you need to specify ramda/src/groupBy.
Is there an advantage to having an org with the same name as a package?
Johnny Hauser
@m59peacemaker
Mar 27 2017 01:57
@MattMS yes! I was saying you actually want to publish each function individually as well, so you need the namespace. Imagine you have 20 single function paclage deps on your prof
*project
Matt McKellar-Spence
@MattMS
Mar 27 2017 02:00
I know bundling small packages into a larger one has advantages (ramda) but I was wondering why you would group all those packages within an org as well (@ramda). I've previously just published them separately with a . in the name.
I guess I've sort of answered my own question. It's a standard way of doing that grouping, saving making up my own standard of using ..
Johnny Hauser
@m59peacemaker
Mar 27 2017 02:02
Sorry, I had to stop mid-thought there
Watching Walking Dead with my wife
Brb
Johnny Hauser
@m59peacemaker
Mar 27 2017 02:10
So, if it so happened that your 20 npm deps all use Ramda, and 20 different versions at that....
that's a lot of MB to install
but yeah, I see you understand that
Using your own actual namespace, apart from being intuitive, also prevents someone from faux-contributing unapproved modules with your naming scheme.
Matt McKellar-Spence
@MattMS
Mar 27 2017 02:20
Ah right, yeah that is definitely an advantage.
I see npm announced free organisations now, so I'll likely look into it for my own packages. Maybe Ramda could even get in on the act ;)
Johnny Hauser
@m59peacemaker
Mar 27 2017 02:24
This is really useful to that goal https://github.com/lerna/lerna
Matt McKellar-Spence
@MattMS
Mar 27 2017 02:32
Interesting. Bookmarked :smile:
Sebastian Andres
@sebandres
Mar 27 2017 04:54
thanks for sharing @m59peacemaker !
Raine Virta
@raine
Mar 27 2017 12:20
I'm wondering how people find using ADTs in javascript despite the language not enforcing types. I suppose it helps if you have strongly typed FP background and have developed sort of a type system in your mind
Raine Virta
@raine
Mar 27 2017 12:25

The truth is, consciously or subconsciously, you are always reasoning with your types, JavaScript still has to check your types, although this is delayed until execution (late binding). And you still has to think of what operations you can invoke on this or that variable.

that's a good point

Raine Virta
@raine
Mar 27 2017 12:30
also, I guess the way Promise has been found useful by the JS community shows that you can find value in ADTs even in small scale
Simon Friis Vindum
@paldepind
Mar 27 2017 14:17
@raine How do you see a connection between Promises and ADTs?
Also, great quote. Thanks for sharing!
James Forbes
@JAForbes
Mar 27 2017 14:19
@paldepind it is an adt isn't it Resolved a | Rejected e?
Raine Virta
@raine
Mar 27 2017 14:44
@paldepind maybe I'm incorrectly conflating ADTs and types in general, but from what I understand Promise as defined in the spec is or was almost a monad promises-aplus/promises-spec#94
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:16
What's the obvious refactoring I'm missing here? https://goo.gl/nsOOFr
Gabe Johnson
@gabejohnson
Mar 27 2017 15:22
@aaronmcadam https://goo.gl/R2FAIE ?
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:23
hmm
Gabe Johnson
@gabejohnson
Mar 27 2017 15:23
I don't think that's any clearer though
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:23
I don't klnow why I thought there was a better way
heh
Gabe Johnson
@gabejohnson
Mar 27 2017 15:24
why are you passing { size: 'tiny' } instead of just 'tiny'?
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:24
This is a React style-components helper
so it receives props
height: ${getHeight};
Gabe Johnson
@gabejohnson
Mar 27 2017 15:24
ahh
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:25
That's how it actually gets called
Gabe Johnson
@gabejohnson
Mar 27 2017 15:25
otherwise it'd be
const getHeight = flip(prop)(sizes)
getHeight('tiny')
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:26
yeah, I was thinking of some way to partially apply the size prop
I suppose I could always select the size prop and pipe that into getHeight
const getHeight2 = compose(flip(prop)(sizes), prop('size'));
but yeah, it's getting further away from simplicity :D
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:31
I'm playing around with intersectionWith, but it's getting a bit silly now. It's fun though
Gabe Johnson
@gabejohnson
Mar 27 2017 15:40
Simon Friis Vindum
@paldepind
Mar 27 2017 15:40
@JAForbes Hm. Maybe. I don't see it that way. Because it starts out as "unresolved" and then turns into either "resolved" or "rejected". So it's like a state machine that changes state by internal mutation.
@raine I definitely agree that Promises are monads. And the then method is very close to a monadic bind and async/await is very close to do-notation specialized to promises. But, as you, say not all types are ADTs. Type Script has types but it doesn't have ADTs.
@JAForbes Well. I think you can say that a promise has an internal state that can be represented as Resolved a | Rejected e and that is changed over the lifetime of the promise. But, maybe that is what you meant from the beginning :smile: :sweat_smile:
Raine Virta
@raine
Mar 27 2017 15:47
I threw in Promise as an example of something where FP inspired things have proven to be valuable. but I mentioned ADTs because I had specifically something like Either in mind and I was wondering if people use those in real world and find them useful
Aaron Mc Adam
@aaronmcadam
Mar 27 2017 15:57
Is this the simplest way to build a derived object? https://goo.gl/FxWtXN
Simon Friis Vindum
@paldepind
Mar 27 2017 20:02
@raine Ah. Ok :smile: I think a good example of ADTs in the real world is actions in Redux. Since JS lack types they have the type property on actions but it's basically ADTs.
Sebastian Andres
@sebandres
Mar 27 2017 21:58
@ram-bot
const doSomethingElse = (anotherValue) => Promise.resolve(anotherValue)

const doSomething = (value) => Promise.resolve(value)

const doSomethingWithValue = R.partial(doSomething, ['Yay!'])

const doEverything = R.composeP(doSomethingElse, doSomethingWithValue)

doEverything()
ram-bot
@ram-bot
Mar 27 2017 21:58
Promise { <pending> }
Sebastian Andres
@sebandres
Mar 27 2017 21:59
@ram-bot
const doSomethingElse = (anotherValue) => Promise.resolve(anotherValue)

const doSomething = (value) => Promise.resolve(value)

const doSomethingWithValue = R.partial(doSomething, ['Yay!'])

const doEverything = R.composeP(doSomethingElse, doSomethingWithValue)

doEverything().then((result) => console.log(result))
ram-bot
@ram-bot
Mar 27 2017 21:59
Promise { <pending> }
Sebastian Andres
@sebandres
Mar 27 2017 21:59
:(
Gabe Johnson
@gabejohnson
Mar 27 2017 22:02
@sebandres the bot is displaying the Promise returned from the call to then
I don't think you can do what you're trying to do
Sebastian Andres
@sebandres
Mar 27 2017 22:03
yeah I know, was trying to see if it actually resolved the promise
but all good :D
at least is a promise not a func
@ram-bot
const doFirst = (value) => Promise.resolve(value)

const doSecond = (value) => Promise.resolve(value)

const doFirstWithValue = R.partial(doFirst, ['Yay!'])

const doFirstAndSecond = R.composeP(doSecond, doFirstWithValue)

const shouldReturnPromise = R.composeP(doSecond, doFirstAndSecond)

shouldReturnPromise()
ram-bot
@ram-bot
Mar 27 2017 22:03
Promise { <pending> }
Sebastian Andres
@sebandres
Mar 27 2017 22:04
weird, it works as I would expect here, but from my javascript composeP has a very different behavior
Gabe Johnson
@gabejohnson
Mar 27 2017 22:04
composeP is cool! I never noticed it before
Sebastian Andres
@sebandres
Mar 27 2017 22:05
it is very handy if you have lots of async stuff
Gabe Johnson
@gabejohnson
Mar 27 2017 22:06
works on the repl https://goo.gl/UxmYUZ
Sebastian Andres
@sebandres
Mar 27 2017 22:08
not really @gabejohnson
Yay! shouldn't show up until you run shouldReturnPromise
but for some reason on repl it actually evaluates even if you comment out the last line
or am I missing something ?
Gabe Johnson
@gabejohnson
Mar 27 2017 22:09
i think you need to click clear before commenting out
Sebastian Andres
@sebandres
Mar 27 2017 22:10
ah
that might be it
my bad :D
anyways, my issue might actually be related to using ramda with typescript
Gabe Johnson
@gabejohnson
Mar 27 2017 22:11
Good luck!
Sebastian Andres
@sebandres
Mar 27 2017 22:12
thanks
Johnny Hauser
@m59peacemaker
Mar 27 2017 23:18
What is curryN(0, fn) supposed to do?
It seems to do nothing at all.
I guessed it would make the next invocation call a function even if it were curried
It is setting the length to 0
James Forbes
@JAForbes
Mar 27 2017 23:57
@paldepind no I was wrong that's a great point :D
sorry for the delay (timezones)