Comments (6)
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.
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
Array
s/types that extendsIterable
and types which havescala.collecion.compat.Factory
, it would be nice if working with Cats types would allow using all such input/output types - Cats uses
Applicative
andTraverse
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 getIterable[(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.
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.
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.
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.
Released in 1.0.0-RC1
from chimney.
Related Issues (20)
- Unexpected arity mismatch when mixing Tuple with `enableOptionDefaultsToNone` HOT 6
- Improve ReadTheDocs/MkDocs configuration
- Scary compiler error when providing Int const instead of Long HOT 3
- Compilation of partial transformation fails when there are fields named both `is{Name}` and `{name}` HOT 2
- Silent invalid behavior of `withFieldConst` when field name starts with "set" HOT 6
- [PartialTransformer] Field Option[Field].None to Proto3.Fields.Default
- ClassCastException thrown on Scala 3 when transforming sealed traits to Protobuf GeneratedEnum HOT 12
- Automatic Coproduct Rename from/to Protobuf GeneratedEnum HOT 8
- Can't transform coproduct - Java Enum to Sealed trait HOT 24
- Cannot transform Scala class to Java class HOT 5
- Chimney stabilization into 1.0.0
- Exclude macro generated code from WartRemover checks HOT 14
- Fix Overrides for Subtypes matching
- Support seamless transformation of protobuf oneof types HOT 4
- Compiler bugs: known, relevant and unresolved/undocumented
- Support transformation to and from Java primitives
- Test more Scala CLI snippets for output (printed results)
- Support runtime-defined enums
- Rewrite Patchers as a special case of multiple case classes mapping
- Refactor internals to NOT rely on RuntimeDataStore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chimney.