Comment by shortrounddev2
Comment by shortrounddev2 2 days ago
I'm saying that I wish computation blocks looked better in F#. Instead of:
let foo id = async {
let! bar = getBar id
return bar
}
I would prefer let async foo id =
let! bar = getBar id
bar
or even something like let async foo id =
getBar! id
So that computation blocks don't feel like you're switching to an entirely different language. Just wrap the ugliness in the same syntactic sugar that C# does. As it is, C# can achieve arrow syntax with async methods more elegantly than F# can: async Task<string> foo(int id) => await getBar(id);
This, to me, is also part of a larger problem of F# introducing unique keywords for specific language functions instead of reusing keywords, like member this.Foo = ...
and member val Foo = ...
Your criticism is rather incoherent and it is difficult for me to make sense of it.
You don't even have to use the computation block for that and can use the built in functions as I mentioned earlier and gave 3 examples of.
You're both complaining about extra keywords while trying to make the case of adding yet another one. Thus your complaint boils down to F# not picking the exact keywords that you like - that the language is not specialized to exactly how you want to use it. In language design there are always tradeoffs but I'm unable to see how your suggestions would improve the language in the general case or even in your specific case.
Computation expressions are a generalized concept which are there to add the exact kind of syntactic sugar that you're after. It's better than C# in that you can create your own as a first class concept in addition to using the built in ones. It's there for the exact purpose of creating mini-embedded DSLs, the very thing you're complaining about is the exact point of it.
F# is not for everyone, nor should it be.