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 :: MyMap String [Int] -> MyMap String Int reduce = fmap sum main :: IO () main = print (unMyMap (reduce (MyMap (Map.fromList [("a", [5,2]), ("b", [])]))))