I'm new to Haskell too.
by a little change to your code, it could be re-written as
func :: [Int] -> Bool
func [] = False
func (x:xs)
| x == 3 = True
| otherwise = func xs
explain:
- if list is empty: there is no 3
- if list is no empty:
- if head is 3, then we have 3
- otherwise we should check rest of the list, so answer of "3 is in list" is equivalent to " x is in xs".
if you accept a little change, i can suggest implementing with OR (and help of lazy evaluation).
func :: [Int] -> Bool
func [] = False
func (x:xs) = x==3 || func xs
it is really same as the upper code, but with less lines.
- if head is 3, return True.
- if head is not 3, check rest of list.
at last, I want to introduce you elem function, it works as: get an element and a list, return True if a is in list, otherwise False.
It is exactly what we want here, so i write:
containsThree :: [Int] -> Bool
containsThree = elem 3
also note that I used point-free style, if you are not familiar, second line is same as:
containsThree xs = elem 3 xs
Good luck learning Haskell.