
2 Oct
2004
2 Oct
'04
8:20 a.m.
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 ()