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

Another approach uses :

singleton :: a -> b a

and then just

mappend :: b a -> b a -> b a

i.e. make b a into a Monoid.

singleton = pure = return, if there happens to be a Monad/Applicative instance around.

And indeed there *will* be a Monad, if there is a sensible way of defining concat :: b (b a) -> b a, which there probably is.

Jules
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to