Created
November 10, 2018 23:48
-
-
Save jjant/9923cbd2a4e50c3be31a333f008a5bbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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