## Programming monads operationally with Unimo (2006)

Venue: | In ICFP |

Citations: | 6 - 2 self |

### BibTeX

@INPROCEEDINGS{Lin06programmingmonads,

author = {Chuan-kai Lin},

title = {Programming monads operationally with Unimo},

booktitle = {In ICFP},

year = {2006},

pages = {274--285}

}

### OpenURL

### Abstract

Monads are widely used in Haskell for modeling computational effects, but defining monads remains a daunting challenge. Since every part of a monad’s definition depends on its computational effects, programmers cannot leverage the common behavior of all monads easily and thus must build from scratch each monad that models a new computational effect. I propose the Unimo framework which allows programmers to define monads and monad transformers in a modular manner. Unimo contains a heavily parameterized observer function which enforces the monad laws, and programmers define a monad by invoking the observer function with arguments that specify the computational effects of the monad. Since Unimo provides the common behavior of all monads in a reusable form, programmers no longer need to rebuild the semantic boilerplate for each monad and can instead focus on the more interesting and rewarding task of modeling the desired computational effects.

### Citations

1537 | Aspect-oriented programming
- Kiczales, Lamping, et al.
(Show Context)
Citation Context ...ations. 8.4 Aspect-oriented programming Aspect-oriented programming is a paradigm which aims to address the issue of cross-cutting concerns that cannot be extracted with typical modularity mechanisms =-=[13]-=-. In a system like AspectJ [12], an aspect consists of pointcut declarations which specify certain points of program execution, and advice declarations which specify when the inserted code should exec... |

1079 | An Overview of AspectJ
- Kiczales, Hilsdale, et al.
- 2001
(Show Context)
Citation Context ...gramming Aspect-oriented programming is a paradigm which aims to address the issue of cross-cutting concerns that cannot be extracted with typical modularity mechanisms [13]. In a system like AspectJ =-=[12]-=-, an aspect consists of pointcut declarations which specify certain points of program execution, and advice declarations which specify when the inserted code should execute in relation to the defined ... |

733 | Notions of Computation and Monads
- Moggi
- 1991
(Show Context)
Citation Context ...onad transformers, Unimo Monads are a mathematical abstraction that can be used to model a wide variety of computational effects. They were initially used by Moggi to structure denotational semantics =-=[16, 17]-=- and were later introduced into Haskell to support input–output operations [7]. In Haskell, monadic computations are first-class values which can be stored in data structures, and programmers can defi... |

440 | Computational lambda-calculus and monads
- Moggi
- 1989
(Show Context)
Citation Context ...onad transformers, Unimo Monads are a mathematical abstraction that can be used to model a wide variety of computational effects. They were initially used by Moggi to structure denotational semantics =-=[16, 17]-=- and were later introduced into Haskell to support input–output operations [7]. In Haskell, monadic computations are first-class values which can be stored in data structures, and programmers can defi... |

233 | Monad Transformers and Modular Interpreters
- Liang, Hudak, et al.
- 1995
(Show Context)
Citation Context .... Compared to Claessen’s implementation, the Unimo-based implementation is 20%–40% slower but consumes roughly the same amount of memory. 6. Defining monad transformers with Unimo A monad transformer =-=[14]-=- is a mechanism for adding computational effects onto an existing monad (which is usually called the underlying monad). For example, a state monad transformer adds mutable state to a monad. In Haskell... |

160 | Generalising monads to arrows
- Hughes
- 2000
(Show Context)
Citation Context ...wing section. 5. Parallel parsing processes Parallel parsing processes [1] is a monad proposed by Claessen that eliminates the space leak exhibited by backtracking monadic parser combinator libraries =-=[5]-=-. When there are multiple parses for a sequence of symbols, a backtracking parser employs a depthfirst search strategy that tries all parses in turn. When the monad pursues a successful parse, all alt... |

146 |
Component-Based Semantics
- Mosses
- 2009
(Show Context)
Citation Context ...arious Haskell expressions denote what the monad operators and the effect basis are. While denotations are a useful and well-established technique for defining the semantics of programming constructs =-=[18]-=-, I believe that they unnecessarily complicate the definition of monads for the following reasons: Monad laws The Haskell compiler ensures only that the return and ≫= operators in an instance of the M... |

104 |
Project Oberon – The Design of an Operating System and Compiler
- Wirth, Gutknecht
- 1998
(Show Context)
Citation Context ...assification function. I have translated the grammar of the Oberon programming language [19] into a monadic parser and benchmarked the two parallel parser monads using sample code from Project Oberon =-=[20]-=-. Compared to Claessen’s implementation, the Unimo-based implementation is 20%–40% slower but consumes roughly the same amount of memory. 6. Defining monad transformers with Unimo A monad transformer ... |

99 | Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in haskell
- Jones
- 2002
(Show Context)
Citation Context ...utational effects including state, exceptions, nondeterminism, resumptions, and continuations. These qualities made Jones conclude that “Haskell is the world’s finest imperative programming language” =-=[6]-=-. c○ ACM, (2006). This is the author’s version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in Proceedings of... |

91 | Practical type inference for arbitrary-rank types. Submitted to the Journal of Functional Programming
- Jones, Vytiniotis, et al.
- 2005
(Show Context)
Citation Context ...connections between monads and monad transformers, and it leads to a procedure for adapting a Unimo-based monad into the corresponding monad transformer. The implementation of Unimo uses rank-2 types =-=[9]-=-, generalized algebraic datatypes [10], and lexically-scoped type variables [8]; thus it works only with recent versions of GHC. I believe that Unimo makes it easier not only to define monads, but als... |

81 | The Design of a Pretty-printing Library
- HUGHES
- 1995
(Show Context)
Citation Context ...hat result should be produced by a computation and not on how the result should be produced. In addition to correctness, practical programmers also care about the space and time efficiency of a monad =-=[1, 4]-=-, and working with denotations makes it difficult to investigate or to tweak these operational characteristics. In Section 3 I will show how defining monads through operations (what a thing does) comp... |

48 | The evolution of Lisp
- Gabriel
- 1996
(Show Context)
Citation Context ...ost significant ones and explain how they relate to this work. 8.1 Representing code as data The design of Unimo is heavily influenced by the idea of representing code as data that originated in Lisp =-=[11]-=-. Using data constructors as placeholders for monad operators and the effect basis, Unimo turns computations into algebraic data that are later transformed and evaluated. Nonetheless, there are signif... |

42 |
Programming in Oberon - Steps Beyond Pascal and Modula
- Reiser, Wirth
- 1992
(Show Context)
Citation Context ...a parse computation into a sequence of effect-basis computations and greatly simplifies the definition of the classification function. I have translated the grammar of the Oberon programming language =-=[19]-=- into a monadic parser and benchmarked the two parallel parser monads using sample code from Project Oberon [20]. Compared to Claessen’s implementation, the Unimo-based implementation is 20%–40% slowe... |

27 | Deriving backtracking monad transformers
- Hinze
- 2000
(Show Context)
Citation Context ...ould produce the same results, but evaluating t1 prints abccdd, and evaluating t2 prints abcdcd.Hinze proposed a backtracking monad transformer that does not depend on a commutative underlying monad =-=[3]-=-, but his technique requires a completely different design strategy, and to the best of my knowledge there is no simple way to fix the code in Figure 11 to eliminate the problem. 6.2 The principles of... |

15 | Achieving information flow security through precise control of effects
- Harrison, Hook
- 2005
(Show Context)
Citation Context ... building an implementation from the ground up. 8.3 Reactive resumption monads Harrison and Hook investigated using reactive resumption monads to model computations that interact with the environment =-=[2]-=-. A reactive resumption monad differs from a resumption monad in that the computation makes a request of type q when it pauses, and the environment must provide a response of type r to resume the comp... |

10 |
Lexically scoped type variables
- Jones, Shields
- 2004
(Show Context)
Citation Context ...for adapting a Unimo-based monad into the corresponding monad transformer. The implementation of Unimo uses rank-2 types [9], generalized algebraic datatypes [10], and lexically-scoped type variables =-=[8]-=-; thus it works only with recent versions of GHC. I believe that Unimo makes it easier not only to define monads, but also to define monads correctly. The specific technical contributions of this pape... |

6 |
Monads as a theoretical foundation for AOP. Position paper
- Meuter
- 1997
(Show Context)
Citation Context ...cify, for example, that the moved field of an object be set to true after the x field of the object is set. De Meuter proposed using monads as a theoretical foundation for aspect-oriented programming =-=[15]-=-. In his design, weaving an aspect into a computation requires redefining the monad operators, which makes the use of aspects much more complicated than in systems like AspectJ. Also, since pointcuts ... |

5 |
Functional pearl: Parallel parsing processes
- Claessen
(Show Context)
Citation Context ...in Haskell. The Monad instance declaration overloads the monad operators, and the MonadPlus instance declaration defines the effect basis. • An implementation of Claessen’s parallel parsing processes =-=[1]-=- constructed from an algorithm description instead of through formal derivations (Section 5) • An implementation of the list monad transformer that does not require a commutative underlying monad (Sec... |

4 |
Wobbly types: type inference for generalized algebraic data types
- Jones, Washburn, et al.
- 2004
(Show Context)
Citation Context ...transformers, and it leads to a procedure for adapting a Unimo-based monad into the corresponding monad transformer. The implementation of Unimo uses rank-2 types [9], generalized algebraic datatypes =-=[10]-=-, and lexically-scoped type variables [8]; thus it works only with recent versions of GHC. I believe that Unimo makes it easier not only to define monads, but also to define monads correctly. The spec... |