Closed chshersh closed 6 years ago
Done in PR #106.
Wow, this is actually an API-breaking change which was done via incrementing patch version instead of major version (!). Why would you ever do that?
Also, it's super weird when foldl
and foldl'
have different type signatures, it's completely counter-intuitive.
(Got frustrated recently after a failed attempt to build several packages from cardano-sl-*
family with new Universum)
@flyingleafe version change was already discussed.
it's super weird when foldl and foldl'
You shouldn't use foldl
anyways. And universum
shouldn't export foldl
if it does this now. So it doesn't matter at the end.
(Got frustrated recently after a failed attempt to build several packages from cardano-sl-* family with new Universum)
You just need to wait for this PR to be merged:
Currently
foldl'
function has next type:This type signature is not very convenient to use. Consider function where you want to insert elements of list one by one into
HashSet
(this is trivial example, but in practice something structurally similar appears very often):You either add
flip
or write your own function insidewhere
. Or usefoldr
, butfoldr
performance is abysmal and such implementation will have space leak (TODO: benchmark and profile to prove it). It's a common pattern in Haskell where data structure is the last argument of function. Because it's convenient to use so. But when you want to use this pattern withfoldl'
you can't rely on eta-reduce anymore :( You can't just writeSo I propose to have our
foldl'
with arguments changed:This should be implemented using
foldl'
frombase
. And some benchmarks should be added as well. I checkedGHC.List
module and didn't notice presence offoldl'
insideRULES
pragmas. So this change can be performed without performance penalties.DRAWBACKS
foldl'
frombase
(shouldn't be very important because not many people usesfoldl'
)foldl'
in a wrong way.ADVANTAGES