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

Add Haskell's Foldable #1099

Closed
MatthewDaggitt opened this issue Mar 5, 2020 · 5 comments
Closed

Add Haskell's Foldable #1099

MatthewDaggitt opened this issue Mar 5, 2020 · 5 comments

Comments

@MatthewDaggitt
Copy link
Contributor

The results in Algebra.Operations.CommutativeMonoid would really benefit from being proved over a suitable Foldable structure rather than individually for List/Vec/Vector etc.

See https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Foldable.html

Perhaps someone whose familiar with it, could suggest whether we can leverage dependant types to improve the definition somehow?

@gallais
Copy link
Member

gallais commented Mar 5, 2020

I don't think it's a low hanging fruit. Foldable cannot fit in a record like
Functor or Monad do because of size issues!

@jespercockx
Copy link
Member

Can't we just have a Foldable that is parametrized over the level of the return type? At least that's what @UlfNorell did in https://github.com/UlfNorell/agda-prelude/blob/master/src/Container/Foldable.agda.

@jamesmckinna
Copy link
Contributor

Cf. My ICFP2017 talk at TyDe on Foldable https://icfp17.sigplan.org/track/tyde-2017-papers (and Tarmo Uustalu's independent discovery of the same thing somewhat earlier): it would be nice to have a suitable setting in which that characterisation is provable, and hence, as a by-product, be able to dispense with Foldable altogether... But the higher-rank characterisation perhaps hints at what dark level-polymorphic magic might be required to achieve that end.

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Sep 20, 2022

And yes, let's please try to have this: sum and product have no business being defined in Data.List.Base, being special to ... which means that Data.List.Properties ends up importing Data.Nat.Divisibility in order to establish a single property of product, while properties of sum such as sum-++ are not defined as instances of the corresponding general property of foldr: not a rational approach, IMNSVHO.

UPDATED This specific point is handled by #2558 (and #2561 for the Bool counterparts).

@jamesmckinna
Copy link
Contributor

Meanwhile, is the general issue now closed by #2300 ? I hope so!

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

4 participants