title: Haskell - Functors
body: <p>I'm trying to understand how Functors work, so I read about it here: <a href="http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass" rel="noreferrer">http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass</a></p>
  
  <p>I have a function that takes a map and calculates the sum of the values (which is a list).</p>
  
  <pre><code>reduce :: Map String [Int] -&gt; Map String Int
  reduce = fmap sum
  </code></pre>
  
  <p>I didn't really understand how the <code>fmap</code> worked so I read about it and tried to make my own version. i can't really test it because Map is already defined in the Haskell library.</p>
  
  <p>So is this right?</p>
  
  <pre><code>instance Functor (Map k) where  
      fmap f fromList[] = []
      fmap f fromList[(k, v): xs] = (f v) fmap xs
  </code></pre>