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

Formatter "upgrading" symbols to fancy unicode characters might hurt discoverability #1610

Open
jwoudenberg opened this issue Dec 16, 2019 · 6 comments
Labels

Comments

@jwoudenberg
Copy link

@jwoudenberg jwoudenberg commented Dec 16, 2019

Sorry if this has been raised before, but I'm a bit concerned about dhall format automatically 'upgrading' symbols, such as turning a backslash into a lambda. The end result looks beautiful, but someone dropped into an existing Dhall codebase without knowledge of this behavior is not unlikely to grow annoyed at having to copy-paste unicode characters around, being unaware of the shortcut available to create them. I'm curious what the motivation is for having the fancy characters be the default.

@sjakobi

This comment has been minimized.

Copy link
Collaborator

@sjakobi sjakobi commented Dec 16, 2019

I'll move this to the dhall-haskell repo, since it contains the code for dhall.

@sjakobi sjakobi transferred this issue from dhall-lang/dhall-lang Dec 16, 2019
@sjakobi

This comment has been minimized.

Copy link
Collaborator

@sjakobi sjakobi commented Dec 16, 2019

I'm curious what the motivation is for having the fancy characters be the default.

AFAIK it's just the older style. IMHO it's also a bit more readable. But you can always use --ascii to get the ASCII versions of symbols.

@sjakobi sjakobi added the formatting label Dec 16, 2019
@ari-becker

This comment has been minimized.

Copy link

@ari-becker ari-becker commented Dec 16, 2019

To offer a different perspective: I have my .vimrc set up with:

:nnoremap <Leader>f :w<CR>:silent exec "!dhall format --inplace %"<CR>:e<CR>:redraw!<CR>
:nnoremap <Leader>v :w<CR>:!clear; dhall format --inplace % && dhall --file %<CR>

This makes it easy, in Vim's normal mode, to type Leader-f to format the Dhall file I'm working on and Leader-v to verify the Dhall file I'm working on. In insert mode, I'll type \(, hit Esc then Leader-f, and bam, I have the Unicode characters. It happens quickly enough that it doesn't disrupt my flow, and indeed, makes it easy for me to find when I make syntax errors (since the file doesn't format when there are errors).

To me, comments like this seem less "dhall's formatter's default behavior is problematic" and more "we need to help spread best practices for Dhall workflow".

@jwoudenberg

This comment has been minimized.

Copy link
Author

@jwoudenberg jwoudenberg commented Dec 16, 2019

I have auto-formatting set up in my Vim as well! It's something I'm used to having set up for other languages, and the same is true for the rest of my team. I'm not concerned about that workflow being inaccessible, rather that even with the flow you describe set up people will still need to know about dhall format replacing backslashes with unicode characters to make use of the trick.

Dhall is a pretty clean language with good error messages. Many aspects of it people might learn on the fly, as they dive into their first .dhall file that maybe a team-member added to the project. I don't think dhall format replacing backslashes with lambda's is something you'll learn by inspecting existing dhall code though (all the backslashes in comitted Dhall code have been formatted out!), but that knowledge seems fairly essential to having a good time with the language.

Maybe making the knowledge super prominent in docs will help (to be honest I haven't checked at which point people new to Dhall would encounter this tidbit in the documentation), though even then I wonder if it would occur to most people that an easier way to insert lambda's might exist, and that they need to look it up.

@Gabriel439

This comment has been minimized.

Copy link
Collaborator

@Gabriel439 Gabriel439 commented Dec 16, 2019

I would be fine changing the default formatting to ASCII, actually. I would probably run it by Discourse first, though, to see if anybody objected

@SiriusStarr

This comment has been minimized.

Copy link
Collaborator

@SiriusStarr SiriusStarr commented Dec 16, 2019

I'm not too strongly opposed to the change so long as the VSCode plugin/LSP gets a (not horrible to setup) setting to keep the current behavior of formatting to Unicode. Frankly, I like Unicode syntax (and wish Haskell formatters did the same and converted everything automagically), but I can see how a new person might be befuddled. I do wonder if instead of changing the default behavior and requiring everyone currently using Dhall to mess with their IDE settings if it would be better just to have prominent information that both syntaxes are accepted (and dhall format converts to Unicode)?

If it wouldn't be a nightmare to implement, the "preview" on dhall-lang.org could implement that replacement (maybe just for lambdas if everything were too hard), so new people discovering Dhall would immediately be exposed to the "formatter" upgrading to Unicode syntax? The comment on the functions tab could include like "Don't want to type λ's? You don't have to! Just type "" and dhall format takes care of the rest." or something along those lines.

Screenshot_2019-12-16 The Dhall configuration language

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.