fork download
  1. bmiCalculator :: IO ()
  2. bmiCalculator = do
  3. putStrLn "Please input your weight"
  4. weight <- readLn
  5. putStrLn "Please input your height"
  6. height <- readLn
  7. let bmi = weight / height^2
  8. putStrLn $ case () of
  9. _ | bmi <= 17.5 -> "stuff goes here"
  10. | bmi <= 20.7 -> "..."
  11. | otherwise -> "..."
  12.  
  13. {- a much better variant: extract bmi calculation into its own function -}
  14. showBmi :: Double -> Double -> String
  15. showBmi weight height
  16. | bmi <= 17.5 = "stuff goes here"
  17. | bmi <= 20.7 = "..."
  18. | otherwise = "..."
  19. where bmi = weight / height^2
  20.  
  21. bmiCalculator :: IO ()
  22. bmiCalculator = do
  23. putStrLn "Please input your weight"
  24. weight <- readLn
  25. putStrLn "Please input your height"
  26. height <- readLn
  27. putStrLn $ showBmi weight height
  28.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty