title: Composing functions via map and flatmap
body: <p>I learn scala in university and I cannot understand how to use map, flatmap and Option. Here's couple functions from my lab. I know how to implement first but I have no idea how to deal with second? So, the question: how to implement second function without changing it's signature (using map and flatmap)?</p>
  
  <pre><code>def testCompose[A, B, C, D](f: A =&gt; B)
                             (g: B =&gt; C)
                             (h: C =&gt; D): A =&gt; D = h compose g compose f
  
  def testMapFlatMap[A, B, C, D](f: A =&gt; Option[B])
                                (g: B =&gt; Option[C])
                                (h: C =&gt; D): Option[A] =&gt; Option[D] = // help
  </code></pre>