i guess references mark bits of state that persist even if you invoke a continuation.
--
we gotta do something about foldl, foldr. having the user keep track of which one of these will lead to an error when they sum a bunch of numbers is like manual memory management.
http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl%27
http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29#Evaluation_order_considerations
http://en.wikibooks.org/wiki/Haskell/Performance_Introduction
ah, i think this is called "automatic strictness analysis".
--- the commments on this also suggest syntaxes etc for dealing with strictness:
http://pchiusano.blogspot.com/2009/06/perfect-strictness-analysis-part-2.html
--
--
mb something like garbage collection for the stack? keep track of which parts of the stack resulted from which parts of code. if the stack is close to overflowing, then find a loop, and try switching folds (or whatever is causing the recursion) between foldl, foldl', foldr, foldr'
--
is clojure doseq an example of this powerful macro thang that everyone talks about? the test is whether or not it needs to execute before its arguments are evaluated (to rearrange the symbols). i guess you have to the pattern matching at the symbolic level, so maybe so.
interesting, todo: think about that.
--
" The Conduit library is a second generation approach to the problem of guaranteeing bounded memory usage in the presence of lazy evaluation. The first generation of these ideas were libraries like Iteratee, Enumerator, and IterIO?. All of these first generation libraries use the the term enumerator for data producers and iteratee for data consumers. The new Conduit library calls data producers "sources" and data consumers "sinks" to make them a little more approachable.
The other big difference between Conduit and the early libraries in this space is to do with guaranteeing early clean up of potentially scarce resources like sockets. Although I have not looked in any detail at the IterIO?