Scotty concurrent write safety


I am taking some old code to upgrade it. It is a simple backend using Scotty, and I found that the server loop only consists in a call to scotty, and all the API calls can update global mutable IORefs. It looks like it is unsafe because there is no protection against multiple concurrent writes. I wonder what is the idiomatic way to add this kind of protection. An MVar? Using atomicModifyIORef? If I wanted to use STM with Scotty, would that be possible?

Thanks in advance.

1 Like

You can use stm with scotty and that would be my choice. Here is an example + an accompanied tutorial.