Results 1  10
of
10
Programming and Reasoning with Algebraic Effects and Dependent Types
"... One often cited benefit of pure functional programming is that pure code is easier to test and reason about, both formally and informally. However, real programs have sideeffects including state management, exceptions and interactions with the outside world. Haskell solves this problem using monads ..."
Abstract

Cited by 20 (1 self)
 Add to MetaCart
(Show Context)
One often cited benefit of pure functional programming is that pure code is easier to test and reason about, both formally and informally. However, real programs have sideeffects including state management, exceptions and interactions with the outside world. Haskell solves this problem using monads to capture details of possibly sideeffecting computations — it provides monads for capturing State, I/O, exceptions, nondeterminism, libraries for practical purposes such as CGI and parsing, and many others, as well as monad transformers for combining multiple effects. Unfortunately, useful as monads are, they do not compose very well. Monad transformers can quickly become unwieldy when there are lots of effects to manage, leading to a temptation in larger programs to combine everything into one coarsegrained state and exception monad. In this paper I describe an alternative approach based on handling algebraic effects, implemented in the IDRIS programming language. I show how to describe side effecting computations, how to write programs which compose multiple finegrained effects, and how, using dependent types, we can use this approach to reason about states in effectful programs. 1.
Monatron: an extensible monad transformer library. Available at http://www.cs.nott.ac.uk/~mjj/pubs/monatron.pdf
"... Abstract. Monads are pervasive in functional programming. In order to reap the benefits of their abstraction power, combinator libraries for monads are necessary. Monad transformers provide the basis for such libraries, and are based on a design that has proved to be successful. In this article, we ..."
Abstract

Cited by 17 (2 self)
 Add to MetaCart
(Show Context)
Abstract. Monads are pervasive in functional programming. In order to reap the benefits of their abstraction power, combinator libraries for monads are necessary. Monad transformers provide the basis for such libraries, and are based on a design that has proved to be successful. In this article, we show that this design has a number of shortcomings and provide a new design that builds on the strengths of the traditional design, but addresses its problems. 1
Factorising Folds for Faster Functions
"... The worker/wrapper transformation is a general technique for improving the performance of recursive programs by changing their types. The previous formalisation (Gill & Hutton, 2009) was based upon a simple fixed point semantics of recursion. In this article we develop a more structured approach ..."
Abstract

Cited by 13 (9 self)
 Add to MetaCart
The worker/wrapper transformation is a general technique for improving the performance of recursive programs by changing their types. The previous formalisation (Gill & Hutton, 2009) was based upon a simple fixed point semantics of recursion. In this article we develop a more structured approach, based upon initial algebra semantics. In particular, we show how the worker/wrapper transformation can be applied to programs defined using the structured pattern of recursion captured by fold operators, and illustrate our new technique with a number of examples.
Monad Transformers as Monoid Transformers
"... The incremental approach to modular monadic semantics constructs complex monads by using monad transformers to add computational features to a preexisting monad. A complication of this approach is that the operations associated to the preexisting monad need to be lifted to the new monad. In a compa ..."
Abstract

Cited by 9 (1 self)
 Add to MetaCart
(Show Context)
The incremental approach to modular monadic semantics constructs complex monads by using monad transformers to add computational features to a preexisting monad. A complication of this approach is that the operations associated to the preexisting monad need to be lifted to the new monad. In a companion paper by Jaskelioff, the lifting problem has been addressed in the setting of system F ω. Here, we recast and extend those results in a categorytheoretic setting. We abstract and generalize from monads to monoids (in a monoidal category), and from monad transformers to monoid transformers. The generalization brings more simplicity and clarity, and opens the way for lifting of operations with applicability beyond monads. Key words: Monad, Monoid, Monoidal Category
The Monad Zipper
, 2010
"... Limitations of the monad stacks get in the way of developing highly modular programs with effects. This pearl demonstrates that Functional Programming’s abstractions are up to the challenge. Of course, abstraction must be followed by clever instantiation: Huet’s zipper for the monad stack makes comp ..."
Abstract

Cited by 2 (2 self)
 Add to MetaCart
