shapeless-2.3.3 released!

Squeaked in just before the end of the year … shapeless-2.3.3 is out!

Fifty three PRs merged and fifty three issues closed from thirty four contributors, eighteen of them first-time … thanks to all of you!

See the full set of changes since 2.3.2 in the detailed release notes below …


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

53 pull requests have been merged and 53 issues have been closed and since 2.3.2 … the complete list can be found in the 2.3.3 github milestone for issues and PRs.

Important note for users of Scala 2.11.12 and 2.12.4

Recent improvements in macro hygiene in the most recent Scala compiler releases interact badly with the implementation of shapeless’s Cached pseudo type in shapeless releases prior to this one. If you are using these Scala compiler versions and are using Cached directly, or indirectly via a library dependency, then you might see compiler crashes similar to the one reported here. If so then updating your shapeless dependency to 2.3.3 should resolve the issue.

Prominent changes

  • Added OrElse combinator, similar to Option.orElse but at the type level.
  • Added UnzipFunctions type class which unzips an HList of unary function types to a pair of HLists of corresponding argument and result types.
  • Added ZipWith and ZipConst type classes for zipping a Coproduct with an HList or repeated constant.
  • Reimplemented ToInt type class via a macro materializer to improve compile time performance.
  • Added new syntax for creating Polys from functions,
    val myPoly = Poly1.at[Int](x => x).at[String](_.length).at[Boolean](if(_) 1 else 0).build
    import myPoly._
    
    myPoly(10)      // 10: Int
    myPoly("hello") // 5: Int
    myPoly(true)    // 1: Int
    
  • Added a TypeOf pseudo operator which allows a type to be computed from a term in type position. This allows non-trivial types to be computed without repetition, eg.
    implicit val genFoo: TypeOf.`Generic[Foo]`.type = cachedImplicit
    

    Here genFoo is ascribed the narrow type inferred for the term Generic[Foo] including the type Repr refinement which would otherwise have to be written explicitly.

  • Added CoproductToEither and EitherToCoproduct type classes which support conversion between coproducts and nested Eithers.
  • Added MergeWith type class which merges two records using a Poly2 to combine the values of fields which are present in both.
  • Added DeepMerge and Extractor type classes for merging and extracting from nested records.
  • Added Refute type class witnessing that that no implicit instance of some type T is available.
  • The description field of Typeables for simple types and case classes is now computed at compile time rather than via reflection at runtime.
  • Fixed equals and hashCode for Sized.
  • Added Repeat type class for repeatedly concatenating an HList some Nat number of times.
  • Added syntax for injection into coproducts,
    true.inject[String :+: Boolean :+: CNil] // Inr(Inl(true))
    
  • Added RuntimeInject type class for injection into a coproduct via Typeable,
    Coproduct.runtimeInject[Int :+: String :+: CNil]("foo": Any) // Inr(Inl("foo"))
    
  • Added AlignByKeys type class allowing records to be aligned by their key types only.
  • Aligned the semantics of Witness more closely with SIP-23’s ValueOf.
  • Removed faulty implementation of coproduct ZipOne.
  • Added support in Generic for case-like classes with mutable fields.
  • Added support for Scala 2.13.0-M2.
  • Added support for Scala Native.
  • Bumped SBT to 0.13.16.

Source and binary compatibility

shapless 2.3.3 is source and binary compatible with 2.3.0, 2.3.1 and 2.3.2.

Contributors

Contributors for shapeless 2.3.3 are,

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