[Haskell-beginners] Return a Foldable instance

Federico Mastellone fmaste at gmail.com
Wed May 4 14:11:50 CEST 2011


The MultiMap is based on Foldable types, but it's not Foldable (at
least there's no need to).
I made a mistake with the example function, the type I want is
getValues :: Foldable f => k -> MultiMap k v -> f v
but I don't know how to return a generic Foldable type.

On Wed, May 4, 2011 at 7:10 AM, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
> On 4 May 2011 07:25, Federico Mastellone <fmaste at gmail.com> wrote:
>>
>> Because the underlying structure is already Foldable, so why creating
>> a dummy function for every method on the Foldable class that only
>> calls the same function but in the underlying structure.
>
> If you make your MultiMap type and instance of Foldable, you get every
> method on the Foldable class for free anyway. Namely, you do not need to
> replicate functions with a Foldable constraint with your MultiMap data type.
> HTH,
> --
> Ozgur Akgun



-- 
Federico Mastellone
Computer Science Engineer - ITBA
".. there are two ways of constructing a software design: One way is
to make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."

Tony Hoare, 1980 ACM Turing Award Lecture.



More information about the Beginners mailing list