Skip to content

Improvements to Ask & Local#911

Merged
janstenpickle merged 5 commits intotrace4cats:masterfrom
alejandrohdezma:feature/improvements
Oct 18, 2023
Merged

Improvements to Ask & Local#911
janstenpickle merged 5 commits intotrace4cats:masterfrom
alejandrohdezma:feature/improvements

Conversation

@alejandrohdezma
Copy link
Copy Markdown
Contributor

💻 How to review this PR?

This PR was created with the idea of being reviewed commit by commit. Each commit contains an incremental change that makes it easier to review. Also some of the commits contain additional information in their description to help understand why the change was made.

I also recommend checking "Hide whitespace" when reviewing this PR!

🚀 What's included in this PR?

New method Ask.make to ease creating a new Ask instance

- implicit def instance[F[_]: Monad: Trace.WithContext]: Ask[F, SpanContext] = new Ask[F, SpanContext] {
-
-   override def F: Monad[F] = Monad[F]
-
-   override def ask[R1 >: SpanContext]: F[R1] = Trace.WithContext[F].context.widen
-
- }
+ implicit def instance[F[_]: Monad: Trace.WithContext]: Ask[F, SpanContext] = Ask.make(Trace.WithContext[F].context)

Add Ask instances for Tuple types

Provide automatic derivation of Ask instances for tuple types if we have instances for underlying types.

Provide implicit syntax for Local

- Local[F, Something]
-   .local(
-     myService.doSomething()
-   )(_.update(withSomething))
+ myService.doSomething()
+   .local(_.update(withSomething))

Provide Ask instances for SpanContext, TraceId & SpanId

@@ -0,0 +1,15 @@
package trace4cats.context

object syntax {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be good to include some provide syntax here too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! See 7b8fe6b

Copy link
Copy Markdown
Collaborator

@janstenpickle janstenpickle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@janstenpickle janstenpickle merged commit c5c400f into trace4cats:master Oct 18, 2023
@alejandrohdezma alejandrohdezma deleted the feature/improvements branch October 18, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants