title: Why do I have to compose id with mapM
body: <p>I have the following methods:</p>
  
  <pre><code>nucleotideComplement :: Char -&gt; Either String Char
  nucleotideComplement 'G' = Right 'C'
  nucleotideComplement 'C' = Right 'G'
  nucleotideComplement 'T' = Right 'A'
  nucleotideComplement 'A' = Right 'U'
  nucleotideComplement x = Left "Not a valid RNA nucleotide."
  </code></pre>
  
  <p>And would like to define another:</p>
  
  <pre><code>toRNA :: String -&gt; String
  toRNA = either error mapM nucleotideComplement
  </code></pre>
  
  <p>However I'm getting a type error here. However doing it this way seems to fix the issue:</p>
  
  <pre><code>toRNA :: String -&gt; String
  toRNA = either error id . mapM nucleotideComplement
  </code></pre>
  
  <p>I don't understand why this happens</p>
  
  <p>First, <code>id</code> has the type <code>a -&gt; a</code>. Next, when getting the type (<code>:t</code>) of <code>mapM nucleotideComplement</code> and <code>id . mapM nucleotideComplement</code>, they seem to be the same. Why am I getting such a different effect?</p>
  
  <p>Hope someone could clarify this further.</p>