{-# LANGUAGE LambdaCase #-}
module Main where
import Control.Monad
import System.IO
data NumberType = Normal Int
| Fizz
| Buzz
| FizzBuzz
numberType :: Int -> NumberType
numberType i = case (i `mod` 3 == 0, i `mod` 5 == 0) of
(True, False) -> Fizz
(False, True) -> Buzz
(True, True) -> FizzBuzz
_ -> Normal i
main :: IO ()
main = do
putStrLn "FizzBuzz v. 1.0.0"
putStr "From: "
hFlush stdout
from <- getLine
putStr "To: "
hFlush stdout
to <- getLine
forM_ (map numberType [read from .. read to]) $ \case
Normal i -> putStrLn $ show i
Fizz -> putStrLn "Fizz"
Buzz -> putStrLn "Buzz"
FizzBuzz -> putStrLn "FizzBuzz"