The error message says - you are using xs on the right hand side but do not define it before its usage (i.e. no let statement before, no where statement after, and not on the left hand side either.
Aside from this answer
You have another problem is that you are basically implementing a filter, but the result type is a String not a [String]!
letterList :: String -> [String]
letterList [] = []
letterList (x:xs) = if x == 'a' || x == 's'
then [x]: letterList xs
else letterList xs
- The first case prevents an error if you supply an empty
String!
- the next line deconstructs the
String in head = x and tail = xs, which is more readable and correct (tail x is wrong you try to take the end of a single letter!)
- next
[x] transforms a single letter Char in a String = [Char].
More elegant/homework
letterList str = [[x] | x <- str, x `elem` "as"]
this is called list comprehension, which would be the next "homework" I will give you to think about.
or
letterList str = map (\x -> [x]) $ filter (`elem` "as") str
Which uses higher order functions (filter and map) which is the second task I'll give you.
Edit
Of course you can also change the type signature to String -> String as @ChrisMartin shows - then you can omit the [,] in the [x] statements, and respectively omit the map (\x -> [x]) thing.
mirrorList?mirror :: [a] -> [a] mirror [] = [] mirror (x:xs) = [x] ++ mirror xs ++ [x]