this post was submitted on 28 Jul 2024
1306 points (99.0% liked)

Programmer Humor

19623 readers
2 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] bss03@infosec.pub 4 points 3 months ago (1 children)

Might check out the Haskell layout rules.

Basically, when you leave out the '{' then Haskell uses your intendation to insert ';}' on later lines between the leading whitespace and the first token.

There some really old Haskell code out there that lines up the '{;}' characters on the left under block-introduction keywords.

[โ€“] barsoap@lemm.ee 4 points 3 months ago

It's not just old Haskell code that's how you write Haskell if you want explicit braces. Well, mostly generate, but it's still the idiomatic formatting (and when you generate you always generate braces because it's easy to get layout subtly wrong when generating).

Haskell also does the whole

data Foo = Bar
         | Baz
         | Quux

foo = [ Bar
      , Baz
      , Quux
      ]

thing, makes sense to apply it to braces especially as they're seen only very rarely. Single-line, yes, but not multi-line.