ramda icon indicating copy to clipboard operation
ramda copied to clipboard

R.prepend and R.append should work for strings too (String → String → String)

Open wojpawlik opened this issue 6 years ago • 7 comments

R.concat does work for strings.

wojpawlik avatar Dec 24 '17 20:12 wojpawlik

R.concat(s) or R.concat(R.__, s) could be used instead, but I think R.prepend(s) and R.append(s) just sound better.

wojpawlik avatar Dec 24 '17 22:12 wojpawlik

At least for me, they map more naturally to what I wanna do. For me, curried R.concat is less readable than equivalent arrow function.

wojpawlik avatar Dec 25 '17 14:12 wojpawlik

This, a few hours ago I spent some minutes looking for the right function for my module and the first choice in my head was to look for R.append, and then I saw that there's no such thing for strings and had to spend a few minutes remembering that it's actually called R.concat here and that it's actually inverted, so I had to invert the logic and direction of my pipes. It's a tad bit unintuitive if you ask me.

Bestulo avatar Dec 25 '17 14:12 Bestulo

I make no guarantees that it would be approved, but I would be happy to see a PR for this.

CrossEye avatar Dec 26 '17 19:12 CrossEye

IMHO using concat for strings seems nicer and we already support that.

paldepind avatar Jan 20 '18 20:01 paldepind

Just saying, changing append definition to list.concat([el]), ie. using .concat instead of _concat does enable it to concat strings due to JS's weak typing (I'm not saying that it's a good idea to rely on it). Found no similar trick for prepend.

wojpawlik avatar Mar 01 '18 18:03 wojpawlik

R.flip(R.concat) is a nice way of giving you both append and prepend equivalents

mulholo avatar Jul 27 '19 10:07 mulholo