Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It depends on context. For example, here is a function from a project I'm working on:

    parseModifier : String -> Outcome Modifier
    parseModifier s = case s of
      "shift"   -> Ok Shift
      "ctrl"    -> Ok Ctrl
      "alt"     -> Ok Alt
      "meta"    -> Ok Meta
      "command" -> Ok Meta
      "windows" -> Ok Meta
      x         -> Err <| "Unknown modifier: " ++ x
I find it easier to read as is rather than if I dropped the alignment:

    parseModifier : String -> Outcome Modifier
    parseModifier s = case s of
      "shift" -> Ok Shift
      "ctrl" -> Ok Ctrl
      "alt" -> Ok Alt
      "meta" -> Ok Meta
      "command" -> Ok Meta
      "windows" -> Ok Meta
      x -> Err <| "Unknown modifier: " ++ x
As developers we spend more time reading code than editing it. Optimizing for readability seems like a better goal than optimizing for edit speed. Besides, most editors have functionality to align code. When I am looking over a file, the second example looks like a jumble of words to me, while the aligned version seems easier to parse (ha).



I agree that unaligned switches/pattern matches are bad (and in fact, there is an utility for OCaml which will nicely indent your pattern matches).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: