You need to answer the two basic questions for writing recursively:
- What cases are so trivial that the answer is obvious?
- If given a non-trivial case, how do I make a smaller instance of it, so I can get the answer for that smaller instance just by using this same function that I am writing1, and then find my full answer from that smaller answer by some simple steps?
For this problem, the trivial cases (I would say) are when k is 0, and when the given list is an empty list.
For the non trivial case, the insight seems to be that I can get the first k elements of a list (for k > 0) by getting the first (k - 1) elements of the tail of the list, and then adding the head of the original list onto that 2.
This is not what your code does, so that's basically why it doesn't work :-)
As a side comment, I wouldn't consider it an error to ask for the first 0 elements of any list (including the empty list).
1 and the essence of recursion method is to assume you already have it at your disposal.
2 this is because of the identity length (x :: xs) = 1 + length xs
.