## Monads, Zippers and Views Virtualizing the Monad

### BibTeX

@MISC{Schrijvers_monads,zippers,

author = {Tom Schrijvers and Bruno C. D. S. Oliveira},

title = {Monads, Zippers and Views Virtualizing the Monad},

year = {}

}

### OpenURL

### Abstract

Abstract. This work aims at making monadic components more reusable and robust to changes by employing two new techniques for virtualizing the monad stack: the monad zipper and monad views. The monad zipper is a monad transformer that creates virtual monad stacks by ignoring particular layers in a concrete stack. Monad views provide a general framework for monad stack virtualization: they take the monad zipper one step further and integrate it with a wide range of other virtualizations. For instance, particular views allow restricted access to monads in the stack. Furthermore, monad views can be used by components to provide a call-by-reference-like mechanism to access particular layers of the monad stack. With these two mechanisms component requirements in terms of the monad stack shape no longer need to be literally reflected in the concrete monad stack, making these components more reusable and robust to changes. 1

### Citations

1309 | Monads for Functional Programming
- Wadler
- 1995
(Show Context)
Citation Context ...requirements in terms of the monad stack shape no longer need to be literally reflected in the concrete monad stack, making these components more reusable and robust to changes. 1 Introduction Monads =-=[1]-=- are an abstraction for encapsulating side-effects in purely functional languages like Haskell [2], which models different types of effects – such as state, nondeterminism or exceptions – with the sam... |

345 | How to make ad-hoc polymorphism less ad hoc
- Wadler, Blott
- 1989
(Show Context)
Citation Context ...o manage the monad stack. There are two existing approaches for this: implicit liftings and explicit liftings. Implicit liftings exploit type-directed overloading of methods, provided by type classes =-=[6]-=-, to automatically route an effectful operation to the first layer of the right type in the monad stack. Explicit liftings offer more control to programmers, at the cost of automation, by allowing mon... |

233 | Monad Transformers and Modular Interpreters
- Liang, Hudak, et al.
- 1995
(Show Context)
Citation Context ...ke Haskell [2], which models different types of effects – such as state, nondeterminism or exceptions – with the same abstract interface. Monads are composed via mechanisms such as monad transformers =-=[3]-=-. With monad transformers writing programs that use multiple effects is possible by stacking different transformers on top of each other to form a larger monad. Monads and monad transformers are inter... |

165 |
An Abstract View of Programming Languages
- Moggi
- 1989
(Show Context)
Citation Context ...ump (� 0) ‘fmask‘ r ‘usesm‘ Err & Memo � prof ‘usesm‘ Prof � memo ‘usesm‘ Memo � fib) myEval m = runI $ runTS T Memo empty $ runTS T Prof 0 $ runTE T Err $ m7 Related Work Modular Monads Since Moggi =-=[11]-=- proposed monads to model side-effects, and Wadler [12] popularized them in the context of Haskell, various researchers (e.g., [13, 14]) have sought to modularize monads. Monad transformers emerged [3... |

141 | A Denotational Semantics of Inheritance
- Cook
- 1989
(Show Context)
Citation Context ... do not pose a problem. 6.1 Monadic Mixin Components Mixins We briefly summarize the notion of mixins, and refer the interested reader to previous literature on the topic for a more indepth treatment =-=[10]-=-. A simple form of mixins can be easily implemented in Haskell as follows: type Mixin s = s → s fix :: Mixin s → s fix a = a (fix a) (�) :: Mixin s → Mixin s → Mixin s a1 � a2 = λproceed → a1 (a2 proc... |

69 | Composing monads
- Jones, Duponcheel
- 1993
(Show Context)
Citation Context ...T Prof 0 $ runTE T Err $ m7 Related Work Modular Monads Since Moggi [11] proposed monads to model side-effects, and Wadler [12] popularized them in the context of Haskell, various researchers (e.g., =-=[13, 14]-=-) have sought to modularize monads. Monad transformers emerged [3] from this process, and in later years various alternative implementation designs, facilitating monad (transformer) implementations, h... |

55 |
et al. The Haskell 98 language and libraries: The revised report
- Jones
- 2003
(Show Context)
Citation Context ...crete monad stack, making these components more reusable and robust to changes. 1 Introduction Monads [1] are an abstraction for encapsulating side-effects in purely functional languages like Haskell =-=[2]-=-, which models different types of effects – such as state, nondeterminism or exceptions – with the same abstract interface. Monads are composed via mechanisms such as monad transformers [3]. With mona... |

34 | Data types à la carte
- Swierstra
- 2008
(Show Context)
Citation Context ...-style advice with them. Prehofer [5] considers an monadic model for FOP. The techniques presented in this paper can be used to improve the current state-of-the-art approaches to modular interpreters =-=[3, 16, 17]-=-. We describe a modular effectful interpreter case study, which uses the techniques presented in this paper, in a separate manuscript [18]. 8 Conclusion The current-state-of-the-art in monad stack man... |

31 | Building Interpreters by Composing Monads
- Steele
- 1994
(Show Context)
Citation Context ...T Prof 0 $ runTE T Err $ m7 Related Work Modular Monads Since Moggi [11] proposed monads to model side-effects, and Wadler [12] popularized them in the context of Haskell, various researchers (e.g., =-=[13, 14]-=-) have sought to modularize monads. Monad transformers emerged [3] from this process, and in later years various alternative implementation designs, facilitating monad (transformer) implementations, h... |

18 | Functional Pearl: The Zipper
- Huet
- 1997
(Show Context)
Citation Context ...ucture of the monad stack in a data type data Stack = Trans · Stack | Bottom Monad data Trans = T1 | ... | Tn data Monad = I where the Ti represent the different transformers and I represents I. Huet =-=[9]-=- taught us how to shift the focus to any position in a data structure, with his zipper. Here is the Zipper for Stack: data Zipper = Zipper Path Trans Stack data Path = Path ◮ Trans | Top where Zipper ... |

14 | Effectiveadvice: disciplined advice with explicit effects
- Oliveira, Schrijvers, et al.
- 2010
(Show Context)
Citation Context ... enjoying reasoning principles such as equational reasoning and parametricity. Furthermore, they enable the study of modular effectuful components, like Aspect-Oriented Programming (AOP) style advice =-=[4]-=- or models of Feature-Oriented Programming (FOP) [5], in the context of Haskell. Monad transformers come with a responsability: it is necessary to manage the monad stack. There are two existing approa... |

7 |
Flexible construction of software components: A feature oriented approach
- Prehofer
- 1999
(Show Context)
Citation Context ...asoning and parametricity. Furthermore, they enable the study of modular effectuful components, like Aspect-Oriented Programming (AOP) style advice [4] or models of Feature-Oriented Programming (FOP) =-=[5]-=-, in the context of Haskell. Monad transformers come with a responsability: it is necessary to manage the monad stack. There are two existing approaches for this: implicit liftings and explicit liftin... |

7 |
Writing modular interpreters using catamorphisms, subtypes and monad transformers
- Duponcheel
- 1995
(Show Context)
Citation Context ...-style advice with them. Prehofer [5] considers an monadic model for FOP. The techniques presented in this paper can be used to improve the current state-of-the-art approaches to modular interpreters =-=[3, 16, 17]-=-. We describe a modular effectful interpreter case study, which uses the techniques presented in this paper, in a separate manuscript [18]. 8 Conclusion The current-state-of-the-art in monad stack man... |

4 |
Monadic memoization mixins
- Brown, Cook
- 2007
(Show Context)
Citation Context ...ents Many works have identified a need for reusable monadic components, but have not addressed the limitations. Mixins were introduced by Cook [10] as a functional form of inheritance. Brown and Cook =-=[15]-=- first considered monadic mixins for memoization, while Oliveira et al. [4] model arbitrary AOP-style advice with them. Prehofer [5] considers an monadic model for FOP. The techniques presented in thi... |

3 |
Tagging monad transformer layers
- Piponi
- 2010
(Show Context)
Citation Context ...use it only allows to refer to layers below the current layer, but not layers above. The first problem is well-known in the Haskell community and there have been some proposals for solving it. Piponi =-=[7]-=- and Snyder & Alexander [8] suggested a solution by labeling monad transformers with (type-level) tags, allowing particular layers in a monad stack to be accessed by name rather than by position, elim... |

2 |
Monad factory: Type-indexed monads
- Snyder, Alexander
- 2010
(Show Context)
Citation Context ... to layers below the current layer, but not layers above. The first problem is well-known in the Haskell community and there have been some proposals for solving it. Piponi [7] and Snyder & Alexander =-=[8]-=- suggested a solution by labeling monad transformers with (type-level) tags, allowing particular layers in a monad stack to be accessed by name rather than by position, eliminating the pollution arisi... |

2 | The monad zipper
- Schrijvers, Oliveira
- 2010
(Show Context)
Citation Context ...nt state-of-the-art approaches to modular interpreters [3, 16, 17]. We describe a modular effectful interpreter case study, which uses the techniques presented in this paper, in a separate manuscript =-=[18]-=-. 8 Conclusion The current-state-of-the-art in monad stack management is too restrictive to effectively support reusable monadic components. The monad zipper provides the basic mechnanism to lift thes... |