Haskell equations, thirty-eight years later
One night, while drifting off to sleep, I solved a conundrum that puzzled me since 1987.
Before Haskell there was Orwell. In Orwell equations were checked to ensure order is unimportant. When an equation was to match only if no previous equation applied, it had to be preceded by ELSE. Thus, equality on lists would be defined as follows:
(==) :: Eq a => [a] -> [a] -> Bool
[] == [] = True
(x:xs) == (y:ys) = x == y && xs == ys
ELSE
_ = _ = False
The designers pondered whether to include this restriction in Haskell. Further, they wondered whether Haskell should insist that order is unimportant in a sequence of conditionals, unless *ELSE* was included. Thus, equality on an abstract type Shape would be defined as follows:
(==) :: Shape -> Shape -> Bool
x == y | circle x && circle y = radius x == radius y
| square x && square y = side x == side y
ELSE
| otherwise = False
This design was not pursued in Haskell for two reasons. First, because it might be too unfamiliar. Second, because it was syntactically awkward.
Today, the first problem is perhaps no longer quite so strong an issue. Many applications using Haskell would welcome the extra assurance from flagging any cases where order of the equations is significant. But the syntactic awkwardness of ELSE remains considerable. It was syntax about which I had an insight while tossing in bed.
The talk will present my proposed new syntax and sketch a suitable extension to Haskell.
Philip Wadler is Professor of Theoretical Computer Science at the University of Edinburgh and Senior Research Fellow at IOHK. He is a Fellow of the Royal Society, a Fellow of the Royal Society of Edinburgh, and an ACM Fellow. He is head of the steering committee for Proceedings of the ACM, past editor-in-chief of PACMPL and JFP, past chair of ACM SIGPLAN, past holder of a Royal Society-Wolfson Research Merit Fellowship, winner of the SIGPLAN Distinguished Service Award, and a winner of the POPL Most Influential Paper Award. Previously, he worked or studied at Stanford, Xerox Parc, CMU, Oxford, Chalmers, Glasgow, Bell Labs, and Avaya Labs, and visited as a guest professor in Copenhagen, Sydney, and Paris. He has an h-index of over 70 with more than 25,000 citations to his work, according to Google Scholar. He contributed to the designs of Haskell, Java, and XQuery, and is co-author of Introduction to Functional Programming (Prentice Hall, 1988), XQuery from the Experts (Addison Wesley, 2004), Generics and Collections in Java (O’Reilly, 2006), and Programming Language Foundations in Agda (2018). He has delivered invited talks in locations ranging from Aizu to Zurich.
Fri 17 OctDisplayed time zone: Perth change
10:30 - 12:15 | |||
10:30 30mResearch paper | Rebound: Efficient, expressive, and well-scoped binding Haskell Link to publication DOI Pre-print | ||
11:00 30mResearch paper | Total Type Classes Haskell | ||
11:30 20mTalk | Four Years of Embedded Haskell in Critical Real-Time Systems: Lessons and Insights Haskell | ||
11:50 20mTalk | Haskell equations, thirty-eight years later Haskell Philip Wadler IOG; University of Edinburgh | ||
