Incremental trasnformations (not Haskell topic)

Hi, this is not a Haskell question but I'm not sure if anyone in java community can answer this. And I'm sure every Haskell programmer know OO programing. I'm programming one big boring db application and making a MDD tool to model and generate such applications. Many times object have computed attributes: E.g. value attribute of class Invoice is sum of values of all associated classes Item (Invoice 1 <>---> * Item) So value attribute of invoice is computed every time it is demanded. So far easy.Sometimes it is necessary not to compute it when it is needed but to have it precomputed (computed it every time, item is added/removed to invoice or item value is changed). Contract of attribute value is the same but it is not obvious from code if you program it in event-based as if you program it with expression which is computed every time. Event-based=no big picture. Expression=big picture but little performance. Question: Is there any way how to transform the OO transformation (invoice value is a sum of values of items) to incremental transformation (update invoice value, when item is created/deleted/changed)? Is there any product doing it. I am not interesting in product itself I want only see how it works? Is there any science paper on this? I call this not a function but a OO transformation because it can be much more complicated. I know it is not possible for all the functions (transformations), you have to do undo step, but it is possible for that what we use. One more complicated example: Provider provides money to receiver. It provides money with special code. Receiver sees all the money from all the providers grouped by the code and summed. Every summed group on the code has a subgroup summed on the provider. Provider A provides to R 10 on code "ABC" Provider A provides to Q 10 on code "ABC" Provider A provides to R 5 on code "ABC" Provider A provides to R 20 on code "DEF" Provider B provides to R 30 on code "ABC" Reciever R - recieves 45 on code "ABC", 15 from A, 30 from B - recieves 20 on code "DEF", 20 from A Reciever Q - recieves 10 on code "ABC", 10 from A This example can be easily programmed declarative way in Scala the way that everytime everything is computed. But have no clue if it can be transformed automatically to incremental way. Hope you understand what I mean. Thanks for your help and opinions Fero

Still nobody? Maybe I didn't write it clear. So one more time: I have a list of numbers (say Int) numberList = [1:Int,2,3,1,2,6,7,8] and a number sumOfNumberList = sum numberList and here comes the question. Imagine the list numberLists is mutable (that's why in topic is "not Haskell question") so the calculation doesn't occur only once but every time something changed in the list (listener pattern). (If the lis tis java List and Int is java Integer, every acces to list should trigger event to its listeners, but if I use list of another objects e.g. Item with value, every access to list should trigger event to its listeners as well as every modification of object Item should triggers its listeners (list) and that in turn triggers its listeners) How to make transformation of often used functions (map, sum, forall, filter, exists) to listeners in OO language? Is there anything (any tool, any paper, any blog...) about it? Thanks Fero PS If nobody answers I really stop asking non Haskell questions in this mailling list:)

