[Haskell-cafe] GHC TV station?

Neil Mayhew neil_mayhew at users.sourceforge.net
Tue May 15 16:56:34 UTC 2018


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180515/b6e4d4cb/attachment.html>


More information about the Haskell-Cafe mailing list