Created
November 11, 2018 00:28
-
-
Save jjant/335b3dd60720ba1133e98f4af93b9ff0 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
| -- We don't really care about the types pt, pf, rt and rf here, | |
| -- and we want to get an Int back when both predicates are false. | |
| type FizzBuzz = FizzResult Int () () () () | |
| -- Helper function to format predicates to the form mkFizzBuzz needs. | |
| boolToEither :: Bool -> Either () () | |
| boolToEither True = Right () | |
| boolToEither False = Left () | |
| fizzbuzz :: Int -> FizzBuzz | |
| fizzbuzz = | |
| let divisibleBy' d x = boolToEither (divisibleBy d x) | |
| in mkFizzBuzz (divisibleBy' 3) (divisibleBy' 5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment