[PEAK] Lucid: a trellis-like programming language
Phillip J. Eby
pje at telecommunity.com
Tue Oct 2 22:31:43 EDT 2007
Interesting stuff:
http://en.wikipedia.org/wiki/Lucid_(programming_language)
http://i.csc.uvic.ca/home/LucidPrimer/LPS.ise
In Lucid, an expression like "sqroot(avg(square(a)))" is actually a
function over an infinite data stream "a". This is essentially
isomorphic to a trellis.Component with an input cell and an output
value, in that as the input value changes, so does the output.
It makes me wonder if there should be a simple way to convert
functions over values into functions over cells in the Trellis. That
is, if you have a function like 'square()' that takes a value, it
should be possible to convert it into a function taking a cell, whose
output is a new cell.
Concretely, right now to do something like that, you have to write:
def square_cell(a_cell):
return trellis.Cell(lambda: a_cell.value ** 2)
versus, say, something like:
square_cell = trellis.cellfunc(lambda a: a**2)
which produces a dynamically-equivalent function to the first
function, so that square_cell(a_cell) still produces a function
taking a cell and returning a cell.
Interestingly, this idea is isomorphic to the idea of "lifting"
functions to monadic forms in Haskell. It makes me curious whether
the trellis itself can be viewed as a sort of monadic combinator
system. My work so far on the new trellis "co-ordinator" protocol
rather suggests that.
Lucid also has "temporal operators" that can be used to access
different versions of the values in a stream, and to do things like
filter streams. I'm reading a bit more about these to see how they
relate to the Trellis, if they do. Unfortunately, I don't think it's
likely that I'd be able to implement them within the same
pseudo-monadic system as the function idea above.
(But the main idea behind looking at this stuff, as always, is to see
whether anybody else has either solved problems I'm trying to solve,
to see whether they independently arrived at similar conclusions to
me, and whether anybody has found problems with the approach that I
myself have not yet run into.)
More information about the PEAK
mailing list