Skip to content

Instantly share code, notes, and snippets.

@jjant
Created November 11, 2018 00:28
Show Gist options
  • Select an option

  • Save jjant/335b3dd60720ba1133e98f4af93b9ff0 to your computer and use it in GitHub Desktop.

Select an option

Save jjant/335b3dd60720ba1133e98f4af93b9ff0 to your computer and use it in GitHub Desktop.
-- 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