koka-lang / koka

Koka language compiler and interpreter

Home Page:http://koka-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Koka doesn’t support tabs

toastal opened this issue · comments

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.

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.

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

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.