[Haskell-beginners] Return a Foldable instance

Felipe Almeida Lessa felipe.lessa at gmail.com
Wed May 4 13:39:26 CEST 2011


On Wed, May 4, 2011 at 2:51 AM, Chaddaï Fouché <chaddai.fouche at gmail.com> wrote:
> Writing this function given your intention (doing different thing
> depending on the type) is equivalent to writing an instance of
> Foldable for your (MultiMap k). If the underlying structure of your
> multimaps is always foldable, it doesn't make sense to make a function
> like this, the multimaps themselves should be Foldable. This is not
> hard to do, refer to the doc (
> http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.1.0/Data-Foldable.html
> ) to see how to write a minimal instance of Foldable.

I second this.  I don't see how an instance of Foldable (MultiMap k)
is different of what the OP wants.  Much easier and nicer.

Cheers,

-- 
Felipe.



More information about the Beginners mailing list