DEV Community

Cover image for F#'s Stack Overflow community is amazing
André Slupik
André Slupik

Posted on

F#'s Stack Overflow community is amazing

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
Enter fullscreen mode Exit fullscreen mode

Lo and behold, it had already been asked, and already had a great, detailed answer by user Fyodor Soikin. He pointed me to it literally within minutes of my post. I was amazed.

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)