These are chat archives for ramda/ramda

10th
Oct 2015
Jethro Larson
@jethrolarson
Oct 10 2015 00:45
Is this a law?
compose(map(f), chain(g)) == chain(compose(map(f), g))
Hardy Jones
@joneshf
Oct 10 2015 01:50
@jethrolarson hmm, I don't know that you can easily do that.
At least, so far as I understand your question.
If you wanted to create something like events, that's generally going to be monadic.
Whereas handling those events would be more comonadic
erm, the hard part is that you want to make a stream of clicks. That usually requires some sort of effectful thing.
Or mauybe i'm thinking about this wrong.
Chet Harrison
@ChetHarrison
Oct 10 2015 06:40
Ha. Yall have probably seen this by now but worth sharing
Raine Virta
@raine
Oct 10 2015 07:57
thanks for sharing
Martin Algesten
@algesten
Oct 10 2015 15:06
momentjs. what a truly horrid piece of software it is. does anyone know of a sane date handling library? preferably of a functional mind set.
David Chambers
@davidchambers
Oct 10 2015 15:06
That's a very good question!
jQuery.localize is one of the few pieces of software I wrote several years ago which I can still recommend, though I imagine you're looking for a more general-purpose library.
If you find a sane alternative to momentjs, please share it. We use momentjs in several projects at Plaid.
Martin Algesten
@algesten
Oct 10 2015 15:10
interesting. i didn't know you had a past in date parsing :)
right now i'm looking at server side. so no jquery.
Hardy Jones
@joneshf
Oct 10 2015 15:36
@algesten what sorts of things are you looking for?
Martin Algesten
@algesten
Oct 10 2015 15:49

@joneshf parsing/manipulation mainly, but maybe formatting too. i have string input that should be interpreted using some heuristics where it prefers some way to parse it. stuff that momentjs is supposed to do out of the box. but i struggle to make it behave the way i want, since the control you have over a "valid" parse is really limited.

but it's not the first time momentjs bit me. it's timezone support is sketchy at best. the site i work on is swedish. when my laptop happens to be in europe and i interpret user input such as "2015-06-01 10:00" it correctly identifies that june is "CEST", daylight saving and december "2015-12-01 10:00" as "CET" (no daylight). however. if my laptop is in india, where i spend my winters, this automatic recognition for cutoff dates for daylight savings can't be had. you can't tell it "interpret this string as if my laptop is somewhere in europe", even though it clearly does that under the hood.

and do i even need to mention the mutability of it?
m = moment(); m.add(2, 'days'); m is ... ?

Hardy Jones
@joneshf
Oct 10 2015 15:51
no
no, you don't
Raine Virta
@raine
Oct 10 2015 15:53

m = moment(); m.add(2, 'days');

does it mutate m?

Martin Algesten
@algesten
Oct 10 2015 15:53
oh yes it does.
even though it would be perfectly reasonable for this api to be chainable and immutable. and it would even make it clearer.
Hardy Jones
@joneshf
Oct 10 2015 15:55
yeah, it's very jquery-esque for date/time things
Martin Algesten
@algesten
Oct 10 2015 15:55
m = moment();
tomorrow = m.add(1, 'days');
yesterday = m.sub(1, 'days'); // oh no it isn't!
Hardy Jones
@joneshf
Oct 10 2015 15:55
gives a whole bunch of functionality, but has a whole bunch of issues.
Raine Virta
@raine
Oct 10 2015 15:55
jquery-esque? in what respect
Hardy Jones
@joneshf
Oct 10 2015 15:55
^
Raine Virta
@raine
Oct 10 2015 15:56
moment/moment#390
Hardy Jones
@joneshf
Oct 10 2015 15:57
Like, i always want to gouge eyes when doing straight up date stuff in js. But moment makes me less irate.
similarly for something like xhr stuff in plain js vs jquery.
Raine Virta
@raine
Oct 10 2015 15:59
yep, i see
time to start a ramda-esque datetime lib :grin:
David Chambers
@davidchambers
Oct 10 2015 16:02

I updated my website last night:

I’m currently fixing JavaScript, which will take some time!

Hardy Jones
@joneshf
Oct 10 2015 16:02
haha
nice
Martin Algesten
@algesten
Oct 10 2015 16:03
:)
Raine Virta
@raine
Oct 10 2015 16:03
fixing JS, brb
Hardy Jones
@joneshf
Oct 10 2015 16:03
I don't think you're going to like the punchline though.
David Chambers
@davidchambers
Oct 10 2015 16:04
What's the punchline? I give up and get a job writing Haskell?
Hardy Jones
@joneshf
Oct 10 2015 16:04
basically.
Martin Algesten
@algesten
Oct 10 2015 16:04
are there jobs where you get to write haskell?
David Chambers
@davidchambers
Oct 10 2015 16:04
1000, apparently.
Hardy Jones
@joneshf
Oct 10 2015 16:04
...
I can't tell if that's sarcasm or not.
Raine Virta
@raine
Oct 10 2015 16:06
@davidchambers https://github.com/davidchambers/an.hour.ago do you still like APIs like this?
David Chambers
@davidchambers
Oct 10 2015 16:06
Absolutely not, @raine!
Martin Algesten
@algesten
Oct 10 2015 16:06
i thought we only used haskell as wishful thinking whilst churning out mutations and side effects in various imperative guises.
Hardy Jones
@joneshf
Oct 10 2015 16:07
I still can't tell.
David Chambers
@davidchambers
Oct 10 2015 16:07
There are definitely Haskell jobs, but the 1000 figure I mentioned a moment ago is an honest estimate from a talk earlier this year.
I expect this number to grow significantly over the coming years. At some point companies will be crushed by the weight of their own software, and saner approaches will prevail. Big companies are beginning to adopt functional programming, so I think Haskell will lose its “hobbyist” tag at some point.
Martin Algesten
@algesten
Oct 10 2015 16:11
What languages do you use at Plaid?
David Chambers
@davidchambers
Oct 10 2015 16:15
Currently we're perhaps 75% JavaScript, 20% Python, 5% Go, but the majority of the engineers are excited about functional programming. Most of us take online courses and/or write small Haskell programs in our free time. We're moving to a “service-oriented” architecture, which'll mean we have the ability to use different languages in different places without worrying about interoperability. I expect we'll have 5% Haskell within six months (or 5% Scala, if I lose the fight).
Martin Algesten
@algesten
Oct 10 2015 16:18
Interesting. With "service-oriented" do you mean a micro-service style arch? We managed to transition my work into micro-services and it's been huge – devs that suddenly found a purpose in life again after being dead inside from maintaining these huge java/.net monoliths.
David Chambers
@davidchambers
Oct 10 2015 16:21
I used quotes because I don't know whether I'm using the right term. Essentially the current situation involves lots of npm packages which require other npm packages, but we'd like to have independent processes communicating via HTTP and other protocols.
Martin Algesten
@algesten
Oct 10 2015 16:26
yes. that's what i mean with micro-services. we base our services around rabbitmq – a bit of an initial hurdle, but it really pays off. our intention was to be language independent since all major platforms support amqpc (rabbitmq), however in practice we ended up with almost exclusively javascript. what it does do is let us experiment and move stuff forwards (we actively avoid having shared npm-packages). i think we soon will start getting our devs more into FP, just because we can. whatever is the next service to write, it is a potential FP candidate.
David Chambers
@davidchambers
Oct 10 2015 16:28
Great! We're in quite similar situations.
Martin Algesten
@algesten
Oct 10 2015 16:40
does ramda have a function that returns all arguments as an array? (as...) -> as
David Chambers
@davidchambers
Oct 10 2015 16:41
No, but there's a recipe in the cookbook.
Martin Algesten
@algesten
Oct 10 2015 16:42
:o trying to get my head around that :)
ok
David Chambers
@davidchambers
Oct 10 2015 16:44
R.apply transforms a function which accepts positional arguments into a function which accepts a list. R.unapply transforms a function which accepts a list into a function which accepts positional arguments.
Martin Algesten
@algesten
Oct 10 2015 16:45
that's an interesting way of thinking about R.apply. i've stared myself too blind at fn.apply to think beyond that.
David Chambers
@davidchambers
Oct 10 2015 16:47
I find it's often helpful to think of functions in terms of what they do when partially applied. R.chain, for example, transforms a function which takes an unwrapped value into a function which takes a wrapped value.
Jethro Larson
@jethrolarson
Oct 10 2015 17:58
Isnt it essentially just an extend pattern for creating objects? Rather than single inheritance
@joneshf i was thinking of an event stream as basically a future that has an indeterminate number of resolves
Hardy Jones
@joneshf
Oct 10 2015 18:07
hmm, so kind of like a FutureT (Cofree Identity) a?
Though, you'd resolve it once, and that would start the stream of events.
maybe FutureT (Cofree Identity) ClickEvent is better descriptive?
hmm, wait, isn't that just an observable?
"just" as though it's been implemented before, or is so simple...
Martin Algesten
@algesten
Oct 10 2015 18:36
i never knew...
> null >= 0;
true
> undefined >= 0;
false
Hardy Jones
@joneshf
Oct 10 2015 18:39
did you know:
> null > 0
false
> null == 0
false
> null < 0
false
?
Martin Algesten
@algesten
Oct 10 2015 18:40
hehe. my first instinct is "well that's reasonable"... but then, you think mathematially, and I do see how absurd that is :)
> null < 0
false
> null <= 0
true
> null == 0
false
> null >= 0
true
> null > 0
false
it's almost like null approaches zero both from negative and positive.
David Chambers
@davidchambers
Oct 10 2015 18:43
Heh! These are great.
This is still one of my favourites:
> 42 == ['42']
true
> [42] == [42]
false
Martin Algesten
@algesten
Oct 10 2015 18:44
but but...
how does that work?
David Chambers
@davidchambers
Oct 10 2015 18:45
I think it's because in order to compare 42 and ['42'], which are of different types, == coerces both values to strings. Both have the same .toString() representation. :\
When comparing two arrays, == uses identity so the fact that both arrays have the same .toString() representation is ignored.
Martin Algesten
@algesten
Oct 10 2015 18:47
i think you're right
> 42 == [[[[['42']]]]]
true
David Chambers
@davidchambers
Oct 10 2015 18:47
LOL!
Martin Algesten
@algesten
Oct 10 2015 18:47
the mind boggles
David Chambers
@davidchambers
Oct 10 2015 18:48
Is anyone interested in working with me for a couple of hours on some of the website issues?
Martin Algesten
@algesten
Oct 10 2015 18:52
sorry. got my step mum coming over for social time. otherwise i would!
David Chambers
@davidchambers
Oct 10 2015 19:09
No problem. :)
Tobias Pflug
@gilligan
Oct 10 2015 19:52
good evening
;-)
does anyone here have some experience with flowtype ?
trying to get into it
but not getting that far
const toList = (...args) => args
how would i add flow annotations to that ?
off-topic but considering the smart people density around here ... ;=)
Scott Sauyet
@CrossEye
Oct 10 2015 21:38

@raine: I haven't seen rtype before, didn't make much sense from the README, and am not motivated by it to investigate any further.

I have played around with stampit a bit. I've seen half-a-dozen similar libraries for pure prototypal inheritance, and many more for pseudo-classical inheritance. None have ever done that much for me. I'm especially turned off by Eric Elliott's aggressive insistence that his is the only reasonable way to do inheritance in JS -- not the library per se, but the general approach. While I happen to share his preference, I don't think the choice is so stark, and this attitude really bothers me: "Well, I'm an O'Reilly published author, so my point of view is so much more valuable than yours." I've been approached about writing a book, and responding to that gave me more impetus to consider doing it than any actual good reasons.

John-David Dalton
@jdalton
Oct 10 2015 22:28
Snookie is an author.