JosephCottam / AbstractRendering

Bin-based rendering...for the win!
Other
52 stars 6 forks source link

Transfer Combinators #48

Closed JosephCottam closed 11 years ago

JosephCottam commented 11 years ago

Transfer chains are powerful, they let you compactly express some really neat stuff. However, strictly linear flows are limiting. An expression composition language would be handy...

Things I can think of: Apply -- Perform the requested transfer Split -- Takes the result of the input function and applies EACH to the aggregates.
Map -- Apply a single function to a list of aggregates.
Join -- Apply a function to to combine several results.
If -- Predicate, true-action, false-action:
Lift -- Executes a function, but does not produce a set of aggregates. Can be used to compute control parameters or non-aggregate results (like ISO contours). AndLift -- Performs a transfer operation that results in aggregates and some other value (this is an optimization). WithLifted -- Takes a non-aggregate argument. Essentially an enhanced version of 'specialization'

Types: (F is function, A is Aggregates, T is 'some type', [..] is list of) Apply: F -> A -> A Split: [F] -> A -> [A] Map: F -> [A] -> [A] Join: F -> [A] -> [A] If: F -> F -> F -> A -> A Lift: F -> T -> T2 (Need to do the Lift1, Lift2, Lift3, etc to handle multiple args) AndLift: F -> A -> (A,T) WithLifted: F-> T -> [A] -> A (Need WithLiftedN to handle multiple T args)

This feels a lot like FRP or RDDs in Spark...

JosephCottam commented 11 years ago

Then: Compose left-to-right (F -> F -> T -> T)

JosephCottam commented 11 years ago

Iterate: Performs one function until another returns true (F->F->T->T)

JosephCottam commented 11 years ago

Basic set of aggregate-based combinators are now done.

I no longer see a point for 'map'. The basic unit is an aggregator, if you need something map-like, then 'fan' can be used...and if you really hate it then we can talk.

AndLift or WithLifted are ideas that require going beyond just plumbing the aggregate values around. They can be done on a case-by-case basis now. I'm not sure there is value in doing a general system at this time, so they are being skipped.

JosephCottam commented 10 years ago

Add a 'then' method to 'seq' to facilitate chaining!