Skip to content

Instantly share code, notes, and snippets.

@mizukmb
Created November 25, 2017 08:41
Show Gist options
  • Save mizukmb/e4bfebaddb40c3805c73d0dc888251ae to your computer and use it in GitHub Desktop.
Save mizukmb/e4bfebaddb40c3805c73d0dc888251ae to your computer and use it in GitHub Desktop.
import Data.Char
-- main = putStrLn "Hello, World"
-- main = do
-- putStrLn "Hello, what's your name?"
-- name <- getLine
-- putStrLn ("Hey " ++ name ++ ", you rock!")
main = do
putStrLn "What's your first name?"
firstName <- getLine -- <- は IO アクションを束縛する際に使う
putStrLn "What's your last name?"
lastName <- getLine
-- let は純粋な式を名前に束縛する際に使う
let bigFirstName = map toUpper firstName
bigLastName = map toUpper lastName
putStrLn $ "hey " ++ bigFirstName ++ " "
++ bigLastName ++ " "
++ ", how are you?"
@mizukmb
Copy link
Author

mizukmb commented Nov 25, 2017

すごいHaskellたのしく学ぼう! 『第8章 入出力』より

@mizukmb
Copy link
Author

mizukmb commented Nov 25, 2017

$ stack ghc helloworld.hsc
$ ./helloworld 
What's your first name?
foo
What's your last name?
bar
hey FOO BAR , how are you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment