the following code compiles well but when i try to input helper 10 primes [] [] it gives me :Non-exhaustive patterns in function helper
primes = [2, 3, 5, 7,
Based on the first line of the definition of helper, it will match on an empty list ([]) in the second argument. Based on the second line, it will match on a list of at least two values in the second argument (x:y:xs). This leaves a single-item list unaccounted for.
EDIT
For the sake of simplicity, let's assume that primes is defined like this:
primes = [2, 3, 5]
Now when you evaluate this expression:
helper 10 primes [] []
Clearly it's the second part of the definition of helper that will get matched here (the first part would only match if primes were an empty list). Now based on the pattern for the second parameter (x:y:xs), we can see that x will be bound to 2, y will be bound to 3 and xs will be bound to [5]. In the definition of helper you are applying the function recursively using xs as the second argument. In other words, it looks something like this:
helper 10 [5] ...
Which case of the helper function will be used here? [5] is not an empty list, so not the first one. The second case? No, that case only matches against a list of at least two values (what value would y get bound to?). I hope you can now see that you have not accounted for when helper is called with a single item list as the second parameter (which in practice will happen any time you call helper with a list of an odd number of values in the second parameter).