Mark Seemann likes what C#’s async/await does for code that waits on I/O. He asks what else that style of writing could do. His example is a parser that should stop at the first invalid field, a workflow that F# and Haskell can express as a straight sequence of steps.
- F# uses computation expressions, blocks whose rules can be set by a library. A
taskblock waits on .NET tasks. A small customoptionbuilder makes the parser stop as soon as a step returnsNone. - Haskell uses its built-in
Maybetype withdonotation to get the same early exit without a custom builder. - C# can express the early exit with LINQ query syntax. That syntax has separate limits: you can’t put an
ifstatement or a call that returnsvoiddirectly in a query clause.
F#’s task blocks use the same .NET task machinery as C#. That makes the comparison about language design rather than runtime speed. When several workflows need the same readable sequence of steps, it’s worth asking which rules the language should fix and which rules a library should supply.