Scala Tuple Extensions

Typesafe operations on tuples.

Build Status codecov Maven Central

  • prepend value "abc" +: (1, false) == ("abc", 1, false)
  • append value (1, false) :+ "abc" == (1, false, "abc")
  • concatenate (1, false) :++ ("abc", 3.14) == (1, false, "abc", 3.14); (1, false) ++: ("abc", 3.14) == (1, false, "abc", 3.14)
  • reverse (1, 2, 3).reversed == (3, 2, 1)
  • rotateRight (1, 2, 3).rotatedRight == (3, 1, 2)
  • rotateLeft (1, 2, 3).rotatedLeft == (2, 3, 1)
  • case class ToTuple case class CC(a: Int, b: String, c: Float) ToTuple(CC(1, "b", 3.14)) == (1, "b", 3.14) So this is designed as less type-confusing analog of CC.unapply(CC(1, "b", 3.14)).get
  • case class FromTuple case class CC(a: Int, b: String, c: Float) FromTuple((1, "b", 3.14)).to[CC] == CC(1, "b", 3.14)

Use

SBT

libraryDependencies += "com.andyglow.github" %% "scala-tuples" % "0.1.0"

Maven

<dependency>
  <groupId>com.github.andyglow</groupId>
  <artifactId>scala-tuples_2.13</artifactId>
  <version>0.1.0</version>
</dependency>

Gradle

implementation 'com.github.andyglow:scala-tuples_2.13:0.1.0'