import qualified Data.Map as Map newtype MyMap k v = MyMap { unMyMap :: Map.Map k v } instance Ord k => Functor (MyMap k) where fmap f = MyMap . Map.fromList . map (\(k,v) -> (k,f v)) . Map.toList . unMyMap reduce :: Map.Map String [Int] -> Map.Map String Int reduce = unMyMap . fmap sum . MyMap main :: IO () main = print (reduce (Map.fromList [("a", [5,2]), ("b", [])]))