forked from arunatma/LearnYouAHaskell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCommandLineParams.hs
32 lines (26 loc) · 922 Bytes
/
getCommandLineParams.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- Part of 09_input_and_output.hs (but independent on its own)
-- Learn You a Haskell For Great Good
-- Chapter 9: Input and Output
-- http://learnyouahaskell.com/input-and-output
-- create an executable file out of this .hs file
-- Compile into an "exe"
-- > ghc --make getCommandLineParams.hs
-- Execution:
-- > getCommandLineParams.exe
-- or
-- > runhaskell getCommandLineParams.hs
--(needs to imported at the beginning of the .hs file)
import System.Environment
-- getArgs gets the command line arguments to a .hs program
-- getArgs :: IO [String]
-- getProgName gets the name of the executable .hs file
-- getProgName :: IO String
-- Does not get anything in interactive mode
main = getCommandLineParams
getCommandLineParams = do
args <- getArgs
progName <- getProgName
putStrLn "The arguments are:"
mapM putStrLn args
putStrLn "The program name is:"
putStrLn progName