Constructing efficient monad instances on `Set` (and other containers with constraints) using the continuation monad
Monads are one particular way of structuring and sequencing computations. The bind of a monad cannot magically restructure your computation so as to happen in a more efficient way. There are two problems with the way you structure your computation. When evaluating stepN 20 0, the result of step 0 will be computed 20 times. … Read more