You would attain different semantics by explicitly using a different effect (that includes a ‘transactionally’ operation as @tomjaguarpaw said) and handler in this case, and I think this is better than waiting for different semantics to fall out of arbitrary orderings of handler calls. To quote Alexis King:
I believe there is a ground truth that exists external to monads, transformers, and continuations. I believe an effect system should pursue it, acknowledging the advantages of adopting a model without confusing the model’s limitations for features of the terrain. Both semantics for
Errorcomposed withStateare useful, and we should be able to express them both, but we should do this intentionally, not incidentally.