id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
4343	Add throwSTM and generalize catchSTM	basvandijk		"Currently the only way to throw an exception in an [http://hackage.haskell.org/packages/archive/stm/2.1.1.2/doc/html/Control-Monad-STM.html STM] transaction is via [http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Control-Exception.html#v:throw throw]. The `IO` monad has the [http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Control-Exception.html#v:throwIO throwIO] function which guarantees ordering with respect to other `IO` actions. It would be nice to have a similar function for the `STM` monad:

{{{throwSTM :: Exception e => e -> STM a}}}

Catching exceptions in the `IO` monad can be done with [http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Control-Exception.html#v:catch catch]:

{{{catch :: Exception e => IO a -> e -> IO a -> IO a}}}

Catching exception in the `STM` monad can be done with [http://hackage.haskell.org/packages/archive/stm/2.1.1.2/doc/html/Control-Monad-STM.html#v:catchSTM catchSTM]:

{{{catchSTM :: STM a -> (SomeException -> STM a) -> STM a}}}

However, it would be nice to generalize this function to any exception:

{{{catchSTM :: Exception e => STM a -> (e -> STM a) -> STM a}}}

This makes it consistent with the `IO` catch function and allows packages like: `exception-monads-fd/tf` to define instances for [http://hackage.haskell.org/packages/archive/exception-monads-tf/0.1/doc/html/Control-Monad-Exception.html#t:MonadException MonadException]."	proposal	closed	normal		libraries (other)	7.1	fixed	stm, exception, throw, throwIO, throwSTM, catch, catchSTM		Unknown/Multiple	Unknown/Multiple	None/Unknown					
