Releases: scalalandio/chimney
v1.7.3
Changelog:
- cache some intermediate results during the macro expansion (#691) - feedback (improvement, no change, regression) is appreciated!
- more examples in documentation (#693)
- explanation why some usages lead to infinite recursion
- usage of
Transformer.derive
/Transformer.define
- examples of overrides with
Option
s/Either
s/collections - examples of updating
Option
types when the patch is decoded JSON
v1.7.2
Changelog:
- fix regression in
Patcher
s by @hughsimpson (#687) - update Scala 3 to 3.3.5
- update scala-collection.compat to 2.13.0
v1.7.1
Changelog:
- bugfixes
- increased test coverage for semiautomatic derivation methods and fixed a bug in Scala 3 implementation of
TransformerDefinition.withFallbackFrom
(#685) - enabling macro debugging for a single derivation (rather than globally) is no longer treated as an override changing behavior of some cases (#682)
- fix some rename edge cases broken by 1.6.0 refactor (#683, fixed in #684)
- increased test coverage for semiautomatic derivation methods and fixed a bug in Scala 3 implementation of
- updated documentation
- expanded section on
chimney-macro-commons
(#681) - updated Ducktape section, thanks to the first contrubution of @arainko! (the author of Ducktape) (#679)
- fixed typos in DESIGN.md, thanks to the first contribution of @civilizeddev! (#680)
- expanded section on
v1.7.0
This big release bring some long-awaited features: transformations, which take more than 1 case class
as input (well, not only case class
es 😄 ) and improved Patcher
s which handle: recursive patching, overriding values.
Changelog:
- merging transformations - now it's possible to start transformation DSL with 1 value, and keep adding more values as "fallbacks", so that if the field is not found in the first one, it will be looked for in the second, then third, etc, effectively allowing us to merge several input values into 1 output value (#115, fixed in #614)
- this includes merging several tuples into 1
- and merging several
Option
s orEither
s usingorElse
(opt-in) - and merging several collections using
++
(opt-in) - and more!
- added policies for checking if some source field was not used during transformation, or that some target sealed trait subtype was not matched - (#248, fixed in #614)
- we can set Chimney to fail compilation until we mark some source field explicitly not-used, ditto for sealed subtype
- rewritten
Patcher
s as specialized merging transformations (#538, fixed in #614)- this allowed us to make
Patcher
s recursive (fixing #119) - and take implicit
Patcher
in nested fields (fixing #133) - and made it east to add
withFieldConst
,withFieldComputed
andwithFieldomputedFrom
toPatcher
s (fixing #134) - and, combined with policies, allowed us to ignore some fields in
Patchers
and updating from another instance of the same type (fixing #161 and #57)
- this allowed us to make
- additionally we added (opt-in!) support for using implicit conversions and
<:<
during derivation (#667) - added support for generating transformation out of implicit
F ~> G
in Cats integration (#666) - improved
withFieldComputedFrom
to handle more expected cases (#660) - added/expanded a few sections in our documentation (#657)
- explained how to define transformers between
String
and enums - how to avoid using nested
.into.transform
when we need only 1 - the common issue of how to change the naming convention when decoding JSON and then using Chimney
- expanded Cats section on examples with
parMapN
and similar - updated Ducktape comparison
- explained how to define transformers between
- updated Scala 2.13 to 2.13.16, Scala.js to 1.18.1
With this release I feel that all of my personal ambitions for Chimney has been realized.
v1.6.0
Changelog:
-
now we are testing that macros in Scala 2.13 can read Scala 3 code and vice versa - while people might take it for granted, there are some differences in AST between both versions so support for e.g. default values or
@BeanProperty
requires additional work (done in #647) -
withFieldComputed
/withFieldComputedPartial
can now be used in a version that does NOT take the whole input, and so removes the need for writing nested transformers (done in #650)// before foo.into[Bar] .withFieldComputed(_.baz, foo => f(foo.field)) // cannot just use f, does not work with .everyItem etc .transform // or implicit val inner: Transformer[Field, Baz] = ... foo.into[Bar] .withFieldComputed(_.baz, _.field.transformInto[Baz]) // actually never needed -> withFieldRenamed is enough .transform // now foo.into[Bar] .withFieldComputedFrom(_.field)(_.baz, f) // just f, can be used as ComputedFrom(_.everyItem)(_.everyItem, f) etc .transform
-
flags can be provided not only globally, but for nested scope as well, which further removed any need for nesting transformers (done in #653)
// before foo.into[Bar] .withFieldComputed(_.baz, _.field.into[Baz].enableDefaultValues.transform) .transform // now foo.into[Bar] .withFieldRenamed(_.field, _.baz) .withTargetFlag(_.baz).enableDefaultValues .transform
-
make Path DSL more consistent - now Chimney should handle more overrides where we want to rewrite e.g. from
_.everyItem._1
into_.everyMapKey
,.matchingSome
is consistent with.matching[Some[InferredA]].value
, etc (done in #654) -
for a long time when
.withFieldConstPartial
or.withFieldComputed(something that might throw)
or.withFieldComputedPartial
were used, the errorPath
contained the target field name - if such transformation happens in nesting you would receive an error path likesourceField.nestedSourceField.targetField
which makes no sense. This is changed now, so that the Path would be<const for _.targetField>
,<computed for _.targetField>
orsourceField.anotherSourceField => <computed for _.targetField>
to make it explicit that the failure didn't come from some value in input, but in a value provided explicitly, or returned from a function (done in #655 and #656) -
documentation improvements by @ghostdogpr (#628) - thank you for your first contribution!
v1.5.0
Changelog:
- updated Scala 2.12 to 2.12.20, Scala to 3.3.4, Scala.js to 1.17.0 and Scala Native to 0.5.5
- added the
Result#fromCatchingNonFatal
by @danicheg in #590 - thank you for your first contribution! - fixed some typos by @danicheg in #593
- improved
withFieldRenamed
- now it supports.everyItem
/.everyMapKey
/.everyMapValue
/.matching[Subtype]
/.matchingSome
/.matchingLeft
/.matchingRight
on the source-side of the rename path as well!- done in #616 - added a new Outer Transformers integration - allowing to tell the Chimney how to convert some outer type while Chimney takes care of converting its inner values - and used it to improve the support for Cats' NonEmpty types - fixing #569 in #624
- tested and documented the possibly surprising behavior - that writing to
var
s is enabled with.enableBeanSetters
, and it makes sense! - done in #621 - improvements to
chimney-macro-commons
- module existing since Chimney 0.8.0-M1, which you probably haven't heard about yet:- adding
Type.simplePrint
andDefCache
which should make it easier to use this library for writing other macro libraries (with possibly different use cases than Chimney) - done in #620
- adding
- the first release of
chimney-engine
:- it allows using chimney derivation logic inside your own macros, if what you're trying to do is very close to what Chimney does but when extending it for your use cases requires modifying macros rather than providing an implicit
chimney-engine
has a release cycle tied to core Chimney (meaning the same version), but please consider this API experimental
- bugfix for pattern matcing fall through when the Scala 3's enum parameterless case is lowercased #479 - fixed by @jchyb in #603
- workaround against the bug in the compiler scala/scala3#21672 which would make order of cases in match nondeterministic (breaking cache)- fixed in #623
v1.4.0
Changelog:
- allow setting Chimney flags globally through
-Xmacro-settings
scalac flag - see the docs to be able to globally disable/enable default values, usage of defs, getters/setters, etc (done in #572) - start supporting some simple lens-like operations officially (added testing, bugfixed uncovered cases) - see the docs and start updating your data with
value.into[ValueType].withFieldConst(_.fieldName.matching[Subtype].everyItem, value).transform
and how it compares to e.g. Quicklens (done in #583) - improve the documentation about integrating other libraries with Chimney (done in #584)
v1.3.0
Changelog:
- fix issue in Scala 2 related to (probably?) Symbol initialization AND default values in constructor not relying on companion
apply
(#562, fixed in #563) - improve support for singleton types - case objects and Scala 3 enums as target should always succeed and always be available as a fallback values for parameters (do not require matching input parameter) (#407, fixed in #559)
- add Cats instances (Category/Invariant) for bi-directional transformations (Codec/Iso) (#566)
- improve docs testing - test whether the Scala CLI output printed with pprint matches the expectation (#536, fixed in #567)
- improve Protobufs support for data types modeled using sealed traits:
- implicit with automatic handling of
Empty
oneof forsealed_value
- implicit with automatic handling of
Unrecognized
forenum
- ability to automatically unwrap non-AnyVal value type (enabled with a flag) which can be used to unwrap oneof values (#531, fixed in #568)
- implicit with automatic handling of
v1.2.0
Changelog:
-
chimney-java-collections
module now contains conversions for Scala to/from Java primitives (scala.Int
<->java.lang.Integer
,scala.Double
<->java.lang.Double
, etc) (#535, done in #556) -
introduced
Codec[Domain, Dto]
andIso[A, B]
types which represents bidirectional conversions:Codec
"encodes"Domain
intoDto
usingTransformer
and "decodes"Dto
intoDomain
withPartialTransformer
Iso
represents isomorphism where both directions are handled withTransformer
s
-
allow renaming the subtype in sealed/enum conversions (#409, done in #557)
-
allow enabling default values only for a specific type (e.g.
scalapb.UnknownFieldSet
), allow providing your ownDefaultValue[A]
for cases when it would be convenient to use then but where they are not defined (#408, done in #558)
v1.1.0
Changelog:
-
updated Scala 2.13 to 2.13.14 (#526)
- it's the first release implementing SIP-51
which drops forward comparibility in standard library. It means that every library compiled with 2.13.14 or higher will
evict standard library to higher version - and since the compiler cannot be at lower version than the .ibrary it will also force
Scala version update. This change was reade to merge before Chimney 1.0.0 but we postponed it to give people more time to migrate to this new convention
- it's the first release implementing SIP-51
-
replaced Scala Native 0.4 with Scala Native 0.5 (#545) - while ideally we'd prefer to have a stepping-stone release cross-compiled for both 0.4 and 0.5,
libries that Chimney depends on in its integrations (Cats, Scala Collection Compat, Scala Java Time, ScalaPB) moved directly to
SN 0.5 dropping 0.4 on the spot -
made the order of pattern-matching in sealed trait/enum transformation deterministic (useful for avoiding cache misses) (#543) - thanks to @reimai for the first contribution!
-
replaced hardcoded dependency on DSL's runtime overrides storage from macros internals (#552, fixed in #539)
-
this change unblocks the possibility to provide a different front-end to Chimneys macros (or using Chimney macros inside your macros). It would allow a development of, for instance:
- Ducktape-like DSL without builder-API runtime overhead (
value.transformInto(overrides)
) - Chimney-based lenses - currently Chimney can be used for lenses-like operations
but it only works with.into.overrides.transform
API and bears the costs of builder-API overhead
(with different API it would be possible to update several nested fields with no overhead compared to manually written code!) - specialized derivations - initiatives like moia-oss/teleproto#321 would be able to call and customize Chimney macros directly,
replace Chimney'sTransformer
with their own type class, add/remove derivation rules, etc. with collision with Chimney
If you are interested in this, please contact us using GH discussions!
- Ducktape-like DSL without builder-API runtime overhead (
-