[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN]: new Lua-based list comprehension and parsing libraries
- From: "David Manura" <dm.lua@...>
- Date: Thu, 11 Sep 2008 01:04:40 -0400
On Wed, Sep 10, 2008 at 12:38 PM, Greg Fitzgerald wrote:
> Have you given any thought to implementing the generalized list
> comprehensions proposed by SPJ and Wadler?
That paper is really interesting. I had thought of some basic
extensions along "list comprehensions <-> set builder <-> SQL <->
map/grep" analogies but wasn't certain what form they would take.
This provides some clear directions to take this to the next level,
and the related work in Microsoft LINQ shows a practical
implementation along some of these lines.
Some code snippets have been added to the "Possible extensions"
section of that wiki page to show what the generated Lua function code
corresponding to the "zip" and "group by" extensions to list
comprehensions might look like. These correspond to, using a
Haskell-like notation in the paper,
[ (x,y,z,w) | (x <- xs | y <- ys), (z <- zs | w <- ws) ]
[ the x.name, sum x.deposit | x <- transactions, group by x.name ] .
The implementations are a bit different from the "translations" in the
paper as they make efficient use of Lua for/if/while/tables constructs
rather than functional map/grep/zip.
I'll probably move on to other things, but I think there's a lot of
potential for work in this direction.