title: why can't a function take monadic value and return another monadic value?
body: <p>Let's say that we have two monadic functions:</p>
  
  <pre><code>  f :: a -&gt; m b
    g :: b -&gt; m c
    h :: a -&gt; m c
  </code></pre>
  
  <p>The bind function is defined as </p>
  
  <pre><code>(&gt;&gt;=) :: m a -&gt; (a -&gt; m b) -&gt; m b
  </code></pre>
  
  <p>My question is why can not we do something like below. Declare a function which would take a monadic value and returns another monadic value?</p>
  
  <pre><code>  f :: a -&gt; m b
    g :: m b -&gt; m c
    h :: a -&gt; m c
  </code></pre>
  
  <p>The bind function is defined as </p>
  
  <pre><code>(&gt;&gt;=) :: m a -&gt; (ma -&gt; m b) -&gt; m b
  </code></pre>
  
  <p>What is in the haskell that restricts a function from taking a monadic value as it's argument?</p>
  
  <p>EDIT: I think I did not make my question clear. The point is, when you are composing functions using bind operator, why is that the second argument for bind operator is a function which takes non-monadic value (<code>b</code>)? Why can't it take a monadic value (<code>mb</code>) and give back <code>mc</code>  . Is it that, when you are dealing with monads and the function you would compose will always have the following type. </p>
  
  <pre><code>  f :: a -&gt; m b
    g :: b -&gt; m c
    h :: a -&gt; m c
  </code></pre>
  
  <p>and <code>h = f 'compose' g</code></p>
  
  <p>I am trying to learn monads and this is something I am not able to understand.</p>