title: How do I properly use the length function in haskell?
body: <p>I am currently working on trying to find the number of primes between a range in haskell.  The program prints out the range of primes correctly. E.g countPrimesUntil 2 10 will print out [2, 3, 5, 7].  I am looking for the number 4 because that's how many primes is between 2 and 10.  How do I incorporate countPrimes correctly?</p>
  <pre><code>import Data.List
  
  countPrimesUntil :: Integral a=&gt; a -&gt; a -&gt; [a]
  countPrimesUntil a b = takeWhile (&lt;= b) $ dropWhile (&lt; a) $ sieve [2..]
      while sieve (n:ns) = n:sieve [m | m &lt;- ns, m `mod` n /= 0]
  
  countPrimes n = length([x | x &lt;- [2..n], countPrimesUntil x])
  </code></pre>