Closed davidchambers closed 4 years ago
Deleted my previous comment, as I had misunderstood the change.
My only concern is that this function would share the signature of a right fold, but not the behavior. There's nothing wrong about that (functions with different behaviors frequently share the same type signature), just something to consider.
My only concern is that this function would share the signature of a right fold, but not the behavior.
Interesting observation, Gabe. I admit that I am not completely comfortable with foldl
and foldr
in Haskell. It is not clear to me why these functions are of different types:
> :type foldl
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
> :type foldr
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
> foldl (\s c -> c:s) "." "abc"
"cba."
> foldr (\c s -> c:s) "." "abc"
"abc."
Thank you for considering this addition, folks. I may be the only person excited about this function, but as no one has voiced opposition, I will merge this pull request. :)
I've wanted this function many times during the past few years. @sanctuary-js/owners, are you in favour of this addition?