I want my showStackHead function take a stack print the head and return the rests, here is my code --code
showStackHead xx
               | xx == []   = return []
               | otherwise  = do putStrLn("result:" ++ (head xx))
                              return (tail xx)
when I run this code, the compiler tells me there is a parse error about the second return, so what is the right way to write this function?
Indent the 'return' to the same depth as 'putStrLn', like so:
showStackHead xs
   | xs == []   = return []
   | otherwise  = do putStrLn ("result:" ++ (head xs))
                     return (tail xs)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With