<div dir="ltr"><div><div>I just read the M.P. Jones paper on the topic of monad transformers and have been playing a bit with some simple examples combining `Maybe` and `State` with `IO`: <a href="http://lpaste.net/6702944292505124864">http://lpaste.net/6702944292505124864</a><br><br></div>I have the same "stuff" function defined 3 ways: two recursive methods, one of which takes the "maybe" function as an argument which is used to break the recursion, and a non-recursive method which is 'looped' using `iterateM_`.<br><br></div><div>The functionality is that an integer is given as initial `State` and it is decremented until 0 is reached, printing each iteration and breaking by the result of the "maybe" function. I also wanted to ensure that no negative integer could enter into the `State` so the same "maybe" function is used in main to restrict entry into the "stuff" function, either using `for_` over the result or injecting the `Maybe` before the "stuff" function.<br><br></div><div>The iterative calls are a little bit harder to read but the second (2) recursive call is fairly concise and readable.<br><br></div><div>Basically I'm just looking for any suggestions if anything looks out of place or can be refined before I go on to do more involved error handling or logging.<br></div><div><br></div><div>* There are also a couple helper functions at the bottom below "main" that I ended up not using but was wondering if they are defined somewhere.<br></div></div>