Hasn't someone been working on a Clojure vesion of Parsec? On Sat, Mar 14, 2009 at 4:31 AM, Christophe Grand <christo...@cgrand.net>wrote:
> > Anatoly Yakovenko a écrit : > > basically i am dealing with a 3rd party library, (interactive brokers > > tws api), that takes an interface with lots of different methods that > > it calls when an event occurs. like received market data, received > > order, etc... It provides another interface that basically generates > > these events. > > > > Some of the events are statefull, like i canceled an order, i get a > > response that the order cancel was received, and then i get a > > confirmation that the order was canceled. > > > > If i was implementing this in haskell, (i am at the moment, but > > writing the bindings is a pain in the arse), i would pump all the > > events into a Chan, essentially a lazy evaluated sequence used to get > > stuff from IO, and write a parser on top of that. > > This first part is rather easy to port to Clojure, use a BlockingQueue > to buffer events received by the callback interface: > (def #^java.util.concurrent.BlockingQueue q > (java.util.concurrent.LinkedBlockingQueue.)) > and in your consumer thread, turn it into a sequence: > (def s (repeatedly #(.take q))) ; (EOS handling is left as an exercise) > > For the parser part, I'm afraid there's no such thing right now. Maybe > can you build upon Konrad's monads library? > > HTH Christophe > > > -- > Professional: http://cgrand.net/ (fr) > On Clojure: http://clj-me.blogspot.com/ (en) > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---