
* Joey Adams
This package provides imperative-style loops supporting "continue" and "break". For example:
import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Loop import Control.Monad.Trans.Class
main :: IO () main = foreach [0..] $ \i -> foreach [0..] $ \j -> do when (j == 0) $ continue -- skip to next iteration when (j >= 5) $ exit -- exit the loop when (i >= 5) $ lift exit -- exit the outer loop by calling 'exit' in the parent monad liftIO $ print (i, j)
Very nice! Here's a patch to generalize foreach to any Foldable: https://github.com/joeyadams/haskell-control-monad-loop/pull/1 Also, it's not obvious how your tests work. Please consider using HUnit and test-framework (or similar) to organize them. -- Roman I. Cheplyaka :: http://ro-che.info/