Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created November 23, 2015 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/47832dfabc9925d5564e to your computer and use it in GitHub Desktop.
Save chuck0523/47832dfabc9925d5564e to your computer and use it in GitHub Desktop.
main = do
putStrLn "挨拶といえば?"
greeting <- getLine
answerToGreeting greeting
putStrLn "なんか数字を。"
num <- getLine
putStrLn (checkNum num)
-- 純粋でない関数内の`if`
-- `then`, `else`のあとに`do`をつける
answerToGreeting greeting = do
if greeting == "hi"
then do
putStrLn "You are using English"
else do
putStrLn "日本語ですね"
-- 純粋な関数内の`if`
-- `then`, `else`のあとに`do`をつけない
checkNum num =
if num == "0"
then "ゼロです"
else "ゼロではないです"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment