<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 2018-05-15 10:13 AM, Sylvester via Haskell-Cafe wrote:<br>
<blockquote type="cite"
cite="mid:1526400834177-0.post@n5.nabble.com">
<pre wrap="">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"
</pre>
</blockquote>
<br>
This works fine if you indent the code correctly. The code following
the first <tt>putStr</tt> should line up with it vertically:<br>
<br>
<pre>strlen :: IO ()
strlen = do putStr "Enter a string: "
xs <- getLine
putStr "The string has "
putStr (show (length xs))
putStr " characters"
</pre>
This compiles for me with ghc 8.2.<br>
<br>
The way you have the code above, the second and subsequent lines of
the <tt>do</tt> block are indented further, and so would need an
additional <tt>do</tt>. However, I don't think this is what's
intended.<br>
<br>
Are you using tabs by any chance? Or have you copied the source from
text that uses a mixture of tabs and spaces?<br>
</body>
</html>