### Should I use a Monad or a Comonad? Draft – Last updated June 16, 2012

"... The category theoretic structures of monads and comonads can be used as an abstraction mechanism for simplifying both language semantics and programs. Monads have been used to structure impure computations, whilst comonads have been used to structure context-dependent computations. Interestingly, th ..."

Abstract
- Add to MetaCart

(Show Context)
The category theoretic structures of monads and comonads can be used as an abstraction mechanism for simplifying both language semantics and programs. Monads have been used to structure impure computations, whilst comonads have been used to structure context-dependent computations. Interestingly, the class of computations structured by monads and the class of computations structured by comonads are not mutually exclusive. This paper formalises and explores the conditions under which a monad and a comonad can both structure the same notion of computation: when a comonad is left adjoint to a monad. Furthermore, we examine situations where a particular monad/comonad model of computation is deficient in capturing the essence of a computational pattern and provide a technique for calculating an alternative monad or comonad structure which fully captures the essence of the computation. Included is some discussion on how to choose between a monad or comonad structure in the case where either can be used to capture a particular notion of computation. 1

### An Intensional Investigation of Parallelism

, 1994

"... Denotational semantics is usually extensional in that it deals only with input/output properties of programs by making the meaning of a program a function. Intensional semantics maps a program into an algorithm, thus enabling one to reason about complexity, order of evaluation, degree of parallelism ..."

Abstract
- Add to MetaCart

Denotational semantics is usually extensional in that it deals only with input/output properties of programs by making the meaning of a program a function. Intensional semantics maps a program into an algorithm, thus enabling one to reason about complexity, order of evaluation, degree of parallelism, efficiency-improving program transformations, etc. I propose to develop intensional models for a number of parallel programming languages. The semantics will be implemented, resulting in a programming language of parallel algorithms, called CDSP. Applications of CDSP will be developed to determine its suitability for actual use. The thesis will hopefully make both theoretical and practical contributions: as a foundational study of parallelism by looking at the expressive power of various constructs, and with the design, implementation, and applications of an intensional parallel programming language. 1 Introduction Denotational semantics has now been around for about 25 years, which makes...

### Logical Methods in Computer Science

, 2012

"... Vol. 10(3:14)2014, pp. 1–48 www.lmcs-online.org ..."

(Show Context)
### Full abstraction for nominal exceptions

"... We examine the denotational semantics of a language extending the nu-calculus of Pitts and Stark by using names for exceptions and general references. In particular, we examine abstract categorical models capturing nominal computation and construct a concrete fully abstract model in game semantics b ..."

Abstract
- Add to MetaCart

(Show Context)
We examine the denotational semantics of a language extending the nu-calculus of Pitts and Stark by using names for exceptions and general references. In particular, we examine abstract categorical models capturing nominal computation and construct a concrete fully abstract model in game semantics by using the recently introduced generalisation to nominal games. 1.

### A Modal Calculus for Exception Handling Abstract

"... The exception monad, while an adequate mechanism for providing the denotational semantics of exceptions, is somewhat awkward to program with. Just as any other monad, it forces a programming style in which exceptional computations are explicitly sequentialized in the program text. In addition, value ..."

Abstract
- Add to MetaCart

(Show Context)
The exception monad, while an adequate mechanism for providing the denotational semantics of exceptions, is somewhat awkward to program with. Just as any other monad, it forces a programming style in which exceptional computations are explicitly sequentialized in the program text. In addition, values of computation types must usually be tested before use, in order to determine if they correspond to a raised exception. In this paper we propose a type system that rearranges the monadic formulation, so that the above shortcomings are avoided. Instead of the exception monad, we propose the operator � from the modal logic S4 to encode exceptional computation. The way tracking of exceptions is organized in the modal system is exactly dual to the monadic case, reflecting the well-known property that � is actually a comonad. Key words: monads, exceptions, modal logic. 1

### Chapter 5: Calculating Functional Programs

"... Functionalpctiona are merely equations; they may be manipjxxOB by straightforward equational reasoning. InpSUjSSB7jO one can use this style of reasoning to calculatepcnutiBS in the same way that one calculates numeric values in arithmetic. Many useful theorems for such reasoning derive from an alg ..."

Abstract
- Add to MetaCart

(Show Context)
Functionalpctiona are merely equations; they may be manipjxxOB by straightforward equational reasoning. InpSUjSSB7jO one can use this style of reasoning to calculatepcnutiBS in the same way that one calculates numeric values in arithmetic. Many useful theorems for such reasoning derive from an algebrai view ofp rograms, built around datatyp es and theirop erations. Traditional algebraic methods concentrate on initial algebras, constructors, and values; dual co-algebrai methods concentrate on final co-algebras, destructors, andp rocesses. Both methods are elegant andp owerful; they deserve to be combined. 1 Introduc45 These lecturen otes on algebraican coalgebraic methods forcalculatin funI tion--- programs derive from a series of lectures given at the Summer Schoolon Algebraic an Coalgebraic Methodsin the Mathematics of Program ConT# in Oxfordin April 2000. They are basedon an earlier series of lectures given at the Eston#` Win ter School on ComputerSciene in Palmse,EstonWR in 1999. 1.1 Why calculat programs? Over the past few decades there has been aphenIWk`B growthin the use of computers.Alonuter this growth, conFIB hasnW`R`F`W grown over the correctn ---5 of computer systems, for example as regards human safety,fin`FI`W security,an system developmen t budgets. Problemsin developin software an errorsin the finW product have serious con]]]WkB#R` such problems are the neW ratherthan the exception There is clearly an`: for more reliable methods of programconmWB5]5IW than the tradition: ad hoc methodsin use today. What isn]I---# is ascien e ofprogrammin--- inogra of today's craft (or perhaps black art). As JeremyGun warden poin ts out [15],computation isinR"B tly more mathematicalthan most enWBI---]]Wk artifacts;henac practisin software enR---5IRW should be at ...