shapeless-2.3.0 released!

shapeless-2.3.0 is out!

Lots of issues closed (61 to be precise) and PRs merged (85 in total) from the largest number of contributors to any shapeless release so far (a grand total of 26 … thanks to all of you!). This release to some extent represents consolidation in the light of the experience of the many projects downstream of shapeless. But there have been other significant changes.

One of the biggest is that the project branch and build structure has been completely reworked. shapeless is now built for all permutations of Scala 2.10/11/12 and JVM and Scala.js from a single branch using macro-compat and the new support for JUnit in Scala.js 0.6.6+.

On the face of it, this runs counter to what I said in the release notes for 2.2.0,

My “one branch per platform” policy seems to be paying off: managing the differences between Scala 2.11.x and Scala 2.10.x for each of the JVM and Scala.js by branching and merging (as opposed to managing platform variations within a single branch) is working out very smoothly.

but I’m not backing away from that entirely.

It’s certainly true that managing releases from four branches became somewhat unweildy, but that was mitigated to a very large extent by the multi-branch relase script contributed by Johnny Everson. What really changed is that the state of the art for dealing with cross-platform builds for both Scala.JVM and Scala.JS has moved on significantly … I’d particularly like to thank Alistair Johnson for all the work he’s done on this across the entire gamut of Typelevel projects.

When I started work on export-hook I wanted to take advantage of that and, as an experiment, decided to try going for a single branch approach to dealing with macros on Scala 2.10.x vs. 2.11.x as well … this led to the development of macro-compat which I think has worked out beautifully. Having seen the benefits of this approach in export-hook it seemed that it would be worth seeing if it would scale to the more extensive macro usage in shapeless as well. To cut a long story short, it did … and I’d like to thank Dale Wijnand for his amazing contribution to that.

So where does that leave what I said in 2.2.0 release notes? In the absence of macro-compat, or something equivalent, if you have non-trivial macros, I still think it would be preferable to manage the difference between the 2.10.x and 2.11.x macro APIs by branching. But, for me at least, that’s now moot.

For the rest of the changes in 2.3.0, see the detailed release notes below …

Many thanks to everyone who contributed!


This is the final release of shapeless-2.3.0. These release notes provide a summary of changes since shapeless 2.2.5.

Prominent changes

85 pull requests have been merged and 61 issues have been closed and since 2.2.5 … the complete list can be found in the 2.3.0 github milestone for issues and PRs.

The project branch and build structure has been completely reworked. shapeless is now built for all permutations of Scala 2.10/11/12 and JVM and Scala.js from a single branch using macro-compat and the new support for JUnit in Scala.js 0.6.6+.

There are a large number of new features, refactorings and bug fixes in shapeless 2.3.0. The most significant of these are,

ADTs

  • Many bug fixes and improvements in the implementation of Generic.
  • Many bug fixes and improvements in the implementations of Generic1, IsHCons1, IsCons1 and Split1 in support of Kittens.
  • Added Annotation and Annotations type classes providing evidence of the presence of annotations on a type, or on the elements or constructors of an ADT.
  • Added Default, AsRecord and AsOptions type classes providing evidence of the default values for the constructors of product types as HLists of Options or records.
  • LabelledGeneric[T] no longer extends Generic[T].

HLists/Coproducts/tuples/records

  • Dramatically improved compile time performance for record select and update.
  • Added zipWithIndex method and ZipWithIndex type class for HLists, Coproducts and tuples.
  • Added ToCoproduct/ToSum type classes for HLists and tuples.
  • Added toCoproduct method and ToCoproductTraversable type class allowing conversion of an HList to a homogenous collection of the Coproduct of its element types.
  • Added selectMany, selectManyType and selectRange methods and SelectMany and SelectRange type classes allowing elements of an HList to be selected given a set or range of Nat indices.
  • Added group method and Grouper and PaddedGrouper type classes allowing HLists and tuples to be subdivided into smaller tuples of a given size.
  • Added union, intersect, diff methods and Union, Intersection and Diff type classes supporting set-like operations on HLists.
  • Added updateAtWith method and ModifierAt type class supporting functional update of elements of HLists and tuples at a given Nat index.
  • Added collectFirst method and CollectFirst type class which applies a Poly to the first compatible element of an HList.
  • Added LiftAll type class which collects instances of a type class for each element of an HList.
  • Added padTo and slice methods and PadTo and Slice type classes which support padding and slicing HLists to/by Nat indices.
  • Added toRecord method and FromMap type class which supports type safe conversion of a homogenous Map to a record.
  • Added remove and removeAll methods and Remove and RemoveAll type classes supporting removing of one or more fields from a record. These operations are reversible via reinsert and reinsertAll.
  • Added toSizedHList method and ToSizedHList type class which support conversion of a homogenous collection to an HList of a known size.
  • Added impossible method to CNil.
  • Improved readability of toString for nested HLists.
  • Improved toString for Coproducts.

Infrastructure

  • cachedImplicit now uses a more reliable mechanism for preventing self-loops.
  • Added Strict and Cached type constructors which modify the semantics of Lazy by eliminating unnecessary closures and by sharing instances respectively.
  • Added LowPriority mechanism for controlling the priority of instances during implicit resolution.
  • User supplied @implicitNotFound annotations are now propagated through Lazy.
  • Added NatProductArgs which allows argument lists of Int literals to be mapped to HLists of Nats.
  • Added Range, GCD, LCM, GT and GTEq type classes for Nats.
  • Added NatWith which supports conversion of Int literals to Nat values and simultaneously summoning a specified type class at the corresponding Nat type.
  • Added Widen type class which allows the widening of a singleton type and value to the corresponding non-singleton type.
  • Added runtimeList method allowing conversion of an HList to a List[Any] efficiently when precise types are not needed.
  • Added unwrapped method and Unwrapped type class which allow access to the value underlying a newtype or value class.
  • The experimental support for lifting polymorphic methods to Poly values has been removed.

Source and binary compatibility

shapless 2.3.0 is source compatible with 2.2.5. As indicated by the version number bump, however, shapeless 2.3.0 is not binary compatible with shapeless 2.2.x.

Contributors

Contributors for shapeless 2.3.0 are,

Many thanks to all of you and everyone else who has contributed ideas, enthusiasm and encouragement.