Skip to content
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

Refactor internals to NOT rely on RuntimeDataStore #539

Closed
MateuszKubuszok opened this issue May 21, 2024 · 0 comments · Fixed by #552
Closed

Refactor internals to NOT rely on RuntimeDataStore #539

MateuszKubuszok opened this issue May 21, 2024 · 0 comments · Fixed by #552
Labels
enhancement low hanging fruit Task that should be easy to implement - perfect for people that want to start contributing.

Comments

@MateuszKubuszok
Copy link
Member

Currently in a lot of of places we use ctx.runtimeDataStore(idx) directly, while TransformerConfiguration's overrides store only idx.

We could move this extraction to TransformerOverrides, so that the code would NOT hardcode how we are storing/parsing runtime information.

  • TransformerOverrides would store overrideExpr: Expr[Any] instead of index: Int
  • this overrideExpr could be computed in TransformerConfiguration.readTransformerConfiguration
  • every usage of ctx.runtimeDataStore(idx) could be replaced with overrideExpr

This way, in the future we could:

  • provide an alternative API without any runtime overhead:

    // no overhead for building Vector and extracting values from it
    foo.transform[Bar](
      Const(_.a.b.c, value),
      Computed(_.d.e.f, foo => anotherValue)
    )

    (By alternative I am thinking a separate module or even a separate library - to avoid confusion from one-in-one API - import dsl.* - and API split into components - auto.* + inlined.* + syntax.* - and then yet another API for inlined expressions without fluent API overhead like Ducktape's.)

  • open up possibilities to reuse macros to provide e.g. lens-like functionality

    // already possible!
    (foo: Foo).into[Foo].withFieldConst(_.bar.baz, value).transform
    
    // could be possible to implement
    foo.updateInline(
      Const(_.bar.baz, value)
    )

    (If we'd compare to e.g. Quicklens, and if we only consider .setTo, Chimney would only be missing foo.modify(_.list.at(idx)).setTo(item). If we could chain updates without any overhead, then we could get better performance than foo.modify(...).setTo(...).modify(...).setTo(...)),

  • make it easier to reuse Chimney derivation engine in other libraries (from what we can see Teleproto already attempts such thing in Try turning teleproto into a wrapper around chimney moia-oss/teleproto#321)

@MateuszKubuszok MateuszKubuszok added enhancement low hanging fruit Task that should be easy to implement - perfect for people that want to start contributing. labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement low hanging fruit Task that should be easy to implement - perfect for people that want to start contributing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant