Skip to content

case of - "of" shouldn't need to be indented in do-notation

Summary

In do-notation, it is not allowed to have the "of" on the same column as its "case". This behavior is allowed for "if"-"then" and I can't think of sample code that would break by allowing this. I suspect an inconsistency in the parsing process. :)

Steps to reproduce

main :: IO ()
main = do
	putStrLn "hi"
	if True then
		putStrLn "hi"
	else
		putStrLn "hi"
	if
		True --useful for conditions that span multiple lines
	then
		putStrLn "hi"
	else
		putStrLn "hi"
	case 1 of
		1 -> putStrLn "hi"
	case
		1 --useful for complex case expressions that span multiple lines
		of --won't work if it's not indented
		1 -> putStrLn "hi"

Expected behavior

In line 18 (second-last line) it should be possible to indent the "of" one column less. For If-Then I got used to having both keywords on the same line or in the same column because this style of formatting makes scanning code a little easier.

Environment

  • GHC version used: 8.10.6

Optional:

  • Operating System: Windows 10 Professional
  • System Architecture: x64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information