A couple of things are wrong here:
- You will need an else clause.
True
must be capitalized.
inputIndex
must always take two arguments (right now it does not, in the last case).
I guess you want something like this...
inputIndex :: [String] -> [String] -> IO ()
inputIndex listx input = if inputIndex' listx input
then putStrLn ("ok")
else putStrLn ("not ok")
where
inputIndex' :: [String] -> [String] -> Bool
inputIndex' listx input = and [x `elem` listx |x <- input]
(Here I defined a new function with a near-identical name, by appending a prime/apostrophe. By defining it in the where
clause, it is only visible to the outer inputIndex
function. You can call this a helper-function, if you will. I could also have chosen a completely different name, but I'm uncreative.)
You could also condense this to the following (which is also more general):
allPresent :: (Eq t) => [t] -> [t] -> IO ()
allPresent xs ys = putStrLn (if and [y `elem` xs | y <- ys] then "ok" else "not ok")