These are chat archives for ramda/ramda

16th
Oct 2015
Raine Virta
@raine
Oct 16 2015 05:20
sinelaw/infernu#27
Tobias Pflug
@gilligan
Oct 16 2015 06:50
good morning
@raine interesting - i hadn't heard of infernu before
looking at the syntax I'd certainly prefer that over what typeflow is using
Niloy Mondal
@niloy
Oct 16 2015 07:11
@davidchambers Should contains work with String? I'd be happy to submit PR
Ludwig Magnusson
@TheLudd
Oct 16 2015 08:54
@niloy Depending on the use case you could use test with regexps http://bit.ly/1OyiNxq
Niloy Mondal
@niloy
Oct 16 2015 08:55
@TheLudd I will have to create the regexp at runtime since it tries to match with user input
Niloy Mondal
@niloy
Oct 16 2015 10:38
event => event.preventDefault(), can this be written in point free style?
Aldwin Vlasblom
@Avaq
Oct 16 2015 10:39
R.invoker(0, 'preventDefault')
Niloy Mondal
@niloy
Oct 16 2015 10:40
Thanks ๐Ÿ‘ ๐Ÿ˜€
Raine Virta
@raine
Oct 16 2015 11:22
any favorite libs for creating custom Errors?
Raine Virta
@raine
Oct 16 2015 11:28
I tried error but it wouldn't let you do R.is(MyCustomError, err)
so it didn't build the object in the way that would make instanceof work or something
Tobias Pflug
@gilligan
Oct 16 2015 11:31
hm, sorry. dunno
Niloy Mondal
@niloy
Oct 16 2015 11:32
What is wrong with new Error?
Raine Virta
@raine
Oct 16 2015 11:32
what do you mean?
Niloy Mondal
@niloy
Oct 16 2015 11:33
why not simply use new Error("my custom error")?
Raine Virta
@raine
Oct 16 2015 11:33
how would you match err against that type of error?
Scott Sauyet
@CrossEye
Oct 16 2015 11:34
@niloy: usually when we extend list APIs to String, it's because we can think of Strings as lists of characters. But that extension doesn't feel right for contains. You wouldn't only want to be able to test that "foobar" contains "f" or "a". You would also want to know if it contains "bar". And that would lead to a completed API, IMHO.
Niloy Mondal
@niloy
Oct 16 2015 11:37
@CrossEye makes sense ๐Ÿ‘
@raine Sorry, no idea โ˜บ
Raine Virta
@raine
Oct 16 2015 11:38
well, that's where the need for custom error types arise
Niloy Mondal
@niloy
Oct 16 2015 11:40
@raine how about class MyCustomError extends Error {...}?
Tobias Pflug
@gilligan
Oct 16 2015 11:40
es6 classes..meh ;)
Niloy Mondal
@niloy
Oct 16 2015 11:41
Dont hate the feature, hate the programmer ๐Ÿ˜€
Scott Sauyet
@CrossEye
Oct 16 2015 11:42
@raine: is there anything special about Error types that wouldn't be handled by generic OO construction method number 57?
Niloy Mondal
@niloy
Oct 16 2015 11:42
@CrossEye R.map(R.toUpper, "abc") should return "ABC" instead of ["A", "B", "C"], what do you think?
Scott Sauyet
@CrossEye
Oct 16 2015 11:43
@gilligan: still, the only es6 feature I dislike. But it's a huge one.
Tobias Pflug
@gilligan
Oct 16 2015 11:44
@CrossEye yeah es6 is basically awesome apart from the classes
and sadly i have them everywhere in my current project -> React components = es6 classes
Scott Sauyet
@CrossEye
Oct 16 2015 11:45
@niloy: we've stayed doing this for some functions. Probably should include map if we're not already doing so.
Denis Stoyanov
@xgrommx
Oct 16 2015 11:45
@niloy no, map can be apply only to array. Use R.toUpper("abc")
Scott Sauyet
@CrossEye
Oct 16 2015 11:46
@gilligan: I know Eric Elliot had been publishing some about how to use React without the OO. Don't recall where, as I've mostly just seen his infant tweets about it.
Aldwin Vlasblom
@Avaq
Oct 16 2015 11:48
@gilligan I first learned about composition over inheritance when reading the original ReactJS docs, just a few weeks after they opensourced it. Since then I've learned a lot more about it and have come to appreciate it. You might be able to imagine that I was scratching my head a little when I read the docs again last month and saw classes everywhere, with only one mention in the docs of createClass supporting mixins, and ES6 classes don't.
Scott Sauyet
@CrossEye
Oct 16 2015 11:48
Actually, @xgrommx is right. How would you map (String -> Number) over a String and hope to get a String back?
Raine Virta
@raine
Oct 16 2015 11:48
how does mapping over a string fit into the signature of (a -> b) -> [a] -> [b]?
Scott Sauyet
@CrossEye
Oct 16 2015 11:49
It doesn't. Brain fart.
Tobias Pflug
@gilligan
Oct 16 2015 11:49
String ain't a functor ;}
Scott Sauyet
@CrossEye
Oct 16 2015 11:50
Typo above, although I kind of like it. "Incessant tweets".
Tobias Pflug
@gilligan
Oct 16 2015 11:50
@CrossEye ;-)
@CrossEye yeah there are some things in the workings and hope i will get rid of the classes at some point
Niloy Mondal
@niloy
Oct 16 2015 12:07
@raine If a string is viewed as a array of characters, [a] = String, a = Single character
Tobias Pflug
@gilligan
Oct 16 2015 12:13
@raine hm, so map is in the List category now. That is not exactly accurate anymore
Raine Virta
@raine
Oct 16 2015 12:13
i guess String would have to satisfy functor laws, i don't know if that would be possible
Tobias Pflug
@gilligan
Oct 16 2015 12:13
@raine perhaps there needs to be a Functor category
i suppose if you really need to map over a string you can R.pipe(R.split(''), R.map(f), R.join(''))
Niloy Mondal
@niloy
Oct 16 2015 12:19
@gilligan map already works over String, just the output is an Array instead of a String
Raine Virta
@raine
Oct 16 2015 12:20
doesn't that mean it... doesn't work?
Tobias Pflug
@gilligan
Oct 16 2015 12:20
hence my suggestion
Martin Algesten
@algesten
Oct 16 2015 12:39
isnโ€™t it only broken if you think ramda should have a stringent type system?
i mean itโ€™s not surprising the way it works.
> fn = pipe map((s) -> ":#{s}"), join('')
[Function]
> fn 'abc123'
':a:b:c:1:2:3'
Niloy Mondal
@niloy
Oct 16 2015 12:48
I was only suggesting that the last join should not be required in case of String
Scott Sauyet
@CrossEye
Oct 16 2015 13:03
@niloy: but are you suggesting that map (fn, string) somehow only allow fn :: Char -> Char?
Niloy Mondal
@niloy
Oct 16 2015 13:04
@CrossEye I am suggesting map (fn, [Char]) => [Char], right now its map(fn, [Char]) => [[Char]]
@CrossEye oh wait... ok, got ur point
Scott Sauyet
@CrossEye
Oct 16 2015 13:06
But as it stands, we have no way to know without running
it that fn returns a Char.
It's tricky sometimes.
Niloy Mondal
@niloy
Oct 16 2015 13:08
@CrossEye Yes, I get it ๐Ÿ‘
If someone wants to convert a string to its codePoints, the current map works great
Martin Algesten
@algesten
Oct 16 2015 13:16
@CrossEye i suspect it could be solved by in map check whether the incoming array-argument is typeof == 'string' and in that case finish with a join. not saying itโ€™s a good idea :)
Niloy Mondal
@niloy
Oct 16 2015 13:17
@algesten You can only join if the mapper function always returns a String, which may not be the case
Scott Sauyet
@CrossEye
Oct 16 2015 13:21
map (isVowel, 'foo'); //=> [false, true, true]. join would just be harmful.
Niloy Mondal
@niloy
Oct 16 2015 13:24
Good Example ๐Ÿ‘
Martin Algesten
@algesten
Oct 16 2015 13:26
yes. hence โ€œnot a good ideaโ€. i think 1) using map over strings is dodgy, and writing dodgy code is a user error (not something ramda should fix). 2) current behaviour is fine and totally what i would expect
the description make any sense to you?
Martin Algesten
@algesten
Oct 16 2015 13:32
looks good! :+1:
Scott Sauyet
@CrossEye
Oct 16 2015 13:34
:herb:
Raine Virta
@raine
Oct 16 2015 13:36
non-fancy-word way to do that would be echo '1 2 2 3 3 4 5' | R --slurp --unslurp drop-repeats i.e. wrapping and unwrapping as list.
Jethro Larson
@jethrolarson
Oct 16 2015 17:31