CrossEye/ramda — pull request #257 by ndhoule (2014-08-18 03:28:13+00:00)
Title: Make foldl work on plain objects

Like a lot of other folks (especially those coming from Lodash/Underscore), I frequently find myself reaching for `foldl` when dealing with plain objects. Converting the object to an array before passing it to `foldl`-like functions is both verbose and has some significant disadvantages. Currently, most Ramda functions only work on arrays, but I'd like to change that, starting with `fold`-family functions.

I see this as more of a conversation starter than anything, since work to be done here before this PR is ready. I'm not satisfied with the current implementation of this for a few reasons:

- Currently, because `foldl` is decorated by `checkForMethod`, this wastefully checks whether or not the target is an array twice--once in the `checkForMethod` call, and again in the body of the function when checking which function to dispatch. I can conceive of a few ways to get around this, but not without fairly significant refactoring (e.g. I think the `checkForMethod` decoration pattern is a little inflexible as is; I'd pull the check back into each function body, and maybe refactor the dispatching code into a separate function `dispatchMethod`).
- I'd want to amend this PR before merge to include a patch to all fold-like functions (`foldl.idx`, `foldr`, etc.) to keep the assorted interfaces consistent.

A broader topic of conversation is to extend this kind of polymorphic functionality to functions other than `foldl` (e.g. `map` `any`, etc.)--many list-oriented functions are useful whether the input list is an array or an object.