Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Created April 8, 2015 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhileshs/703e388430a8f0ca666c to your computer and use it in GitHub Desktop.
Save akhileshs/703e388430a8f0ca666c to your computer and use it in GitHub Desktop.
prodToSum :: (a, Either b c) -> Either (a, b) (a, c)
prodToSum (x, e) =
case e of
Left y -> Left (x, y)
Right z -> Right (x, z)
sumToProd :: Either (a, b) (a, c) -> (a, Either b c)
sumToProd e =
case e of
Left (x, y) -> (x, Left y)
Right (x, z) -> (x, Right z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment