A History of Haskell: Being Lazy with Class April 16, 2007
Total Page:16
File Type:pdf, Size:1020Kb
A History of Haskell: Being Lazy With Class April 16, 2007 Paul Hudak John Hughes Simon Peyton Jones Yale University Chalmers University Microsoft Research [email protected] [email protected] [email protected] Philip Wadler University of Edinburgh [email protected] Abstract lution that are distinctive in themselves, or that developed in un- expected or surprising ways. We reflect on five areas: syntax (Sec- This paper describes the history of Haskell, including its genesis tion 4); algebraic data types (Section 5); the type system, and type and principles, technical contributions, implementations and tools, classes in particular (Section 6); monads and input/output (Sec- and applications and impact. tion 7); and support for programming in the large, such as modules and packages, and the foreign-function interface (Section 8). 1. Introduction Part III describes implementations and tools: what has been built In September of 1987 a meeting was held at the confer- for the users of Haskell. We describe the various implementations ence on Functional Programming Languages and Computer of Haskell, including GHC, hbc, hugs, nhc, and Yale Haskell (Sec- Architecture in Portland, Oregon, to discuss an unfortunate tion 9), and tools for profiling and debugging (Section 10). situation in the functional programming community: there had come into being more than a dozen non-strict, purely Part IV describes applications and impact: what has been built by functional programming languages, all similar in expressive the users of Haskell. The language has been used for a bewildering power and semantic underpinnings. There was a strong con- variety of applications, and in Section 11 we reflect on the distinc- sensus at this meeting that more widespread use of this class tive aspects of some of these applications, so far as we can dis- of functional languages was being hampered by the lack of cern them. We conclude with a section that assesses the impact of a common language. It was decided that a committee should Haskell on various communities of users, such as education, open- be formed to design such a language, providing faster com- source, companies, and other language designers (Section 12). munication of new ideas, a stable foundation for real ap- Our goal throughout is to tell the story, including who was involved plications development, and a vehicle through which others and what inspired them: the paper is supposed to be a history rather would be encouraged to use functional languages. than a technical description or a tutorial. These opening words in the Preface of the first Haskell Report, We have tried to describe the evolution of Haskell in an even- Version 1.0 dated 1 April 1990, say quite a bit about the history of handed way, but we have also sought to convey some of the ex- Haskell. They establish the motivation for designing Haskell (the citement and enthusiasm of the process by including anecdotes and need for a common language), the nature of the language to be personal reflections. Inevitably, this desire for vividness means that designed (non-strict, purely functional), and the process by which our account will be skewed towards the meetings and conversations it was to be designed (by committee). in which we personally participated. However, we are conscious Part I of this paper describes genesis and principles: how Haskell that many, many people have contributed to Haskell. The size and came to be. We describe the developments leading up to Haskell quality of the Haskell community, its breadth and its depth, are both and its early history (Section 2) and the processes and principles the indicator of Haskell’s success and its cause. that guided its evolution (Section 3). One inevitable shortcoming is a lack of comprehensiveness. Haskell Part II describes Haskell’s technical contributions: what Haskell is. is now more than 15 years old and has been a seedbed for an im- We pay particular attention to aspects of the language and its evo- mense amount of creative energy. We cannot hope to do justice to all of it here, but we take this opportunity to salute all those who have contributed to what has turned out to be a wild ride. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Third ACM SIGPLAN History of Programming Languages Conference (HOPL-III) San Diego, CA Copyright c 2007 ACM . $5.00 Part I Lisp, and showed soundness of their evaluator with respect to a denotational semantics. • David Turner (at St. Andrews and Kent) introduced a series Genesis and Principles of influential languages: SASL (St Andrews Static Language) (Turner, 1976), which was initially designed as a strict lan- guage in 1972 but became lazy in 1976, and KRC (Kent Re- 2. The genesis of Haskell cursive Calculator) (Turner, 1982). Turner showed the elegance In 1978 John Backus delivered his Turing Award lecture, “Can pro- of programming with lazy evaluation, and in particular the use gramming be liberated from the von Neumann style?” (Backus, of lazy lists to emulate many kinds of behaviours (Turner, 1981; 1978a), which positioned functional programming as a radical at- Turner, 1982). SASL was even used at Burroughs to develop an tack on the whole programming enterprise, from hardware archi- entire operating system—almost certainly the first exercise of tecture upwards. This prominent endorsement from a giant in the pure, lazy, functional programming “in the large”. field—Backus led the team that developed Fortran, and invented At the same time, there was a symbiotic effort on exciting new ways Backus Naur Form (BNF)—put functional programming on the to implement lazy languages. In particular: map in a new way, as a practical programming tool rather than a mathematical curiosity. • In software, a variety of techniques based on graph reduction were being explored, and in particular Turner’s inspirationally Even at that stage, functional programming languages had a long elegant use of SK combinators (Turner, 1979b; Turner, 1979a). history, beginning with John McCarthy’s invention of Lisp in the (Turner’s work was based on Haskell Curry’s combinatory cal- late 1950s (McCarthy, 1960). In the 1960s, Peter Landin and culus (Curry and Feys, 1958), a variable-less version of Alonzo Christopher Strachey identified the fundamental importance of the Church’s lambda calculus (Church, 1941).) lambda calculus for modelling programming languages and laid the foundations of both operational semantics, through abstract • Another potent ingredient was the possibility that all this would machines (Landin, 1964), and denotational semantics (Strachey, lead to a radically different non-von Neumann hardware archi- 1964). A few years later Strachey’s collaboration with Dana Scott tectures. Several serious projects were underway (or were get- put denotational semantics on firm mathematical foundations un- ting underway) to build dataflow and graph reduction machines derpinned by Scott’s domain theory (Scott and Strachey, 1971; of various sorts, including the Id project at MIT (Arvind and Scott, 1976). In the early ’70s, Rod Burstall and John Darling- Nikhil, 1987), the Rediflow project at Utah (Keller et al., 1979), ton were doing program transformation in a first-order functional the SK combinator machine SKIM at Cambridge (Stoye et al., language with function definition by pattern matching (Burstall 1984), the Manchester dataflow machine (Watson and Gurd, and Darlington, 1977). Over the same period David Turner, a for- 1982), the ALICE parallel reduction machine at Imperial (Dar- mer student of Strachey, developed SASL (Turner, 1976), a pure lington and Reeve, 1981), the Burroughs NORMA combinator higher-order functional language with lexically scoped variables— machine (Scheevel, 1986), and the DDM dataflow machine at a sugared lambda calculus derived from the applicative subset of Utah (Davis, 1977). Much (but not all) of this architecturally Landin’s ISWIM (Landin, 1966)—that incorporated Burstall and oriented work turned out to be a dead end, when it was later dis- Darlington’s ideas on pattern matching into an executable program- covered that good compilers for stock architecture could outper- ming language. form specialised architecture. But at the time it was all radical and exciting. In the late ’70s, Gerry Sussman and Guy Steele developed Scheme, a dialect of Lisp that adhered more closely to the lambda calcu- Several significant meetings took place in the early ’80s that lent lus by implementing lexical scoping (Sussman and Steele, 1975; additional impetus to the field. Steele, 1978). At more or less the same time, Robin Milner in- In August 1980, the first Lisp conference took place in Stanford, vented ML as a meta-language for the theorem prover LCF at Ed- California. Presentations included Rod Burstall, Dave MacQueen, inburgh (Gordon et al., 1979). Milner’s polymorphic type system and Don Sannella on Hope, the language that introduced algebraic for ML would prove to be particularly influential (Milner, 1978; data types (Burstall et al., 1980). Damas and Milner, 1982). Both Scheme and ML were strict (call- by-value) languages and, although they contained imperative fea- In July 1981, Peter Henderson, John Darlington, and David Turner tures, they did much to promote the functional programming style ran an Advanced Course on Functional Programming and its Appli- and in particular the use of higher-order functions. cations, in Newcastle (Darlington et al., 1982). All the big names were there: attendees included Gerry Sussman, Gary Lindstrom, 2.1 The call of laziness David Park, Manfred Broy, Joe Stoy, and Edsger Dijkstra.