* Joey Adams <joeyadams3.14...@gmail.com> [2012-07-09 01:38:06-0400] > 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/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe