:run commands are for testing command-line applications.
The simplest example is
:main with no arguments. If you have defined an action called
main, then the
:main command will run it.
λ> main = putStrLn "Hello!" λ> :main Hello!
This may not be very interesting, because this is not any different from what happens if we just asked GHCi to run the
main command directly.Notice that we have removed the colon in this second example, so here we not using a GHCi command.
λ> main Hello!
:main command gets more interesting when we have a program that reads its command-line arguments. A program does this using the following action from the
getArgs :: IO [String]