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

Koka doesn’t support tabs #516

Closed
toastal opened this issue May 7, 2024 · 3 comments
Closed

Koka doesn’t support tabs #516

toastal opened this issue May 7, 2024 · 3 comments

Comments

@toastal
Copy link

toastal commented May 7, 2024

parse error: invalid syntax
  unexpected tab characters: configure your editor to use spaces instead (soft tab)

I don’t like arguing with coworkers & collaborators over indentation sizing & tabs are configurable compromise as I have visual scanning issue related to 2-space code. Please consider supporting tabs for indentation on the grounds of accessibility.

@anfelor
Copy link
Collaborator

anfelor commented May 16, 2024

Koka uses a whitespace-aware layout algorithm for parsing. This makes it impossible to mix tabs and spaces in a Koka program and Koka traditionally uses spaces. In particular, it would be a lot harder to align Koka code like the third example (eq2) in the linked documentation using tabs. However, if you are interested in writing an autoformatter for Koka that can automatically adjust the spaces in front of a line, I would be happy to advise with that.

@anfelor anfelor closed this as completed May 16, 2024
@toastal
Copy link
Author

toastal commented May 17, 2024

Just like programming languages like Haskell, Python, JavaScript, Scala, Go, etc.…

All of these support tabs, & Go pretty much enforces tabs. I’ve never been a fan of bothering to even try to align vertically as it creates a lot of maintenance for when values change (nor does it allow changing the level for a11y). If I were to come into this stylistically blind to current Koka style trends I would have instinctively gone with:

fun eq2(
	x : int,
	y : int
) : io bool
	print(
		"calc "
		++ "equ"
		++ "ality"
	)
	val result =
		if (x == y)
			then True
			else False
	result

But if the language is locked to spaces, then it is locked to spaces

@TimWhiting
Copy link
Collaborator

TimWhiting commented May 17, 2024

I don't think this is an unreasonable request, especially with respect to accessibility, however, I do think that we should have an autoformatter as prerequisite or part of solving this issue. I've opened #521 for creating an autoformatter, so let's move further discussion there as far as what sort of configuration should be allowed, and what a 'default' style should look like.

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

No branches or pull requests

3 participants