On 2018-05-15 10:13 AM, Sylvester via Haskell-Cafe wrote:
strlen in Hutton 2ed 10.5 Derived primitives => run on Windows 7 Haskell
Platform 8.2.2
strlen :: IO ()
strlen = do  putStr "Enter a string: " 
                   xs <-  getLine 
                   putStr "The string has " 
                   putStr (show (length xs)) 
                   putStr " characters" 


This works fine if you indent the code correctly. The code following the first putStr should line up with it vertically:

strlen :: IO ()
strlen = do  putStr "Enter a string: "
             xs <- getLine
             putStr "The string has "
             putStr (show (length xs))
             putStr " characters"

This compiles for me with ghc 8.2.

The way you have the code above, the second and subsequent lines of the do block are indented further, and so would need an additional do. However, I don't think this is what's intended.

Are you using tabs by any chance? Or have you copied the source from text that uses a mixture of tabs and spaces?