-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An exploration of cats.mtl.Stateful tracing #103
Conversation
def stateful[S](a: S): IO[Stateful[IO, S]] = | ||
IOLocal(a).map { ioLocal => | ||
new Stateful[IO, S] { | ||
override def get: IO[S] = | ||
ioLocal.get | ||
override def set(s: S): IO[Unit] = | ||
ioLocal.set(s) | ||
override def monad: Monad[IO] = | ||
Monad[IO] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is lawful.
@@ -47,67 +47,68 @@ private[java] object TraceScope { | |||
case object Noop extends Scope | |||
} | |||
|
|||
def fromIOLocal[F[_]: LiftIO: Sync]( | |||
private[java] def fromStateful[F[_]: Sync: Stateful[*[_], Scope]]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike Local
, it's not as obvious what other instances we're bringing to the table here. StateT
over a Concurrent
is generally a bad idea. StateT
over a MonadError
can go up in smoke.
Could something clever be done with a Ref
?
Can we interoperate with synchronous Java with a gulp ThreadLocal
? Uh... probably not, because we also need a Sync?
Stateful[F, Scope].get.flatMap(p => | ||
Stateful[F, Scope].set(scope).as(p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be atomic? 🤔
I don't think this is going to work without solving the fs2 interruptScope issue, which I don't think is going to work without solving the CE race local state reconciliation issue, which I don't think is going to be solved. |
Like #102, but Stateful instead of Local.