user4515: i'm newbie and trying to learn haskell, but i'm having a problem in the Data.List chapter of learnyouahaskell as follows:
let xs = [1..6] in sum xs / genericLength xs    -- > it works

Now I try to add the drop function to calculate the average for some elements t want:
let xs = [1..6] in sum xs / genericLength (drop xs) -- > it works
let xs = [1..6] in sum xs / genericLength $ drop xs -- > it doesn't work
let xs = [1..6] in sum xs / genericLength . drop xs -- > also not working

i want to know what is the problem?

user5926: What????
First of all, you should just use length instead of genericLegth.
λ > let xs = [1..6] in sum xs / length (drop xs)

<interactive>:7:42: error:
    • Couldn't match expected type ‘Int’ with actual type ‘[a1]’
    • In the first argument of ‘drop’, namely ‘xs’
      In the first argument of ‘length’, namely ‘(drop xs)’
      In the second argument of ‘(/)’, namely ‘length (drop xs)’

The problem is that drop takes two input arguments, not 1 as you have given it in all three examples (the last of which is just wrong).
λ > :t drop
drop :: Int -> [a] -> [a]

Fixing that problem, you get another:
λ > let xs = [1..6] in sum xs / length (drop 2 xs)

<interactive>:9:20: error:
    • No instance for (Fractional Int) arising from a use of ‘/’
    • In the expression: sum xs / length (drop 2 xs)
      In the expression: let xs = [1 .. 6] in sum xs / length (drop 2 xs)
      In an equation for ‘it’:
          it = let xs = ... in sum xs / length (drop 2 xs)

Now, you have a problem with the / operator not being usable with Int.
The solution is:
let xs = [1..6] in fromIntegral (sum xs) / fromIntegral (length $ drop 2 xs)
5.25

The reason this does not work:
let xs = [1..6] in sum xs / length $ drop 2 xs

is because it gets desugared to:
let xs = [1..6] in (sum xs / length) (drop 2 xs)

which does not make sense.

4515: <p>i'm newbie and trying to learn haskell, but i'm having a problem in the Data.List chapter of learnyouahaskell as follows:</p>
<pre><code>let xs = [1..6] in sum xs / genericLength xs    -- &gt; it works
</code></pre>
<p>Now I try to add the drop function to calculate the average for some elements t want:</p>
<pre><code>let xs = [1..6] in sum xs / genericLength (drop xs) -- &gt; it works
let xs = [1..6] in sum xs / genericLength $ drop xs -- &gt; it doesn't work
let xs = [1..6] in sum xs / genericLength . drop xs -- &gt; also not working
</code></pre>
<p>i want to know what is the problem?</p>
 5926: <p>What????</p>
<p>First of all, you should just use <code>length</code> instead of <code>genericLegth</code>.</p>
<pre><code>λ &gt; let xs = [1..6] in sum xs / length (drop xs)

&lt;interactive&gt;:7:42: error:
    • Couldn't match expected type ‘Int’ with actual type ‘[a1]’
    • In the first argument of ‘drop’, namely ‘xs’
      In the first argument of ‘length’, namely ‘(drop xs)’
      In the second argument of ‘(/)’, namely ‘length (drop xs)’
</code></pre>
<p>The problem is that <code>drop</code> takes two input arguments, not 1 as you have given it in all three examples (the last of which is just wrong).</p>
<pre><code>λ &gt; :t drop
drop :: Int -&gt; [a] -&gt; [a]
</code></pre>
<p>Fixing that problem, you get another:</p>
<pre><code>λ &gt; let xs = [1..6] in sum xs / length (drop 2 xs)

&lt;interactive&gt;:9:20: error:
    • No instance for (Fractional Int) arising from a use of ‘/’
    • In the expression: sum xs / length (drop 2 xs)
      In the expression: let xs = [1 .. 6] in sum xs / length (drop 2 xs)
      In an equation for ‘it’:
          it = let xs = ... in sum xs / length (drop 2 xs)
</code></pre>
<p>Now, you have a problem with the <code>/</code> operator not being usable with <code>Int</code>.</p>
<p>The solution is:</p>
<pre><code>let xs = [1..6] in fromIntegral (sum xs) / fromIntegral (length $ drop 2 xs)
5.25
</code></pre>
<p>The reason this does not work:</p>
<pre><code>let xs = [1..6] in sum xs / length $ drop 2 xs
</code></pre>
<p>is because it gets desugared to:</p>
<pre><code>let xs = [1..6] in (sum xs / length) (drop 2 xs)
</code></pre>
<p>which does not make sense.</p>
