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 task block waits on .NET tasks. A small custom option builder makes the parser stop as soon as a step returns None.
  • Haskell uses its built-in Maybe type with do notation 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 if statement or a call that returns void directly 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.