Feedback on Maybe+State+IO code

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`: http://lpaste.net/6702944292505124864 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_`. 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. The iterative calls are a little bit harder to read but the second (2) recursive call is fairly concise and readable. 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. * 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.
participants (1)
-
shane pearman