FiraCode
FiraCode copied to clipboard
Ligature request: %>% pipe operator in R
We use the pipe operator %>%
a lot in the Tidyverse set of packages in the R programming language. It's a way of stringing together many functions, converting them from prefix to infix. It would be really nice to have a pipe ligature.
There was a couple of request for getting better coverage for R. I’m not against it, but can’t think of a way to improve the rendering of those
I'll give a design a shot in a day or so.
@jtth Want to share your design idea? Would be awesome to have this in R.
I would second this, and third this for colleagues who have commented on how ugly the pipe symbol is. Has anyone made progress on this?
Maybe something like this?
It's a horizontal invert of the arrow that is shown for <-
, with the zeroes of the percent mark.
Better question is: does R (or RStudio that is) provide ligatures for more than 2 characters?
When typing ===
, I get: . I don't know if it will understand something in place for %>%
.
I don’t think R authors had anything in mind when they chose %>%
. Probably it’s just a random sequence of characters. I also think it’s unfixable, visually I mean
You could rotate the two %
and connect them to form a line with a >
through it. That way you would still have three-character width too.
I would propose to just use F# pipe ligature for %>%
. In R, custom operators are defined between percent signs, so anyone can define an operator like so %whatever% <- function(){ ...}
. R's pipe operator was actually inspired by F#'s pipe and is supposed to have similar behavior. However, since arbitrary-character operators have to be wrapped in %...%
, the pipe ended up looking like %>%
There are several other popular R operators mentioned in https://github.com/tonsky/FiraCode/issues/39. Not sure what can be done with them though.
I would second the proposal to use the F# ligature for the R pipe %>% . With respect to the #39 issue, it would be nice to have some of the other symbols changed, but I think most R developers would tell you they use the %>% in maybe 1/4 of their lines of code, it is everywhere. I think it should have the highest priority.
There was an earlier comment that RStudio does not support three-character ligatures. I am not sure about RStudio 1.0, but in RStudio 1.1 the double headed arrow <<- correctly changes to the ligature for that symbol with Fira Code.
The %
characters should be preserved — one of the rules of Fira Code AFAIK is that all of the characters stay. What about rendering %>%
like %|>%
?
There was an earlier comment that RStudio does not support three-character ligatures. I am not sure about RStudio 1.0, but in RStudio 1.1 the double headed arrow <<- correctly changes to the ligature for that symbol with Fira Code.
True!
I think most R developers would tell you they use the %>% in maybe 1/4 of their lines of code, it is everywhere
True!!!!
j-f1, could you elaborate on rule about all of the characters staying?
Would like this as well. How about removing the slashes and extra dots in the percent symbols, something like:
𐩑<𐩑
(Except maybe the dots being on the same level as the bracket, and also nicer etc)
I want the ligatures to resemble original characters combination
@bcollier
j-f1, could you elaborate on rule about all of the characters staying?
See above ⬆️ 🙂
I agree with the suggestion of something like the F# pipe ligature (right-pointing triangle). The percent signs (which are really just there because of R's requirements for custom binary operators) could be reduced to individual small circles.
Something like this: ∘▷∘ except I would stretch the triangle so it touches the circles.
Yeah, that’s beautiful! And I agree about the percentages :+1:
@timgoodman that's a lot better than what I had in mind. As long as the midline of the ∘ aligns with the centerline of the ▷ that's great!
Kind of like
(Fun design note: this induces a size illusion such that the left circle appears smaller than the right. Dunno whether it'd be better to increase the size of the leftmost circle, or just leave it.)
- Pilcrow
- Manicule
@holstius You want a paragraph marker and a hand? What?
Either seemed appropriate to me.
%>% is read “and then”; it does the same thing pseudo-linguistically as a paragraph break (that is, it separates “sentences”).
The “hand” is more of a visual analogy. There’s a rightward momentum.
On first read, I missed the point about preserving the elements of the original characters. In that case, both my suggestions are way off the mark.
On Mon, Dec 11, 2017 at 9:14 AM Jordan T. Thevenow-Harrison < [email protected]> wrote:
@holstius https://github.com/holstius You want a paragraph marker and a hand? What?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tonsky/FiraCode/issues/473#issuecomment-350791628, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyaakESgjaXanj4yI5LiNmllWKtSyb8ks5s_WLjgaJpZM4OzrQB .
One idea for all of these would be to drop the second o on the first % and the first o on the second %, then elongate the center operator character.
@tonsky Any good arguments against ??
Else I think most of us would say: please implement 😉
@tonsky and others:
Any interest in some variants inspired by the ligature for $>
?
I thought that a compromise between no resemblance to the original characters (as in the o |> o
) and a full representation of the two %
signs might be to turn the /
in the percent sign into an arrow. That sort of nests the arrow "within" a percent.
Even the compound pipe could be represented with uneven <>
@epspi I like yours better than mine. Very nice! That's more clear and visually unpacks a lot better.
Thanks @jtth Adding better compound pipe
Alternative based on arrows instead of > <
-
- Consistency with other languages is a good principle, so following F# is a sound choice
-
- Not to stray too far off-topic, but that would suggest that %in% follows the ancient lead of LaTeX
\in
which inserts the ∈ (isin) symbol, consistent with math in general.
- Not to stray too far off-topic, but that would suggest that %in% follows the ancient lead of LaTeX
-
- FWIW, I believe this represents some specialized type of op-amp in the EE world:
While some resemblance to the original characters is good (and we should follow the rule that each character in the original corresponds to some part of the ligature), I think it's more important that the meaning is conveyed (in the semantic sense, not the "what characters does it stand for" sense). For instance, !=
produces a ligature which doesn't bear much resemblance to an exclamation point, but that's OK because the ligature clearly represents the meaning "not equal". (Put another way, the ligature looks like the symbol that probably would have been used, if only that symbol existed as a key on the standard keyboard.)
For this reason, I still think the percentages should be de-emphasized, since they don't convey much meaning. They are just required for defining any custom binary operator in R. If not for this requirement of the R language, the author of magrittr might well have chosen |>
, given that the magrittr pipe was actually inspired by F#'s pipe, |>
(see here: https://www.r-statistics.com/2014/08/simpler-r-coding-with-pipes-the-present-and-future-of-the-magrittr-package/ ).
So, the magrittr pipe is not a random character sequence as suggested above; it's just an approximation of F#'s pipe that meets the rules of R. And F#'s pipe, it seems clear to me, is meant to have some resemblance to an arrow pointing in the direction of piping (and this is consistent with the fact that the reverse pipe resembles an arrow pointing the other way).
With all that said, I don't particularly care for the suggestion using diagonal arrows, because instead of using an arrow from x to f to represent "x piped into f", they use an arrow pointed off at an oblique angle, which seems less connected to the meaning. Moreover, while they increase the resemblance to the percent sign (the semantically-irrelevant part), they actually decrease the resemblance to the greater-than symbol (the semantically-important part). Even the suggestion before that, which is closer to resembling the greater-than sign, seems like it's favoring a resemblance to the percent sign a bit too much in my opinion.
So, I would still prefer the closed triangle with dots on either end, which:
- Resembles the greater-than sign, and more importantly resembles the meaning of the symbol: an arrow in the direction of piping
- Includes but deemphasizes the semantically-irrelevant percent signs
- Resembles the equivalent F# operator, which actually inspired the magrittr pipeline operator