[Forwarded to this list with Phil Wadler's permission.]
Greg Wilson wrote: Hi, Phil. I was talking to a couple of colleagues over the weekend, one of whom learned Miranda as his second language and never really recovered :-). I was wondering: if you could add one or two features of Haskell to Python, what would you choose? And why?
Philip Wadler email@example.com wrote:
Well, what I most want is typing. But you already know that.
Next after typing? Full lexical scoping for closures. I want to write:
fun x: fun y: x+y
fun x: fun y, x=x: x+y
Lexically scoped closures would be a big help for the embedding technique I described [GVW: in a posting to the Software Carpentry discussion list, archived at
which discussed how to build a flexible 'make' alternative in Python].
Next after closures? Disjoint sums. E.g.,
fun area(shape) : switch shape: case Circle(r): return pi*r*r case Rectangle(h,w): return h*w
(I'm making up a Python-like syntax.) This is an alternative to the OO approach. With the OO approach, it is hard to add area, unless you modify the Circle and Rectangle class definitions. On the other hand, with disjoint sums it is hard to add a new shape, unless you modify all the existing switch statements for shapes. This is a well-known tradeoff, see e.g., the discussion in my paper with Odersky on Pizza, or the ECOOP 98 paper by Felleisen and Krishnamurthi.
[GVW: the Pizza paper is available from:
The Felleisen and Krishnamurthi paper is at: