Tomas Petricek and Don Syme
In pre-proceedings of TFP 2012
The academic literature describes a number of abstract computation types such as monads, applicative functors and their compositions. These can be used to describe features of mainstream languages such as generators in Python or asynchronous computations in C# 5, but working with abstract computations without a convenient syntactic sugar is difficult.
In this paper, we describe computation expressions, which is a syntactic sugar for working with abstract computations in F# 2.0. Unlike the do notation in Haskell, computation expressions are not tied to a single kind of abstract computations. They support wider range of computations, depending on what operations are available and they also provide greater syntactic flexibility.
As a result, F# programmers are able to use a single syntactic sugar for a wider range of computations including monoidal sequence generators, monadic parsers and applicative formlets. This removes the need for ad-hoc language extensions that provide “nice syntax” for one particular kind of computations.
@other{comprefun,
author = {Petricek, Tomas and Syme, Don},
title = {{S}yntax {M}atters: Writing abstract computations in F#},
howpublished = {Pre-proceedings of TFP},
year = {2012},
url = {http://www.cl.cam.ac.uk/{\textasciitilde}tp322/drafts/notations.pdf},
}
If you have any comments, suggestions or related ideas, I'll be happy to hear from you at