The Monad Challenges

PureScript Edition

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

MCPrelude documentation

This project is maintained by shaunplee and is a fork of the Monad Challenges 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 :: forall a b c. (a -> b -> c) -> Array a -> Array b -> Array 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