
On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery
On Wed, Dec 7, 2011 at 23:24, Alexej Segeda
wrote:
case s of (s == reverse s) -> putStrLn (s ++ " is a palindrome") otherwise -> putStrLn (s ++ " is not a palindrome")
case does pattern matching, not Boolean expressions. (s == reverse s) is not a useful pattern, and in fact is probably a syntax error because ==is not a valid infix constructor.
If you want to do Boolean comparisons in a case, you need to use something like
case () of () | s == reverse s -> putStrLn "palindrome" _ -> putStrLn "nope"
This is kind of a hack of case, though. I think what the OP was looking for is palindrome :: IO () palindrome = do putStrLn "Type in a word" s <- getLine isPalindrome s isPalindrome word | (word == reverse word) = putStrLn (word ++ " is a palindrome") | otherwise = putStrLn (word ++ " is not a palindrome") amindfv / Tom