You will probably want to rebuild the structure a bit, as you have an IO involved in something that shouldn't be. How about changing the signature to something like this?
getChar :: Int -> String -> Maybe Char
getChar n x | n < length x = Just (x !! n)
| otherwise = Nothing
Data.Maybe , - (, ) Nothing ( ). , getChar, , . Data.Either . , ( ), Haskell , , Either Maybe, .
, , , , , .
main :: IO ()
main = do
x <- getLine
let z = getChar' 5 x
case z of
(Just z) -> print $ "The 5th character is " ++ show z
Nothing -> print $ "The 5th character is out of range"