I recently asked a question about F# syntax on Stack Overflow. It seemed like a weird edge case with indentation, and I did not expect many people to have encountered this; if they did, they were unlikely to know the answer as it would be quite technical. Still, I wanted to do due diligence before opening an issue on the F# compiler repo.
// This is just an alias of |> let inline (|>!) (a: 'T) (f: 'T -> 'U) = f a Some 5 |> function | Some b -> b | None -> 0 |>! printfn "%d" // FS0001: The type 'int' does not match the type 'unit' // if you replace |>! with |> it compiles, even though // it's literally the same operator // seriously, who's going to know the answer to this // or so I thought
For the curious, a short version of it would be this. While a human reads the above as:
Some 5 |> (function | Some b -> b | None -> 0) |>! printfn "%d"
Because my operator has 3 characters instead of 2, this pushes the
printfn one space, right under the
0 above, and F# interprets it as:
Some 5 |> function | Some b -> b // this is an int | None -> 0 |>! printfn "%d" // this is unit, so the types mismatch
But that's not really the point of this blog post; see the linked question for the juicy technical details.
I've had this experience several times now over my many years of using F#, where I'll ask something simple and then get an answer from someone like e.g. Tomas Petricek, just to name one, with great thought and care, rigorous detail and technical clarity. The level of passion and knowledge demonstrated by many F# community members never ceases to impress me. Even compared to other great SO communities, F#'s feels more friendly, passionate and technically proficient.
Coming from more mainstream languages, one might think moving to a smaller community would make it harder to find support. I think the F# community demonstrates that's not about quantity but quality.