See "Adaptive Functional Programming" by Acar et al.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.61.2257
Doesn't talk about OO specifically, but rather how to make "updatable"
computations in a mutable language.
There's a Haskell implementation, too.
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Adaptive
-- ryan
2008/12/28 frantisek kocun
Still nobody? Maybe I didn't write it clear. So one more time:
I have a list of numbers (say Int) numberList = [1:Int,2,3,1,2,6,7,8] and a number sumOfNumberList = sum numberList and here comes the question. Imagine the list numberLists is mutable (that's why in topic is "not Haskell question") so the calculation doesn't occur only once but every time something changed in the list (listener pattern). (If the lis tis java List and Int is java Integer, every acces to list should trigger event to its listeners, but if I use list of another objects e.g. Item with value, every access to list should trigger event to its listeners as well as every modification of object Item should triggers its listeners (list) and that in turn triggers its listeners) How to make transformation of often used functions (map, sum, forall, filter, exists) to listeners in OO language? Is there anything (any tool, any paper, any blog...) about it?
Thanks
Fero
PS If nobody answers I really stop asking non Haskell questions in this mailling list:)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks Ingram. It seems to be exactly what I was searching for:-) I knew I can rely on Haskellers.. This is from abstract ( http://ttic.uchicago.edu/~umut/papers/toplas06.pdf): "We present techniques for incremental computing by introducing adaptive functional programming. As an adaptive program executes, the underlying system represents the data and control dependences in the execution in the form of a dynamic dependence graph. When the input to the program changes, a change propagation algorithm updates the output and the dynamic dependence graph by propagating changes through the graph and re-executing code where necessary. Adaptive programs adapt their output to any change in the input, small or large."

On 2008 Dec 28, at 17:22, frantisek kocun wrote:
"We present techniques for incremental computing by introducing adaptive functional programming. As an adaptive program executes, the underlying system represents the data and control dependences in the execution in the form of a dynamic dependence graph. When the input to the program changes, a change propagation algorithm updates the output and the dynamic dependence graph by propagating changes through the graph and re-executing code where necessary. Adaptive programs adapt their output to any change in the input, small or large."
I find myself thinking this sounds like a reactive programming technique. Am I being obvious (or oblivious :) or is there something to look at here for reactive UIs? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

2008/12/28 Brandon S. Allbery KF8NH
On 2008 Dec 28, at 17:22, frantisek kocun wrote:
"We present techniques for incremental computing by introducing adaptive functional programming. As an adaptive program executes, the underlying system represents the data and control dependences in the execution in the form of a dynamic dependence graph. When the input to the program changes, a change propagation algorithm updates the output and the dynamic dependence graph by propagating changes through the graph and re-executing code where necessary. Adaptive programs adapt their output to any change in the input, small or large."
I find myself thinking this sounds like a reactive programming technique. Am I being obvious (or oblivious :) or is there something to look at here for reactive UIs?
Adaptive programming is sortof the opposite of reactive programming, the way I see it. Adaptive is *imperative* (that's the best word I have for it), i.e. you have a bunch of variables and your code decides which one to change. Whereas reactive programming, at the very heart (i.e. I would expect every reactive semantics to obey this), is declarative. That is, the way something behaves depends only on where it was defined, and not at all on how it is used. Luke

2008/12/28 Luke Palmer
Adaptive programming is sortof the opposite of reactive programming, the way I see it. Adaptive is imperative (that's the best word I have for it), i.e. you have a bunch of variables and your code decides which one to change. Whereas reactive programming, at the very heart (i.e. I would expect every reactive semantics to obey this), is declarative. That is, the way something behaves depends only on where it was defined, and not at all on how it is used.
I'm not sure I agree with this analysis; Reactive can be implemented on top of Adaptive, and vice versa. Yes, adaptive sort-of about mutation, but if you take a time step as "some input variables updated", you can easily see how a Reactive event stream implements an adaptive computation. Similarily, Conal's implementation of Reactive is mostly about how futures interact; it's easy to see how futures can be implemented as Adaptive objects on top of input sources showing the current time and the other inputs to the system. In fact I think if you look at Magnus Carlsson's Haskell Adaptive package, I think you'll find that there isn't really much mention of mutation at all, except at the point of "update the inputs and tell me what output I get". This is much the same as Reactive where some underlying system is updating the inputs (mouse position, keyboard events, etc.) and giving you the new output. -- ryan

On Mon, 2008-12-29 at 01:20 -0500, Brandon S. Allbery KF8NH wrote:
On 2008 Dec 28, at 17:22, frantisek kocun wrote:
"We present techniques for incremental computing by introducing adaptive functional programming. As an adaptive program executes, the underlying system represents the data and control dependences in the execution in the form of a dynamic dependence graph. When the input to the program changes, a change propagation algorithm updates the output and the dynamic dependence graph by propagating changes through the graph and re-executing code where necessary. Adaptive programs adapt their output to any change in the input, small or large."
I find myself thinking this sounds like a reactive programming technique. Am I being obvious (or oblivious :) or is there something to look at here for reactive UIs?
I believe FrTime and possibly Kenny Tilton's Cells use an approach similar to this. This approach is rather different than most of the FRP implementations in Haskell.
participants (5)
-
Brandon S. Allbery KF8NH
-
Derek Elkins
-
frantisek kocun
-
Luke Palmer
-
Ryan Ingram