Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,401
    • Issues 5,401
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 591
    • Merge requests 591
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #20756
Closed
Open
Issue created Nov 28, 2021 by Hai / @BestYeen@Hai

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
Assignee
Assign to
Time tracking