Skip to main content
Kent Academic Repository

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)

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: Divisions > Division of Computing, Engineering and Mathematical Sciences > School of Computing
Depositing User: Tomas Petricek
Date Deposited: 19 Oct 2018 13:52 UTC
Last Modified: 05 Nov 2024 12:31 UTC
Resource URI: https://kar.kent.ac.uk/id/eprint/69692 (The current URI for this page, for reference purposes)

University of Kent Author Information

  • Depositors only (login required):

Total unique views for this document in KAR since July 2020. For more details click on the image.