streamly
streamly copied to clipboard
Consistency of groupsBy, rollingMap, incremental fold APIs
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.
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.