On May 7, 2009, at 4:15 PM, Jarkko Oranen wrote: > Also, how is a lazy sequence of mouse events supposed to work? does it > block? What happens when there is no mouse event? does the sequence > just end? What if you happen to take the last event, and then the > sequence ends, after which another event comes in? for wouldn't know > what to do in the general case.
I think a facility like this is part of the underpinning of functional reactive programming (FRP), which is an active research area in designing interactive systems such as GUIs functionally rather than object orientedly (if that's a word). Consider a trivial demo where you want to continuously update the mouse's coordinates in a text box on a window. You could just map a function which updates that text box across the potentially infinite list of mouse events. Yes, it would block until the next event came in, but the UI is in a consistent state while the mouse isn't moving. One has to assume that sequences of events are potentially infinite. Haskell is pretty good at the infinite list part, but it's pretty bad at the side-effect part and timing part. I tried pretty hard to read Conal Eliot's paper "Simply Efficient FRP" <http://conal.net/papers/simply-reactive/ > but I never got far enough in Haskell to actually understand what it's saying. It looks like something hard to do in Haskell. It's also been done in Scheme, specifically the FrTime "language" in DrScheme. There's a paper about it here: <http://citeseer.ist.psu.edu/cache/papers/cs/32750/ftp:zSzzSzftp.cs.brown.eduzSzpubzSztechreportszSz03zSzcs03-20.pdf/cooper04frtime.pdf > which I haven't even tried to read. There's also an interesting Javascript implementation called Flapjax, which was pretty under-documented when I heard about it, but makes it a little easier to get the gist of the idea: <http://www.flapjax-lang.org/ > From what little I have gathered about the concept, Clojure ought to be in a unique position to leverage it, since Clojure has ready access to both GUI frameworks and lazy sequences from within an easy-to- reason-about strict language. Much of the work in Haskell FRP must be to cope with state and time, whereas in other languages it must be to introduce the right kinds of laziness and parallelism. Clojure has a good mixture of these ingredients already. There could be extremely novel ways of approaching well-known problems hiding within Clojure right now. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---