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

Use Foldable instead of list? #236

Open
andreasabel opened this issue Jan 19, 2023 · 0 comments
Open

Use Foldable instead of list? #236

andreasabel opened this issue Jan 19, 2023 · 0 comments

Comments

@andreasabel
Copy link
Contributor

andreasabel commented Jan 19, 2023

I see that some functions, like concatWith work for any Foldable instead of just for list.

Is there a reason why the other list functions are not generalized to Foldable? E.g.

hsep :: [Doc ann] -> Doc ann

I am trying to be progressive, using Data.List.NonEmpty and other list variants in my code base, but then I always have to sprinkle an extra toList in.

Unless there are reasons (like breaking type inference), I think all such list functions should be generalized to Foldable. (Even if type inference is broken for legacy users, such a generalization could maybe be pushed in a major-major version bump like 2.0...)

Update: I found a prior discussion on this, but maybe time is ripe for a revision:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant