Haskell: get table count(*) with postgresql.simple (with Connection Pool)
<p>Please,.. how can I get count(*) from one table? I'm trying to connect some fragments of code,..but so far no success.</p>

<p>This is what I have:</p>

<pre><code>fetchSimple :: FromRow r =&gt; Pool Connection -&gt; Query -&gt; IO [r]
fetchSimple pool sql = withResource pool retrieve
   where retrieve conn = query_ conn sql 

getUsersCount :: Pool Connection -&gt; IO (Int)
getUsersCount pool = do
   res &lt;- fetchSimple pool "SELECT count(*) FROM article" :: IO [Int]
   let f = head res
   return f
</code></pre>

<p>this gives me following error:</p>

<pre><code>No instance for (FromRow Int) arising from a use of ‘fetchSimple’
In a stmt of a 'do' block:
  res &lt;- fetchSimple pool "SELECT count(*) FROM article" :: IO [Int]
In the expression:
  do { res &lt;- fetchSimple pool "SELECT count(*) FROM article" ::
                IO [Int];
       let f = head res;
       return f }
In an equation for ‘getUsersCount’:
    getUsersCount pool
      = do { res &lt;- fetchSimple pool "SELECT count(*) FROM article" ::
                      IO [Int];
             let f = ...;
             return f }
</code></pre>