streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Consistency of groupsBy, rollingMap, incremental fold APIs

Open harendra-kumar opened this issue 3 years ago • 1 comments

Keeping the convention like List.groupsBy, rollingMap should also use the previous element as the first argument and the new element as second. Using the same convention we should use the old element as the first in the fold input tuple and new element as second.

harendra-kumar avatar Mar 28 '22 19:03 harendra-kumar

Data.List.groupBy uses the old element as the first one in comparison:

groupBy eq (x:xs)       =  (x:ys) : groupBy eq zs
                           where (ys,zs) = span (eq x) xs

RollingMapM (on master branch) also uses old element first and new next.

Streamly groupsBy uses the new element as first, see #563 .

Incremental folds in streamly (Fold.Window) use (new, old) tuple.

harendra-kumar avatar Apr 12 '22 05:04 harendra-kumar