I have the following code and I already tried multiple ways to write this, but I can\'t make it work. What I need is to use an if condition inside a do
You're missing an else.
palin :: IO ()
palin = do
line <- getLine
putStr line --Probably better to use putStrLn?
if True then putStr line else putStr "hi" --Also consider putStrLn here?
You need to provide an value, if you're coming from Python, then think about something like
a = "dogs" if 1 < 0 else "cats"
here, you need to provide the else as without it the variable assignment wouldn't run.