Search code examples
scalascala-catscats-effect

Does TVar in cats-stm require an immutable value?


Ref in Cats-effect or Zio requires to work with immutable value over the mutable references, because of the underlying java compareAndSet from AtomicReference, I wonder if it is the case with TVar with cats-stm ?


Solution

  • Yes, TVar is still analogous to using a var in imperative code, so the type should be immutable