Skip to content

Instantly share code, notes, and snippets.

@Rembane
Last active December 21, 2015 16:49
Show Gist options
  • Select an option

  • Save Rembane/6336165 to your computer and use it in GitHub Desktop.

Select an option

Save Rembane/6336165 to your computer and use it in GitHub Desktop.
The typed solution for FizzBuzz.
module Main where
data FzBz = Fizz | Buzz | FizzBuzz | N Int
instance Show FzBz where
show Fizz = "Fizz"
show Buzz = "Buzz"
show FizzBuzz = "FizzBuzz"
show (N x) = show x
bzzr (N x) | mod x 15 == 0 = FizzBuzz
| mod x 3 == 0 = Fizz
| mod x 5 == 0 = Buzz
| otherwise = (N x)
main = putStrLn $ unwords $ map (show . bzzr . N) [1..100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment