title: Haskell readFile: Couldn't match expected type ‘[String]’ with actual type ‘IO String’
body: <p>I am trying to read a file into a function to calculate the frequencies of characters in a file. So I am trying the following:</p>
  
  <pre><code>charCount :: String -&gt; [(Char, Int)]
  charCount input = M.toList $ M.fromListWith (+) [(c, 1) | c &lt;- input]
  
  calculate :: FilePath -&gt; [(Char, Int)]
  calculate fp = do
    c &lt;- readFile fp
    charCount c
  </code></pre>
  
  <p>But I am getting the following error:</p>
  
  <pre><code>FileWriter.hs:13:8: Couldn't match expected type ‘[String]’ …
                  with actual type ‘IO String’
      In a stmt of a 'do' block: c &lt;- readFile fp
      In the expression:
        do { c &lt;- readFile fp;
             charCount c }
  Compilation failed.
  </code></pre>