Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of foldl' back and implement 'foldL' instead #136

Closed
chshersh opened this issue Feb 10, 2018 · 8 comments
Closed

Change type of foldl' back and implement 'foldL' instead #136

chshersh opened this issue Feb 10, 2018 · 8 comments

Comments

@chshersh
Copy link
Contributor

foldl' (/) 1 [2,3] doesn't do what it should according to type.

And changing type of foldl' introduces silent breakage.

Naming is another question. As well as an implementation of this function.

@chshersh chshersh added this to the v1.2.0: Convenience milestone Feb 10, 2018
@chshersh
Copy link
Contributor Author

Several unresolved questions:

  1. Naming? foldL or foldLeft or flipfoldl' or something else?
  2. Should it be polymorphic over container type class?
  3. Should we implement it manually or as foldl' . flip?

@volhovm
Copy link
Contributor

volhovm commented Feb 17, 2018

I don't really care about foldlL or whatever you'd like to call it, but since this issue is linked with "revert that change", I must write something. So I do. Please revert. :)

@dniku
Copy link
Contributor

dniku commented Feb 18, 2018

Perhaps foldlF/foldlF' and similarly for foldr would do.

@chshersh
Copy link
Contributor Author

@Pastafarianist What this F stands for?

@volhovm
Copy link
Contributor

volhovm commented Feb 19, 2018

"flipped", but this is counterntuitive. F in the end of the word usually means "Functor". flipFoldl(') is better.

@int-index
Copy link
Member

I agree with @volhovm , the F in the end immediately makes me think of functors. But I'd prefer flipfoldl to flipFoldl for aesthetic reasons.

@chshersh
Copy link
Contributor Author

Okay, I can introduce new function:

flipfoldl :: (Container t, Element t ~ a) => (a -> b -> b) -> b -> t -> b

with strict semantic and implement it manually for every data type.

@int-index
Copy link
Member

with strict semantic and implement it manually for every data type.

I'd expect flipfoldl' f = foldl' (flip f) with whatever type signature is inferred.

@chshersh chshersh removed this from the v1.2.0: Convenience milestone Feb 19, 2018
chshersh added a commit that referenced this issue Feb 19, 2018
[#136] Return type of foldl' back, add flipfoldl'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants