I need to get program arguments and show them
module Main ( main ) where
import System ( getArgs )
main = do
args<-getArgs
print $ show args
But it does nothing.Maybe my call incorrect?
>main 3 4
I need to get program arguments and show them
module Main ( main ) where
import System ( getArgs )
main = do
args<-getArgs
print $ show args
But it does nothing.Maybe my call incorrect?
>main 3 4
It sounds like you're trying to run the program from within GHCi. In that case, you can use the :main
command to run your program with arguments.
*Main> :main foo bar
"[\"foo\",\"bar\"]"
Try changing 'System' -> 'System.Environment':
module Main ( main ) where
import System.Environment ( getArgs )
main = do
args <- getArgs
mapM putStrLn args