Created
April 8, 2017 23:55
-
-
Save janesser/b5e49fae2b20a3666263e3db810bd0d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad | |
import System.Environment | |
main = do | |
args <- getArgs | |
if null args | |
then mainCli | |
else mainArgs args | |
mainArgs args = do | |
let name = unwords args | |
greet name | |
mainCli = do | |
putStrLn "What's your name?" | |
name <- getLine | |
unless (null name) $ do | |
greet name | |
main | |
greet :: String -> IO () | |
greet name = putStrLn $ "Hi " ++ name ++ "!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment