[Haskell-cafe] GHC TV station?
Sylvain Henry
sylvain at haskus.fr
Tue May 15 16:23:42 UTC 2018
Some ways to fix the given code:
strlen :: IO ()
strlen = do putStr "Enter a string: " >> do
xs <- getLine
putStr "The string has "
putStr (show (length xs))
putStr " characters"
strlen :: IO ()
strlen = do putStr "Enter a string: "
do
xs <- getLine
putStr "The string has "
putStr (show (length xs))
putStr " characters"
strlen :: IO ()
strlen = do putStr "Enter a string: "
xs <- getLine
putStr "The string has "
putStr (show (length xs))
putStr " characters"
On 15/05/2018 18:13, 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"
> ===================================================
> GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
> [1 of 1] Compiling Main ( C:\strlen.WhiteSpaced.hs, interpreted
> )
>
> C:\strlen.WhiteSpaced.hs:2:14: error:
> Parse error in pattern: putStr
> Possibly caused by a missing 'do'?
> |
> 2 | strlen = do putStr "Enter a string: "
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
> Failed, no modules loaded.
> Prelude>
> ==================================================
> strlen :: IO ()
> strlen = do {putStr "Enter a string: ";
> xs <- getLine;
> putStr "The string has ";
> putStr (show (length xs));
> putStr " characters"}
> =================================================
> GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
> [1 of 1] Compiling Main ( C:\strlen.Bracesed.hs, interpreted )
> Ok, one module loaded.
> *Main>
>
>
>
> --
> Sent from: http://haskell.1045720.n5.nabble.com/Haskell-Haskell-Cafe-f3074699.html
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe
mailing list