Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show \ as λ optionally #96

Open
purpleP opened this issue May 5, 2017 · 13 comments
Open

Show \ as λ optionally #96

purpleP opened this issue May 5, 2017 · 13 comments

Comments

@purpleP
Copy link

purpleP commented May 5, 2017

I've played with FiraCode and using unicode to make haskell a bit nicer to read and write.

My opinion on that is that FiraCode really makes haskell more readable by making ->, <=, >= etc into mathematical symbols. Unicode on the other hand is making things worse. Because for example trying to show -> as one symbol is making it less readable. The same applies to all two character symbols to some degree or another.

But there is one thing FiraCode isn't making more readable, while unicode is. It's \ lambda abstraction symbol. So I thought that maybe vim knows how to show some characters as another characters? And indeed it is.

syn match haskellLambda '\\' conceal cchar=λ
set conceallevel 2 concealcursor=nv

This is doing what I want, except maybe that it's using Conceal syntax group instead of keyword.

screenshot 2017-05-05 13 26 26

@purpleP
Copy link
Author

purpleP commented May 6, 2017

I also added syn match haskellCompose '\.' conceal cchar=∘ and now function composition look much prettier!

@raichoo
Copy link
Member

raichoo commented May 7, 2017

I personally don't like the conceal feature since it poorly interacts with most languages. In Haskell, take \ for example. It's also used for multiline strings. Now you have lambdas at the beginning and at the end of every line of a multiline string. Without being aware of the context it mindlessly substitutes things.
I'm not a big fan of UnicodeSyntax either because it needlessly complicates the parser for highlighting and indentation (which is already quite hairy).
Further I disagree that this makes Haskell anymore readable, quite the contrary actually, but that's subjective anyway.
However this could be provided as an optional feature if you are willing to provide a patch. Given the problems that it causes I wouldn't make this a default.

@purpleP
Copy link
Author

purpleP commented May 10, 2017

Now you have lambdas at the beginning and at the end of every line of a multiline string.

I'm pretty sure you haven't checked if your statement is actually true. Because for some reason (probably because strings syntax doesn't contain this new conceal group) \ isn't displayed in strings as lambda.

Given the problems...
What problems? But for sure it shouldn't be default.

As to your opinion about readability I just don't get it. Lambda displayed as lambda is less readable than lambda displayed as \? Seriously? I really don't know what to say to this...

@raichoo
Copy link
Member

raichoo commented May 10, 2017

This issue has showed up in various setups, so yes I've checked this. If there is a way to supress this then this might be an issue of specific plugins not doing so.

If you want to argue with me about what you consider more readable I'm going to have to pass. I've already stated that I would accept your patch as an optional flag so your passive aggressiveness is unnecessary.

@purpleP
Copy link
Author

purpleP commented May 10, 2017

@raichoo Well, okay. What are those setups? Because to make a patch that works I would need to recreate them to fix the issues.

I'm not gonna argue about, I'm just saying I don't get it why would anyone think that \ is better displays lambda than lambda. What would be the reason? Dislike of greek letters?

@raichoo
Copy link
Member

raichoo commented May 10, 2017

It's highly subjective. Maybe it's because I've written Haskell that way for quite a long time and I happen to find it distracting. Heck, I get confused when I use a different colorscheme because my brain is used to certain colors for indicating certain things. But others might feel different about this so I think adding this as an option is valuable.
Long story short, if you can make this work without breaking for multiline strings (which I have seen happen in other setups and I didn't bother to figure out why, because I'm not using it anyway) I'll merge this. Just be sure to add it to the documentation so people can find out about this (yes, I forget that for features I add myself, I plead guilty).

@purpleP
Copy link
Author

purpleP commented May 10, 2017

@raichoo So multiline string is like that

some = "blabla \
              \ blabla"

If so, I've just checked - it works. No lambdas there. Other than that - I don't know the test cases.

@raichoo
Copy link
Member

raichoo commented May 10, 2017

Maybe check for CPP macros as well (some libs have them), if that works just prepare a PR and I'll check it out tonight and I'll merge it ASAP.

@purpleP
Copy link
Author

purpleP commented May 11, 2017

@raichoo Wow, I didn't even know that haskell can use CPP macros. That's insane :-). So again, probably because cpp macros is defined as region and they don't said to contain new lambda syntax, \ is displayed like \ there.

One question though. If I add this syntax to syntax file it doesn't work. But If I put it into /after/syntax/haskell.vim then it works. In my patch should I add /after/syntax/haskell.vim or should we dig into why it doesn't work in /syntax/haskell.vim?

@raichoo
Copy link
Member

raichoo commented May 11, 2017

I have to admit that some of this rather arcane Vim folder magic goes beyond me but it would be really good if we could do it the "proper way", for whatever that means. Some people have already reported issues that seem to arise because of loading order (and sadly I'm unable to reproduce them at all).

@purpleP
Copy link
Author

purpleP commented May 17, 2017

I'll try to ask on stackexchange. Maybe someone will help.

@luc-tielen
Copy link

Any update on this?

@purpleP
Copy link
Author

purpleP commented Apr 1, 2019

@luc-tielen New version of fira-code already shows \ as lambda. So I'm don't see much point in doing this in vim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants