ERROR - Cannot infer instance
<p>I am a beginner in Haskell. I have this function</p>

<pre><code>test f xs 
  | length xs == 0  = []
  | f (head xs)     = head xs : test f (tail xs)
  | otherwise       = test f (tail xs)
</code></pre>

<p>This function should make a list from every element of the list xs which is matching the f value but it gives back an error:</p>

<pre><code>test 1 [1,2]
ERROR - Cannot infer instance
*** Instance   : Num (a -&gt; Bool)
*** Expression : test 1 [1,2]
</code></pre>

<p>This part: </p>

<pre><code>| f (head xs)
</code></pre>

<p>should be a Bool but is it? Is it working as a filter? How can I make this function work? 
Thanks in advance.</p>