
On May 15, 2018, at 12:13 PM, 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" ===================================================
The above indentation looks wrong. Try: ---------- $ cat foo.hs strlen :: IO () strlen = do putStr "Enter a string: " xs <- getLine putStr "The string has " putStr (show (length xs)) putStrLn " characters" $ ghci foo.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( foo.hs, interpreted ) Ok, modules loaded: Main. Loaded GHCi configuration from /tmp/haskell-stack-ghci/05485125/ghci-script *Main> strlen Enter a string: foo The string has 3 characters *Main> ---------- If I incorrectly indent the subsequent lines: strlen :: IO () strlen = do putStr "Enter a string: " xs <- getLine putStr "The string has " putStr (show (length xs)) putStrLn " characters" Then I see an error: foo.hs:2:13: error: Parse error in pattern: putStr Possibly caused by a missing 'do'? -- Viktor.