Git Product home page Git Product logo

Comments (6)

MateuszKubuszok avatar MateuszKubuszok commented on July 18, 2024 1

Yes, such implicit would have to take another implicit: https://scastie.scala-lang.org/MateuszKubuszok/sxNjTJcdTti8yio8g0CRYA - I added a section about it in docs, that would be published in 0.8.1 (read it together with recommended automatic vs semiautomatic, since there us quite an important things there about the type of the implicit).

from chimney.

MateuszKubuszok avatar MateuszKubuszok commented on July 18, 2024

Just to be clear: you are missing the ability to just import existing implicits, rather than write your own? Because providing the implicit works.

I'd say such thing is doable, but one would have to keep a few things in mind:

  • Chimney can derive conversions between Arrays/types that extends Iterable and types which have scala.collecion.compat.Factory, it would be nice if working with Cats types would allow using all such input/output types
  • Cats uses Applicative and Traverse to construct results, and there might be types in stdlib which have no typeclass - some custom approach might be needed (custom typeclass created from Traversable/Appliative and providing its own instances when Cats don't)
  • there are Total Transformers and Partial Transformers - the latter should keep traces of which index/key caused an error, so when writing an implicit for them one might need to use some zipWithIndex-like apprach
  • IME Maps and Map-like collections cannot reuse the same implicits, they need their own
  • implicit priorities will almost certainly be a thing to deal with
  • there is a risk of some platform-specific code (e.g. Scala collection compat doesn't help with .to(MapType) on 2.12 - you'll get Iterable[(Key, Value)])
  • similarly a matter of automatic-vs-semiautomatic derivation if elements of source and target collection types are different
  • all of that would have to be tested
  • similar idea was implemented in Java types' support, so this module can be used to steel some ideas

So all in all doable, but one has to be prepared for quite a bit of work

from chimney.

codesurf42 avatar codesurf42 commented on July 18, 2024

Thank you for quick response. Yes, looks like it works for simple types and that's what I have already tried.

Can you have a look while it doesn't work when T is a more complex type, like here: https://scastie.scala-lang.org/Q14e3vvvSuOLHvz227wyyQ

  • that's what I usually get in case of deeper ADTs.

from chimney.

codesurf42 avatar codesurf42 commented on July 18, 2024

For me it works fine, so I don't feel like in need of this feature now. If I was to make chimney more user-friendly (and docs better searchable/gpt-ready), I would add the explicit example with smth like NonEmptyList[T] to the cookbook, especially there was the inner implicit auto-derived. I mean - not everyone will study all the docs before giving up on some library / such examples could attract more people to the user base.
In any case - thank you for your work and quick responses!

from chimney.

MateuszKubuszok avatar MateuszKubuszok commented on July 18, 2024

Well, I understand, but at the same time:

  • if I will have to add an example for every integration that someone might find useful then the docs would be 100 pages long
  • the search bar works great
  • and I rewritten docs from scratch like 3 weeks ago from this into this.

The release of a 0.8.x was a huge effort and I want to shift my attention to other things. I have some ideas what I also want to implement, but beyond that, if it's not a serious bug then I am leaving it at the hands of community.

from chimney.

MateuszKubuszok avatar MateuszKubuszok commented on July 18, 2024

Released in 1.0.0-RC1

from chimney.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.