[Haskell-cafe] classes for data structures

Matthew Pocock matthew.pocock at ncl.ac.uk
Wed Feb 6 06:58:02 EST 2008


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

I'm not particularly wedded to the names. It's just that it would be very 
convenient sometimes to collect data items into e.g. a list or a set, without 
pushing in some klunky foralled insert function.

I see that this is realted to MonadPlus, but the space of possible container 
classes is wider than that of monads e.g. set.


More information about the Haskell-Cafe mailing list