Proposal: Add throwSTM and generalize catchSTM

Bas van Dijk v.dijk.bas at
Sun Sep 26 13:55:12 EDT 2010

On Sun, Sep 26, 2010 at 6:13 PM, Antoine Latter <aslatter at> wrote:
> Your new catchSTM can be written from the old one:
>> newCatchSTM stm h = catchSTM stm (h . fromJust . fromException . toException)


Is the toException necessary? It type checks without it.

> The following definition for throwSTM typechecks, and does pretty much
> exactly what you want, but we'll want someone on GHC to let us know
> that it is not going to do weird things to the RTS:
>> throwSTM e = STM (raiseIO# (toException e))

Yes, I was playing with this definition to but where a bit afraid of
using raiseIO# inside STM.

> Attached is a file with the implementations of these and some examples of usage.


I will make a patch out of this and attach it to the ticket. We'll see
what the GHC devs think of it.


More information about the Libraries mailing list