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.

First Generalization Hint

All three of these functions are conceptually a call to rand followed by applying a function to the Integer it returns. What you ultimately need is a function that you can pass a Gen a to and will transform the result.

Be careful not to make your function too specific to rand. rand is a specific example of a Gen Integer but you want your function to work for other kinds of Gen a as well.

If you are still stuck, you can view the expected type signature by hex decoding the following string: 67656E6572616C41203A3A202861202D3E206229202D3E2047656E2061202D3E2047656E2062

You can decode it with this online hex decoder.

Back