Monads and Intensionality Bill Wadge Abstract Monads are a concept of category theory which can be used to structure functional pro- grams or even define nonstandard interpretations of the λ-calculus. These nonstandard func- tional languages share many of Lucid’s unusual features, such as the distinction between synchronic and general functions. In fact Lucid is exactly one of these languages, determined by a simple stream monad. We therefore propose that monadic functional programming is the appropriate meaning of “Intensional Programming”, with “Indexical Programming” reserved for languages in which intensions are indexed families of extensions. 1 An Unexpected Bounty Every year at ISLIP we have at least one soul-searching discussion on the topic “what is intensional programming?” Recently we added a new twist, an animated debate about “indexical” versus “intensional” programming. This new schism will undoubtedly cause even outsiders to be even more baffled than ever by the slippery notion of intensionality. At the same time, we often have an equally spirited but more accessible discussion of the old question “is Lucid a functional language?” Many functional programmers have argued that Lucid (and indexical languages in general) are not functional languages. One of the more convincing reasons was that indexical languages lacked higher-order functions. Fortunately, this defect has been remedied [4]. Nevertheless, even with higher-order functions Lucid is still very different from Miranda and Haskell. We have streams rather than lazy lists, and the streams are built into the language in a rather peculiar way. And of course Miranda and Haskell have nothing resembling GLU’s user- defined dimensions, or the notorious “freezing” of the original Lucid. For these reasons it is more usual to classify Lucid as a dataflow language, rather than as a functional language. Of course, even considered as a dataflow language, Lucid still appears idiosyncratic, but that is another story. This year I am pleased to report a new development which, I claim, gives a really good answer to all these questions. And the development is due entirely to our longtime rivals, functional programmers (especially Moggi and Wadler). They have (almost unwittingly) helped us solve some of our most perplexing issues and at the same time given Lucid a claim to far more mainstream respectability than we ever expected. At least that is the way I see the situation. They have discovered a whole family of nonstandard functional languages which share Lucid’s idiosyncracies. This new development, of course, is the discovery (by functional programmers, especially Wadler) of the significance of monads for programming languages. 2 Monads Monads are a concept well known in category theory, and the basic definition can be found in almost any text on the subject (they are sometimes called “triples” or “standard constructions”). I will try to avoid all but the most basic categorical notions and for the time being stay rather informal. Phil Wadler has written several excellent expositions of the subject, and I recommend * Presented to the 5th International Symposiunm on Lucid and Intensional Programming, Workshop of the IEEE International Conference on Computer Languages, San Franciso, California, USA, 20–23 April 1992. 1