The third line is fine. The type of “n” isn’t. The error message says it all:
Couldn't match expected type ‘a’ with actual type ‘Int’
‘a’ is a rigid type variable bound by
the type signature for:
absolutFrequency :: forall a. Integral a => Int -> [a] -> Int
at <interactive>:2:1-51
• In the second argument of ‘(==)’, namely ‘n’
In the expression: y == n
In a stmt of a list comprehension: y == n
• Relevant bindings include
y :: a (bound at <interactive>:6:35)
x :: [a] (bound at <interactive>:6:20)
absolutFrequency :: Int -> [a] -> Int (bound at <interactive>:4:1)
If you read between the lines you get:
Couldn't match expected type ‘a’ with actual type ‘Int’
In the expression: y == n
y :: a (bound at <interactive>:6:35)