bracketOnError, while, forever

Peter Simons simons at
Mon Feb 7 07:51:19 EST 2005


I just found the rather useful function 'bracketOnError' in
Network.hs and was wondering why it is not exported. You
need this combinator every time you fork off a computation
with an acquired resource, which happens pretty often in
network code, so I think making it available would be

On a similar note, I find myself using two rather simple
combinators frequently but have no place where to put them:

  while :: (Monad m) => m Bool -> m a -> m ()
  while cond f = cond >>= flip when (f >> while cond f)

  forever :: (Monad m) => m a -> m ()
  forever f = while (return True) f

'while', at least, would a nice addition to Control.Monad,


More information about the Libraries mailing list