To turn my comment into an answer:
You need to use the length
function. In this case you would compose it with what you already have as
countBetween lower upper = length . filter (>= lower) . filter (<= upper)
Alternatively, you could define your function with its full arguments as
countBetween lower upper xs = length $ filter (>= lower) $ filter (<= upper) xs
The general rule of thumb for eta reduction is to first turn all your $
s into .
s and add a $
before the last argument, so the above line becomes
countBetween lower upper xs = length . filter (>= lower) . filter (<= upper) $ xs
Then you look to see if the last argument to your definition is also the last argument to your expression, and it's the only place in your expression that the argument appears
countBetween lower upper xs = length . filter (>= lower) . filter (<= upper) $ xs
-- ^ ^
These can now be removed, leaving you with
countBetween lower upper = length . filter (>= lower) . filter (<= upper)
Then repeat. In this case, you can't eta reduce any more (easily), so you're done!
I would also recommend defining your functions with full arguments to begin with then slowly introducing point free versions. Sometimes it's fun to find clever ways to eta reduce expressions, but while it's possible to push it further with some definitions, it isn't always recommended. Only do it where it's natural and makes it easier to read. For example, using the pointfree
tool from the pointfree
package, you can eta reduce your definition all the way to
countBetween = ((length .) .) . (. (filter . flip (<=))) . (.) . filter . flip (>=)
But this is hardly readable. Don't do this.