Zulip Chat Archive

Stream: lean4

Topic: Something like Haskell's `Foldable`?


Ben Selfridge (Mar 26 2025 at 03:05):

Is there something analogous to Foldable in lean?

Matt Diamond (Mar 26 2025 at 03:32):

Not sure, but the docs for Mathlib.Control.Fold have some relevant text:

https://leanprover-community.github.io/mathlib4_docs/Mathlib/Control/Fold.html

Specifically:

A special class could be defined for foldable, similarly to Haskell, but the author cannot think of instances of foldable that are not also Traversable.

Matt Diamond (Mar 26 2025 at 03:37):

It looks like foldl/foldr are defined for Traversables in that file

Ben Selfridge (Mar 26 2025 at 04:04):

Ah! That makes sense. Traversable and Foldable pretty darn close to the same thing.

Alok Singh (Mar 28 2025 at 05:10):

There was https://github.com/JamesGallicchio/LeanColls/ but it's been a bit since it was updated. I wish this was in batteries, these typeclasses show up a lot


Last updated: May 02 2025 at 03:31 UTC