-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add mapK
to Tracer
, SpanBuilder
, etc.
#284
Conversation
core/common/src/main/scala/org/typelevel/otel4s/meta/InstrumentMeta.scala
Show resolved
Hide resolved
core/trace/src/main/scala/org/typelevel/otel4s/trace/Span.scala
Outdated
Show resolved
Hide resolved
I managed to write up a PoC implementation of but for posterity...trait KindTransformer[F[_], G[_[_], _]] {
type GoF[x] = G[F, x]
val liftK: F ~> GoF
def mapK[H[_], A](ga: GoF[A])(f: F ~> H): G[H, A]
final def liftFunctionK[H[_]](f: F ~> H): GoF ~> G[H, *] =
new GoF ~> G[H, *] {
def apply[A](ga: GoF[A]): G[H, A] = mapK(ga)(f)
}
} |
core/trace/src/main/scala/org/typelevel/otel4s/trace/SpanOps.scala
Outdated
Show resolved
Hide resolved
core/trace/src/main/scala/org/typelevel/otel4s/trace/KindTransformer.scala
Outdated
Show resolved
Hide resolved
65424f6
to
1caa6b7
Compare
rebased to fix conflict; autosquashed while I was at it |
what's needed to move this PR forward? cc @iRevive @rossabaker |
Add `mapK` to `Tracer`, `Tracer.Meta`, `SpanBuilder`, `SpanOps`, `Span`, `Span.Backend`, and `InstrumentMeta`. Add `KindTransformer` type used by `mapK` implementation, allowing for a single `mapK` implementation that supports many transformation target types (`OptionT`, `EitherT`, `IorT`, `StateT`, `Kliesli`, `Resource`) with very little work needed to add additional or custom ones.
5a36ec0
to
b68cd63
Compare
* higher-kinded type `G`. | ||
*/ | ||
@annotation.implicitNotFound("No transformer defined from ${F} to ${G}") | ||
trait KindTransformer[F[_], G[_]] { |
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.
Which laws KindTransformer
should obey? Perhaps we can use Discipline to run law tests? https://typelevel.org/cats/typeclasses/lawtesting.html
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 and that sounds like a great idea!
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 talked to @NthPortal today and we agreed laws are a good idea but shouldn't block progress.
I'll also search through the archives of my brain and try to think of Haskell precedent for similar, but this is good for now.
java/trace/src/test/scala/org/typelevel/otel4s/java/trace/TracerSuite.scala
Outdated
Show resolved
Hide resolved
@NthPortal apologies for making you wait for so long. The changes look good to me. |
@rossabaker @armanbilge what's your opinion on these changes? |
remove Nested instance
* higher-kinded type `G`. | ||
*/ | ||
@annotation.implicitNotFound("No transformer defined from ${F} to ${G}") | ||
trait KindTransformer[F[_], G[_]] { |
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 talked to @NthPortal today and we agreed laws are a good idea but shouldn't block progress.
I'll also search through the archives of my brain and try to think of Haskell precedent for similar, but this is good for now.
Add
mapK
toTracer
,Tracer.Meta
,SpanBuilder
,SpanOps
,Span
,Span.Backend
, andInstrumentMeta
.Add
KindTransformer
type used bymapK
implementation, allowing for a singlemapK
implementation that supports many transformation target types (OptionT
,EitherT
,IorT
,StateT
,Kliesli
,Resource
) with very little work needed to add additional or custom ones.see #261 for previous work, and #264 for a less complex but less powerful alternative
rebase -i --autosquash