title: Haskell Type Synonyms for Functions
body: <p>Say we have the following in Haskell,</p>
  
  <pre><code>type Bag a = a -&gt; Int
  
  data Gems = Sapphire|Emerald|Diamond|Ruby deriving (Show)
  
  myBag :: Bag Gems
  myBag Sapphire = 3
  myBag Diamond = 2
  myBag Emerald = 0 
  
  emptyBag :: Bag Gems
  emptyBag Sapphire = 0
  emptyBag Diamond = 0
  emptyBag Emerald = 0
  </code></pre>
  
  <p>How would we define a function addItem such that addItem x b adds a single occurrence of item x to bag b?</p>