
4 May
2011
4 May
'11
11:25 a.m.
On 4 May 2011 13:21, Federico Mastellone
So, is it even possible to write a function with this type: getValues :: Foldable f => k -> MultiMap k v -> f v ???
I hadn't thought about it, but it's not possible to write that either. (!) You would need something like an Insertable class instead, plus Monoid so you can get an initial empty Set or List: getValues :: (Monoid (f v), Insertable f) => k -> MultiMap k v -> f v class Insertable f where insert :: a -> f a -> f a instance Insertable [] where insert a xs = (a:xs) -- Won't actually compile due to Ord constraint on Set -- (though there are ways with GHC to around that). -- instance Insert Set.Set where insert = Set.insert