Closed tomprince closed 9 years ago
to @radix, for future reference: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.2961
foldl
is just python's reduce
; foldM
is just the case where the reducing function has side-effects. I think sequence can be expressed in terms of foldM
sequence = foldM (\x y -> return (x ++ [y])) []
but I don't think that that is simpler.
@tomprince
Could you check out #51 and #52?
I think this is a nicer formulation. Basically I just split up the "folding over effects" part of your PR from the "accumulating into a list" part. The error-handling is generalized to all folds, such that it raises a FoldError with the accumulator-so-far (not necessarily a list) and the original exception. I've also kept the optimization of appending to a list instead of concatenating lists.
I also dropped the intent. I can't think of a good reason to have an intent for it because tests would still just need to assert that each effect is performed in turn (usually with SequenceDispatcher
).
closing since #52 was merged. Thanks for the contribution.
Hey Tom, glad to see you're still interested in Effect :)
I can see how this offers something beyond manually chaining effects -- managing the list of results is pretty tedious in Python, but I have two questions: