Skip to main content

The F# Computation Expression Zoo

Petricek, Tomas and Syme, Don (2014) The F# Computation Expression Zoo. In: Flatt, Matthew and Guo, Hai-Feng, eds. Practical Aspects of Declarative Languages. Lecture Notes in Computer Science . Springer, New York, NY, USA, pp. 33-48. ISBN 978-3-319-04131-5. (doi:10.1007/978-3-319-04132-2_3) (KAR id:69692)

PDF Author's Accepted Manuscript
Language: English
Download (269kB) Preview
[img]
Preview
Official URL
http://dx.doi.org/10.1007/978-3-319-04132-2_3

Abstract

Program logic can often be structured using abstract computation types such as monoids, monad transformers or applicative functors. Functional programmers use those abstractions directly while main-stream languages often integrate concrete instances as language features – e.g. generators in Python or asynchronous computations in C# 5.0. The question is, is there a sweet spot between convenient, hardwired language features, and an inconvenient but flexible libraries?

F# computation expressions answer this question in the affirmative. Unlike the “do” notation in Haskell, computation expressions are not tied to a single kind of abstraction. They support a wide range of abstractions, depending on what operations are available. F# also provides greater syntactic flexibility leading to a more intuitive syntax, without resorting to full macro-based meta-programming.

We present computation expressions in a principled way, developing a type system that captures the semantics of the calculus. We demonstrate how computation expressions structure well-known abstractions including monoidal list comprehensions, monadic parsers, applicative formlets and asynchronous sequences based on monad transformers.

Item Type: Book section
DOI/Identification number: 10.1007/978-3-319-04132-2_3
Uncontrolled keywords: List Comprehension, Type Unit, Typing Rule, Transactional Memory, Exception Handling
Subjects: Q Science > QA Mathematics (inc Computing science) > QA 76 Software, computer programming,
Divisions: Faculties > Sciences > School of Computing
Faculties > Sciences > School of Computing > Programming Languages and Systems Group
Depositing User: Tomas Petricek
Date Deposited: 19 Oct 2018 13:52 UTC
Last Modified: 06 May 2020 03:18 UTC
Resource URI: https://kar.kent.ac.uk/id/eprint/69692 (The current URI for this page, for reference purposes)
Petricek, Tomas: https://orcid.org/0000-0002-7242-2208
  • Depositors only (login required):

Downloads

Downloads per month over past year