Branching off of OverloadedStringDefault proposal:
After thinking about it for a bit:
-
The only real
Foldable
/Traversable
instances I can count inbase
areList
andArray
. Every other one is there to either extract 0-1 elements or tocoerce
away a newtype. -
Data structure modules tend to be imported qualified, as their exports clash with
Prelude
.Map.foldr
is as good asfoldr
in my mind, as these functions are used sparsely. -
Data structures do not need all of the functions:
-
foldl
/foldr'
forList
are the classic example, indeed not all datatypes are born symmetric; - For non-empty types
null
is alwaysFalse
andtoList
has one or more elements guaranteed; -
elem
/maximum
/minimum
/sum
/product
areList
processing functions and there is no expectation for other datatypes to implement any of them; -
foldMap'
is a complete mystery to me (isnât it always a strict fold around a monoidal accumulator?).
-
-
Monomorphic / indexed / existential / higher-kinded stuff does not fit these definitions and thus either chooses to go the simple way or branches out into a whole extended bridge-burning universe that suffers from the exact same issues.
The ideas around Foldable
/ Traversable
and their extensions are solid, and libraries should be encouraged to share them. Explanations of terminology and mathematical reasoning should be documented somewhere easily accessible, but typeclasses are not a good tool here.
And yes, I know, even if most of the community fervently agrees with this, these typeclasses will not be dismantled overnight. If base-5
were to be agreed upon, I could see this be one of the changes.