Cookbook/Interactivity
< Cookbook
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Problem | Solution | Examples |
---|---|---|
reading a string | getLine | Prelude> getLine
Foo bar baz --> "Foo bar baz"
|
Printing a string
Strings can be output in a number of different ways.
Prelude> putStr "Foo"
FooPrelude>
As you can see, putStr does not include the newline character `\n'. We can either use putStr like this:
Prelude> putStr "Foo\n"
Foo
Or use putStrLn, which is already in the Standard Prelude
Prelude> putStrLn "Foo"
Foo
We can also use print to print a string, including the quotation marks.
Prelude> print "Foo"
"Foo"
Parsing command line arguments
TODO