I'm in the process of learning Haskell, and type classes seem like a powerful way to make type-safe polymorphic functions. But a lot of the Haskell Prelude functions don't use them. More specifically:
Most of the list functions don't work with other data structures (for instance,
foldr
andlength
are only implemented for lists and can't be used on arrays).Modules like
Data.ByteString
are unusable unless you useimport qualified
since they include functions that have the same names as Prelude functions.
It seems like both of these problems would go away if the standard library used generic functions with type classes (please let me know if I'm totally off base with this).
I have two questions:
Are there technical or design reasons that the Prelude is like this, or is it just for historical reasons?
Looking around, it looks like there are a couple of libraries (like
Data.Foldable
and, if I'm not mistaken, Scrap Your Boilerplate) that replace the standard Prelude functions with generic alternatives. Are there any plans to incorporate these ideas into future versions of Haskell?