bracketOnError, while, forever
Peter Simons
simons at cryp.to
Mon Feb 7 07:51:19 EST 2005
Hi,
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
worthwhile.
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,
IMHO.
Peter
More information about the Libraries
mailing list