Haskell provides putStr, Putstrln functions, which write given string to standard output (terminal). putStr, putStrLn are almost same, only difference is putStrLn adds a newline character.
Prelude> :t putStr
putStr :: String -> IO ()
Prelude>
Prelude> :t putStrLn
putStrLn :: String -> IO ()
print function displays value of any printable type to the standard output device. Print function do this by calling show on its input first.
Technically print is defined like below.
print x = putStrLn (show x)
*Main> :t print
print :: Show a => a -> IO ()
Observe the signature of print function, it takes an argument ‘a’ which type should be instance of type class Show and return to IO.
*Main> print 10
10
*Main>
*Main> print [1, 2, 3]
[1,2,3]
*Main>
*Main> print 10.01
10.01
*Main>
This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here