## Data types à la carte

Citations: | 37 - 1 self |

### BibTeX

@MISC{Swierstra_datatypes,

author = {Wouter Swierstra},

title = {Data types à la carte},

year = {}

}

### OpenURL

### Abstract

This paper describes a technique for assembling both data types and functions from isolated individual components. We also explore how the same technology can be used to combine free monads and, as a result, structure Haskell’s monolithic IO monad. 1

### Citations

308 | Functional programming with bananas, lenses, envelopes and barbed wire
- Meijer, Fokkinga, et al.
- 1991
(Show Context)
Citation Context ...re is part of the functional programming folklore. The fixed-points of functors and their corresponding folds have been introduced to the functional programming community more than fifteen years ago (=-=Meijer et al., 1991-=-). More recently, Tim Sheard (2001) has proposed using fixed-points of functors to write modular code. Free monads are well understood in category theory, but are much less widespread in the functiona... |

248 | Monad transformers and modular interpreters
- Liang, Hudak, et al.
- 1995
(Show Context)
Citation Context ...ds are well understood in category theory, but are much less widespread in the functional programming community. The (:≺:) class is an obvious generalization of existing work on modular interpreters (=-=Liang et al., 1995-=-). Yet, amazingly, no one has ever put all these pieces together. I am sure there are many, many other ways to achieve results very similar to ones presented here. Haskell’s type class system, along w... |

37 |
Category Theory
- AWODEY
- 2006
(Show Context)
Citation Context ...Impure t) = Impure (fmap (fmap f ) t) instance Functor f ⇒ Monad (Term f ) where return x = Pure x (Pure x) >= f = f x (Impure t) >= f = Impure (fmap ( >=f ) t) These monads are known as free monads (=-=Awodey, 2006-=-). Several monads you may already be familiar with are free monads. Consider the following types: data Zero a data One a = One data Const e a = Const e Now Term Zero is the identity monad; Term One co... |

25 | Foundations for structured programming with GADTs
- Johann, Ghani
- 2008
(Show Context)
Citation Context ...ngly, this requires a shift from functors to bifunctors. This approach does have its limitations. Although GADTs and nested data types can also be expressed as initial algebras (Johann & Ghani, 2007; =-=Johann & Ghani, 2008-=-), doing so requires a higher-order representation of data types that can be a bit cumbersome to program with in Haskell. Furthermore, modular functions that take different types of modular arguments ... |

24 | Composing Monads Using Coproducts
- Lüth, Ghani
- 2002
(Show Context)
Citation Context ... all their virtues, however, monads are notoriously difficult to combine. Can we extend our approach to combine monads using coproducts? In general, the coproduct of two monads is fairly complicated (=-=Lüth & Ghani, 2002-=-). We choose to restrict ourself to monads of the following form: data Term f a = Pure a | Impure (f (Term f a)) These monads consist of either pure values or an impure effect, constructed usingsFunct... |

16 | Generic Unification via Two-Level Types and Parameterized Modules - Sheard - 2001 |

16 |
Beauty in the beast: A functional semantics of the awkward squad
- Swierstra, Altenkirch
- 2007
(Show Context)
Citation Context ... additional advantage of this two-step approach is that the terms we write are pure Haskell values—information we can exploit if we are interested in debugging or reasoning about effectful functions (=-=Swierstra & Altenkirch, 2007-=-). 8 Discussion There are many interesting topics that I have not covered. While we have encountered the fold over a data type, I have not mentioned the unfold. Furthermore, we have not dealt with pol... |

3 |
Initial algebra semantics is enough! Typed Lambda Calculi and Applications
- Johann, Ghani
- 2007
(Show Context)
Citation Context ...ove. Rather unsurprisingly, this requires a shift from functors to bifunctors. This approach does have its limitations. Although GADTs and nested data types can also be expressed as initial algebras (=-=Johann & Ghani, 2007-=-; Johann & Ghani, 2008), doing so requires a higher-order representation of data types that can be a bit cumbersome to program with in Haskell. Furthermore, modular functions that take different types... |

1 |
Open data types and open functions. Principles and Practice of Declarative Programming
- Löh, Hinze
- 2006
(Show Context)
Citation Context ...t addition. In fact, once we have a menu of expression building blocks, we can assemble our own data types à la carte. This is not even possible with proposed language extensions for open data types (=-=Löh & Hinze, 2006-=-). Adding new functions is not much more difficult. As a second example, we show how to render an expression as a string. Instead of writing this as a fold, we give an example of how to write open-end... |