user2401036
user2401036

Reputation: 71

Haskell print string without newline

When I use this code it's print newline after result. How I can don't write newline?

import System.IO

main :: IO ()
main  = do
        a <- getLine
        b <- getLine
        let aa = read a :: Int
        let bb = read b :: Int
        let cc = aa + bb
        print cc

Upvotes: 7

Views: 7065

Answers (2)

Tom Charles Zhang
Tom Charles Zhang

Reputation: 1050

You can also putStr instead of putStrLn. Not sure how you would do something similar with print though.

Upvotes: 0

huon
huon

Reputation: 102216

print is defined as putStrLn . show, the fix is to use putStr . show $ cc.

Upvotes: 22

Related Questions