Limitations of the monad stacks get in the way of developing highly modular programs with effects. This pearl demonstrates that Functional Programming’s abstractions are up to the challenge. Of course, abstraction must be followed by clever instantiation: Huet’s zipper for the monad stack makes components jump through unanticipated hoops.
Reflection without Remorse Revealing a hidden sequence to speed up monadic reflection
"... A series of list appends or monadic binds for many monads performs algorithmically worse when leftassociated. Continuationpassing style (CPS) is wellknown to cure this severe dependence of performance on the association pattern. The advantage of CPS dwindles or disappears if we have to examine o ..."
Abstract

Cited by 2 (0 self)
 Add to MetaCart
(Show Context)
A series of list appends or monadic binds for many monads performs algorithmically worse when leftassociated. Continuationpassing style (CPS) is wellknown to cure this severe dependence of performance on the association pattern. The advantage of CPS dwindles or disappears if we have to examine or modify the intermediate result of a series of appends or binds, before continuing the series. Such examination is frequently needed, for example, to control search in nondeterminism monads. We present an alternative approach that is just as general as CPS but more robust: it makes series of binds and other such operations efficient regardless of the association pattern – and also provides efficient access to intermediate results. The key is to represent such a conceptual sequence as an efficient sequence data structure. Efficient sequence data structures from the literature are homogeneous and cannot be applied as they are in a typesafe way to series of monadic binds. We generalize them to type aligned sequences and show how to construct their (assuredly orderpreserving) implementations. We demonstrate that our solution solves previously undocumented, severe performance problems in iteratees, LogicT transformers, free monads and extensible effects. Categories and Subject Descriptors D.3.2 [Programming Lan
Functional Pearl: The Monad Zipper
"... Limitations of monad stacks get in the way of developing highly modular programs with effects. This pearl demonstrates that Functional Programming’s abstraction tools are up to the challenge. Of course, abstraction must be followed by clever instantiation: Huet’s zipper for the monad stack makes com ..."
Abstract
 Add to MetaCart
Limitations of monad stacks get in the way of developing highly modular programs with effects. This pearl demonstrates that Functional Programming’s abstraction tools are up to the challenge. Of course, abstraction must be followed by clever instantiation: Huet’s zipper for the monad stack makes components jump through unanticipated hoops. Categories and Subject Descriptors D.1.1 [Programming Techniques]:
HoareStyle Reasoning with (Algebraic) Continuations
"... Continuations are programming abstractions that allow for manipulating the “future ” of a computation. Amongst their many applications, they enable implementing unstructured program flow through higherorder control operators such as callcc. In this paper we develop a Hoarestyle logic for the verif ..."
Abstract
 Add to MetaCart
(Show Context)
Continuations are programming abstractions that allow for manipulating the “future ” of a computation. Amongst their many applications, they enable implementing unstructured program flow through higherorder control operators such as callcc. In this paper we develop a Hoarestyle logic for the verification of programs with higherorder control, in the presence of dynamic state. This is done by designing a dependent type theory with first class callcc and abort operators, where pre and postconditions of programs are tracked through types. Our operators are algebraic in the sense of Plotkin and Power, and Jaskelioff, to reduce the annotation burden and enable verification by symbolic evaluation. We illustrate working with the logic by verifying a number of characteristic examples. 1.
Kan Extensions for Program Optimisation Or: Art and Dan Explain an Old Trick
"... Abstract. Many program optimisations involve transforming a program in direct style to an equivalent program in continuationpassing style. This paper investigates the theoretical underpinnings of this transformation in the categorical setting of monads. We argue that socalled absolute Kan Extens ..."
Abstract
 Add to MetaCart
(Show Context)
Abstract. Many program optimisations involve transforming a program in direct style to an equivalent program in continuationpassing style. This paper investigates the theoretical underpinnings of this transformation in the categorical setting of monads. We argue that socalled absolute Kan Extensions underlie this program optimisation. It is known that every Kan extension gives rise to a monad, the codensity monad, and furthermore that every monad is isomorphic to a codensity monad. The end formula for Kan extensions then induces an implementation of the monad, which can be seen as the categorical counterpart of continuationpassing style. We show that several optimisations are instances of this scheme: Church representations and implementation of backtracking using success and failure continuations, among others. Furthermore, we develop the calculational properties of Kan extensions, powers and ends. In particular, we propose a twodimensional notation based on string diagrams that aims to support effective reasoning with Kan extensions.