I have been doing some follow up to TaskLocal
and I have put together some tests to illustrate some of the findings.
TaskLocal.bind
looks like this:
def bind[R](value: A)(task: Task[R]): Task[R] =
Task.suspend {
val saved = ref.value
ref.update(value)
// the cleanup occurs in the thread where the task executes.