Skip to content

Instantly share code, notes, and snippets.

@jjant
Created November 10, 2018 23:48
Show Gist options
  • Select an option

  • Save jjant/9923cbd2a4e50c3be31a333f008a5bbf to your computer and use it in GitHub Desktop.

Select an option

Save jjant/9923cbd2a4e50c3be31a333f008a5bbf to your computer and use it in GitHub Desktop.
data FizzResult a
= Val a
| Fizz
| Buzz
| FizzBuzz
deriving (Show)
mkFizzBuzz :: (a -> Bool) -> (a -> Bool) -> a -> FizzResult a
mkFizzBuzz p r a =
case (p a, r a) of
(True, True) -> FizzBuzz
(True, False) -> Fizz
(False, True) -> Buzz
(False, False) -> Val x
fizzbuzz' :: Int -> FizzResult
fizzbuzz' = mkFizzBuzz (divisibleBy 3) (divisibleBy 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment