[Haskell-cafe] classes for data structures

Henning Thielemann lemming at henning-thielemann.de
Wed Feb 6 09:00:04 EST 2008

On Wed, 6 Feb 2008, Matthew Pocock wrote:

> Hi,
> I've been working a lot with maps, sets and lists. While the process of
> getting things out of them is abstracted by foldable, traversable and
> friends, the process of building one up is not. Would it be possible to have
> something like:
> class Buildable b where
>   empty :: b a --makes an empty b with elements of type a
>   insert :: a -> b a -> b a --inserts the new element into the buildable

How can this interface be used both for lists and maps? I'm afraid it is
difficult to find an interface that fits the needs of many different data
structures. Maybe at least a generalized 'unfoldr' is possible.

More information about the Haskell-Cafe mailing list