## Semantics of value recursion for monadic input/output (2002)

Venue: | Journal of Theoretical Informatics and Applications |

Citations: | 7 - 1 self |

### BibTeX

@ARTICLE{Erkök02semanticsof,

author = {Levent Erkök and John Launchbury and Andrew Moran},

title = {Semantics of value recursion for monadic input/output},

journal = {Journal of Theoretical Informatics and Applications},

year = {2002},

volume = {36},

pages = {200--2}

}

### OpenURL

### Abstract

Abstract. Monads have been employed in programming languages for modeling various language features, most importantly those that involve side effects. In particular, Haskell’s IO monad provides access to I/O operations and mutable variables, without compromising referential transparency. Cyclic definitions that involve monadic computations give rise to the concept of value-recursion, where the fixed-point computation takes place only over the values, without repeating or losing effects. In this paper, we describe a semantics for a lazy language based on Haskell, supporting monadic I/O, mutable variables, usual recursive definitions, and value recursion. Our semantics is composed of two layers: A natural semantics for the functional layer, and a labeled transition semantics for the IO layer. Mathematics Subject Classification. 68N18, 68Q55, 18C15.

### Citations

1354 | Introduction to Functional Programming - Bird, Wadler - 1988 |

766 | Notions of computation and monads
- Moggi
- 1991
(Show Context)
Citation Context ...tment of fixed-point operators can be found in Simpson and Plotkin’s recent work [32]. On a parallel thread, Moggi introduced monads to computer science as a way of structuring denotational semantics =-=[23]-=-. Use of monads influenced functional programming community deeply, resulting in a surge of practical applications. MostsSEMANTICS OF VALUE RECURSION FOR MONADIC INPUT/OUTPUT 157 importantly, Haskell’... |

604 |
Communicating and Mobile Systems: the π-calculus
- Milner
- 1999
(Show Context)
Citation Context ...ied by Gordon [9]. In such a system, an IO computation is viewed as a sequence of labeled transitions. Each label indicates an effect observable in the real world, similar to those in process calculi =-=[22]-=-. Peyton Jones’s work used an embedding of a denotational semantics for the functional layer into the IO layer. However, it did not capture sharing implied by lazy evaluation, the precise interaction ... |

269 | The revised report on the syntactic theories of sequential control and state
- Felleisen, Hieb
- 1989
(Show Context)
Citation Context ... of our rules, we see that only the second has a chance of matching a rule, namely GETC. Since the GETC rule requires the input stream 5 Other authors use the term evaluation context for this concept =-=[8]-=-. We prefer the term execution, since a non-empty context can only be filled by an IO action which is going to be executed next.s164 L. ERKÖK, J. LAUNCHBURY AND A. MORAN E[putChar c ] (c : I) : E[getC... |

198 | A natural semantics for lazy evaluation
- Launchbury
- 1993
(Show Context)
Citation Context ...ctional. The semantics for the IO layer is based on the approach taken by Peyton Jones [26]. The semantics for the functional layer is based on the natural semantics for lazy evaluation of Launchbury =-=[16]-=-. A final set of rules precisely shows how these two layers interact with each other. It is this interaction that allows us to give a semantics for fixIO. The remainder of this paper is structured as ... |

176 | Generalising monads to arrows
- Hughes
(Show Context)
Citation Context ... but he worked with a notion of partial traces, limiting recursion only to a certain class of maps [13]. More recently, Paterson [25] considered value recursion for arrows, a generalization of monads =-=[12]-=-. The adaptation of trace axioms, however, turned out to be too strong for various arrows. More specifically, certain arrows failed to satisfy the right tightening law required by trace axioms. Indeed... |

169 |
Traced monoidal categories
- Joyal, Street, et al.
- 1996
(Show Context)
Citation Context ...ed-points of continuous functions. In the implementations of programming languages, recursion is generally achieved via cyclic structures [2, 10]. Traced monoidal categories, proposed by Joyal et al. =-=[15]-=-, provide a framework for abstractly capturing such feedback operations. As shown in Hasegawa’s thesis [11], every traced cartesian category admits a Conway fixed-point operator [32], and vice versa, ... |

124 | Lava: Hardware design in haskell
- Bjesse, Claessen, et al.
- 1998
(Show Context)
Citation Context ...r application domain, however, surfaced the need for a different notion of recursion in monadic computations: Hardware design languages, such as Hawk and Lava, employ monads to model circuit elements =-=[4,21]-=-. An important shortcoming of the monadic approach is the difficulty in modeling feedback loops in circuits, a fundamental circuit design principle. Launchbury et al. [17] noticed that a new kind of f... |

112 | Equivalence in functional languages with effects
- Mason, Talcott
- 1991
(Show Context)
Citation Context ...the current definition of ≡ given in Figure 4 is simply too crude to be useful for this purpose. Intuitively, we want to be able to identify program states if their “observable behavior” are the same =-=[9,20,29]-=-. We defer a formal development of this possibility to future work. 4.5. Meaning of program states The meaning of a closed program state is its derivation: Definition 4.10. (Derivations) Let I : Γ : P... |

108 |
Functional programming and input/output
- Gordon
- 1994
(Show Context)
Citation Context ...mputations in the IO monad. Recent work by Peyton Jones introduced a semantics based on observable transitions [26], in the spirit of monadic transition systems that were previously studied by Gordon =-=[9]-=-. In such a system, an IO computation is viewed as a sequence of labeled transitions. Each label indicates an effect observable in the real world, similar to those in process calculi [22]. Peyton Jone... |

103 | Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign- language calls
- Jones
- 2001
(Show Context)
Citation Context ...e need to understand the operation of fixIO. First of all, we need a semantics for the computations in the IO monad. Recent work by Peyton Jones introduced a semantics based on observable transitions =-=[26]-=-, in the spirit of monadic transition systems that were previously studied by Gordon [9]. In such a system, an IO computation is viewed as a sequence of labeled transitions. Each label indicates an ef... |

103 | Premonoidal categories and notions of computation
- Power, Robinson
- 1997
(Show Context)
Citation Context ... trace operator on the corresponding Kleisli category. Unfortunately, the monoidal requirement is too strong: unless the underlying monad is commutative, the Kleisli category will only be premonoidal =-=[30]-=-, and hence the notion of trace is simply not applicable. Hasegawa noted that the extension of traces to premonoidal categories might prove interesting [11] (Chap. 9). Jeffrey followed upon this idea,... |

77 | Parametric polymorphism and operational equivalence
- Pitts
- 2000
(Show Context)
Citation Context ...the current definition of ≡ given in Figure 4 is simply too crude to be useful for this purpose. Intuitively, we want to be able to identify program states if their “observable behavior” are the same =-=[9,20,29]-=-. We defer a formal development of this possibility to future work. 4.5. Meaning of program states The meaning of a closed program state is its derivation: Definition 4.10. (Derivations) Let I : Γ : P... |

73 | Deriving a lazy abstract machine
- Sestoft
- 1994
(Show Context)
Citation Context ...r, as such systems are rather well studied in the literature. The interested reader is referred to Launchbury’s original exposition [16], and Sestoft’s work on abstract machines based on such systems =-=[31]-=-. 4.3. The marriage Given separate semantics for the IO and functional layers, we need to specify exactly how they interact. There are two different kinds of interaction. First, whenever we try to red... |

64 |
Wadler (editors). Report on the programming language Haskell – a non-strict purely functional language, version 1.2
- Hudak, Jones, et al.
- 1992
(Show Context)
Citation Context ...tion Ever since Peyton Jones and Wadler showed how monads can be used to model I/O in a language with non-strict semantics, monadic I/O became the standard way of dealing with input/output in Haskell =-=[27,28]-=-. Together with the IO monad, a rather mysterious function called fixIO, with type ∀τ.(τ → IO τ) → IO τ, was also introduced. As Achten and Peyton Jones point out, fixIO “...allows us to manipulate re... |

63 | Models of Sharing Graphs: A Categorical Semantics of let and letrec
- Hasegawa
- 1997
(Show Context)
Citation Context ...achieved via cyclic structures [2, 10]. Traced monoidal categories, proposed by Joyal et al. [15], provide a framework for abstractly capturing such feedback operations. As shown in Hasegawa’s thesis =-=[11]-=-, every traced cartesian category admits a Conway fixed-point operator [32], and vice versa, satisfactorily explaining recursion resulting from cyclic sharing. A particularly nice summary of the categ... |

54 | Asynchronous exceptions in Haskell
- Marlow, Jones, et al.
- 2006
(Show Context)
Citation Context ...d synchronized variables as in Peyton Jones’s work [26]. This extension does not present any technical challenges. The difficulty, however, lies in extending the approach with asynchronous exceptions =-=[19]-=-. Although exceptions can be modeled nicely in the IO layer, we currently do not see a complementary way of capturing them in the functional layer using our method. Developing proof techniques for est... |

52 | A new notation for arrows
- Paterson
- 2001
(Show Context)
Citation Context ...ight prove interesting [11] (Chap. 9). Jeffrey followed upon this idea, but he worked with a notion of partial traces, limiting recursion only to a certain class of maps [13]. More recently, Paterson =-=[25]-=- considered value recursion for arrows, a generalization of monads [12]. The adaptation of trace axioms, however, turned out to be too strong for various arrows. More specifically, certain arrows fail... |

51 | Typing Haskell in Haskell
- Jones
- 1999
(Show Context)
Citation Context ...gnore the issues of type checking and inference. We assume that the usual Haskell rules apply to determine well typed terms. (Typing of Haskell programs has been discussed in detail in the literature =-=[14,27]-=-.) Notice that return, ≫=, fixIO, etc., are polymorphic constants. As usual, let expressions provide recursive (and possibly polymorphic) bindings. A constructor c of arity i is treated as a function ... |

45 | Recursion from cyclic sharing: traced monoidal categories and models of cyclic lambda-calculi
- Hasegawa
- 1997
(Show Context)
Citation Context ...omain theoretic treatment of recursion relies on the least fixed-points of continuous functions. In the implementations of programming languages, recursion is generally achieved via cyclic structures =-=[2, 10]-=-. Traced monoidal categories, proposed by Joyal et al. [15], provide a framework for abstractly capturing such feedback operations. As shown in Hasegawa’s thesis [11], every traced cartesian category ... |

43 | Recursive monadic bindings - Erkök, Launchbury - 2000 |

38 | Cyclic lambda calculi
- Ariola, Blom
- 1997
(Show Context)
Citation Context ...omain theoretic treatment of recursion relies on the least fixed-points of continuous functions. In the implementations of programming languages, recursion is generally achieved via cyclic structures =-=[2, 10]-=-. Traced monoidal categories, proposed by Joyal et al. [15], provide a framework for abstractly capturing such feedback operations. As shown in Hasegawa’s thesis [11], every traced cartesian category ... |

38 | On embedding a microarchitectural design language within Haskell
- Launchbury, Lewis, et al.
- 1999
(Show Context)
Citation Context ... to model circuit elements [4,21]. An important shortcoming of the monadic approach is the difficulty in modeling feedback loops in circuits, a fundamental circuit design principle. Launchbury et al. =-=[17]-=- noticed that a new kind of fixed-point operator is needed, one that would neither repeat nor lose the effects, but perform recursion only over the values. Later work coined the name value recursion f... |

34 | Microprocessor specification in hawk
- Matthews, Cook, et al.
- 1998
(Show Context)
Citation Context ...r application domain, however, surfaced the need for a different notion of recursion in monadic computations: Hardware design languages, such as Hawk and Lava, employ monads to model circuit elements =-=[4,21]-=-. An important shortcoming of the monadic approach is the difficulty in modeling feedback loops in circuits, a fundamental circuit design principle. Launchbury et al. [17] noticed that a new kind of f... |

31 | Complete axioms for categorical fixed-point operators
- Simpson, Plotkin
- 1998
(Show Context)
Citation Context ...d by Joyal et al. [15], provide a framework for abstractly capturing such feedback operations. As shown in Hasegawa’s thesis [11], every traced cartesian category admits a Conway fixed-point operator =-=[32]-=-, and vice versa, satisfactorily explaining recursion resulting from cyclic sharing. A particularly nice summary of the categorical treatment of fixed-point operators can be found in Simpson and Plotk... |

29 |
Reactive Objects and Functional Programming
- Nordlander
- 1999
(Show Context)
Citation Context ...ists, where each node holds a mutable boolean value [6]. As shown by Nordlander, a similar situation arises in object oriented programming, when several objects need to refer to each other cyclically =-=[24]-=-. 4 Note that, by applying the left shrinking and purity laws of the previous section, we can reduce this expression to getChar ≫= λc. return (fix (λcs. c:cs)), guaranteeing the described behavior axi... |

21 | Porting the Clean Object I/O Library to Haskell
- Achten, Jones, et al.
- 2001
(Show Context)
Citation Context ...h type ∀τ.(τ → IO τ) → IO τ, was also introduced. As Achten and Peyton Jones point out, fixIO “...allows us to manipulate results [of IO computations] that are not yet computed, but lazily available” =-=[1]-=- (Sect. 4.1). In this regard, the functionality provided by fixIO is similar to that of fixST associated with the state monad [18]. Both fixIO and fixST provide fixed-point operators that enable recur... |

21 |
Premonoidal categories and a graphical view of programs. unpublished
- Jeffrey
- 1998
(Show Context)
Citation Context ...es to premonoidal categories might prove interesting [11] (Chap. 9). Jeffrey followed upon this idea, but he worked with a notion of partial traces, limiting recursion only to a certain class of maps =-=[13]-=-. More recently, Paterson [25] considered value recursion for arrows, a generalization of monads [12]. The adaptation of trace axioms, however, turned out to be too strong for various arrows. More spe... |

12 | Value recursion in monadic computations
- Erkök
- 2002
(Show Context)
Citation Context ...new kind of fixed-point operator is needed, one that would neither repeat nor lose the effects, but perform recursion only over the values. Later work coined the name value recursion for this concept =-=[5, 6]-=-. What is the right framework for modeling value recursion? Recalling the correspondence between usual fixed-point operators and traced monoidal categories, it is natural to ask whether we can build a... |

6 | Semantics of fixIO
- Erkök, Launchbury, et al.
- 2001
(Show Context)
Citation Context ...nable recursion resulting from the values of monadic actions. Later work tried to explain the behavior of such fixed-point ∗ This is a revised and extended version of a paper that appeared in FICS’01 =-=[7]-=-. 1 OGI School of Science and Engineering, OHSU; e-mail: erkok@cse.ogi.edu 2 Galois Connections, Inc. c○ EDP Sciences 2002s156 L. ERKÖK, J. LAUNCHBURY AND A. MORAN operators from an axiomatic point of... |

4 |
Traced premonoidal categories (Extended Abstract
- BENTON, HYLAND
- 2002
(Show Context)
Citation Context ...served to be too strong in our earlier work as well (where it was called rightshrinking) [6]. Independently of Paterson, Benton and Hyland tried to generalize traces to premonoidal categories as well =-=[3]-=-. They also attempted to generalize the notion of fixed-point operators to Freyd categories, trying to establish a correspondence with the traced premonoidal case. However, their axiomatization fails ... |