I'd be cautious about using exceptions too liberally. When I implemented a Haskell equivalent to traceroute, I wanted to stop sending packets when a certain condition occurred. It was very tempting to throw an exception and catch it at the top level. However, I think the code below is easier for the maintainer (me) to understand.

Dominic.

sequenceWhile_ :: Monad m => (a -> Bool) -> [m a] -> m ()
sequenceWhile_ p [] =
  return ()
sequenceWhile_ p (x:xs) =
  x >>= \c -> if (p c) then sequenceWhile_ p xs else return ()

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to