When is it OK to use an IORef?

前端 未结 4 728
我寻月下人不归
我寻月下人不归 2021-01-30 12:27

One thing that has always confused me is whether or not it\'s an okay time to use an IORef. Are there any guidelines that should be followed when deciding whether or not to use

4条回答
  •  一生所求
    2021-01-30 13:03

    Hmm. You'd use an IORef when you need some mutable state but are in a single threaded environment. Or when you want a mutable field inside a larger structure that is in turn held by a synchronization variable.

    In general, use MVars. They have more robust semantics.

提交回复
热议问题