The Monad Challenges

A set of challenges for jump starting your understanding of monads.

Outline

Set 1: Random Numbers

Set 2: Failing Computations

Set 3: Combinations

Set 4: Common Abstraction

Set 5: Do Notation

This project is maintained by mightybyte

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Generalizing pairs and cards

As we have done before, look at your allPairs and allCards functions and find the differences. Then implement a more general function that can be used to implement both allPairs and allCards. Call this new function allCombs.

allCombs :: (a -> b -> c) -> [a] -> [b] -> [c]

Then go back and reimplement allPairs and allCards in terms of allCombs. Verify that they do the same thing as the original functions.

Previous Page - Next Page