Haskell Language Reading all contents of standard input into a string


Example

main = do
    input <- getContents
    putStr input

Input:

This is an example sentence.
And this one is, too!

Output:

This is an example sentence.
And this one is, too!

Note: This program will actually print parts of the output before all of the input has been fully read in. This means that, if, for example, you use getContents over a 50MiB file, Haskell's lazy evaluation and garbage collector will ensure that only the parts of the file that are currently needed (read: indispensable for further execution) will be loaded into memory. Thus, the 50MiB file won't be loaded into memory at once.