diff --git a/datatypes/contt.html b/datatypes/contt.html index d348adb998..8aa9d246bd 100644 --- a/datatypes/contt.html +++ b/datatypes/contt.html @@ -286,7 +286,7 @@

ContT

Succeeded(user.id) } } -// eval: Eval[UserUpdateResult] = cats.Later@5ac3866f +// eval: Eval[UserUpdateResult] = cats.Later@613222e9

Finally we can run the resulting Eval to actually execute the computation:

eval.value
 // Persisting updated user to the DB: User(100,Bob,150)
@@ -308,7 +308,7 @@ 

// anotherComputation: ContT[Eval, UserUpdateResult, Map[String, String]] = FromFn( // runAndThen = Single( -// f = cats.data.ContT$$Lambda$11853/0x00007f6e43ffb9c0@690c4ba9, +// f = cats.data.ContT$$Lambda$14355/0x00007fea8366a298@2275791a, // index = 0 // ) // ) @@ -319,7 +319,7 @@

Succeeded(userFields("id").toInt) } } -// anotherEval: Eval[UserUpdateResult] = cats.Eval$$anon$5@1e836f7b +// anotherEval: Eval[UserUpdateResult] = cats.Eval$$anon$5@59abc63a anotherEval.value // Persisting these fields to the DB: Map(id -> 100, name -> Bob, age -> 150) @@ -336,7 +336,7 @@

// updateUserModel: ContT[Eval, UserUpdateResult, User] = FromFn( // runAndThen = Single( -// f = cats.data.ContT$$Lambda$11853/0x00007f6e43ffb9c0@42c47999, +// f = cats.data.ContT$$Lambda$14355/0x00007fea8366a298@420ed3c3, // index = 0 // ) // ) @@ -370,7 +370,7 @@

updateUserModel flatMap persistToDb flatMap publishEvent // chainOfContinuations: ContT[Eval, UserUpdateResult, UserUpdateResult] = FromFn( // runAndThen = Single( -// f = cats.data.ContT$$Lambda$11857/0x00007f6e43ffe5b8@26424caa, +// f = cats.data.ContT$$Lambda$14359/0x00007fea8366ac20@4310e065, // index = 0 // ) // ) @@ -381,7 +381,7 @@

finalResult } } -// eval: Eval[UserUpdateResult] = cats.Eval$$anon$5@12a14b8e +// eval: Eval[UserUpdateResult] = cats.Eval$$anon$5@6738db8e eval.value // Updated user model diff --git a/datatypes/eval.html b/datatypes/eval.html index 672f7d3d30..fef32ab846 100644 --- a/datatypes/eval.html +++ b/datatypes/eval.html @@ -257,7 +257,7 @@

println("Running expensive calculation...") 1 + 2 * 3 } -// lazyEval: Eval[Int] = cats.Later@50ed86a1 +// lazyEval: Eval[Int] = cats.Later@45e7d71c lazyEval.value // Running expensive calculation... @@ -276,7 +276,7 @@

println("Running expensive calculation...") 1 + 2 * 3 } -// always: Eval[Int] = cats.Always@2430073e +// always: Eval[Int] = cats.Always@312f4371 always.value // Running expensive calculation... diff --git a/datatypes/freeapplicative.html b/datatypes/freeapplicative.html index 7567f82f3c..c2fee6d3ab 100644 --- a/datatypes/freeapplicative.html +++ b/datatypes/freeapplicative.html @@ -275,7 +275,7 @@

val validator = prog.foldMap[FromString](compiler)
-// validator: FromString[Boolean] = cats.instances.Function1Instances$$anon$7$$Lambda$12015/0x00007f6e437d33d0@146a2ff9
+// validator: FromString[Boolean] = cats.instances.Function1Instances$$anon$7$$Lambda$14517/0x00007fea836ef678@56fd661f
 validator("1234")
 // res0: Boolean = false
 validator("12345")
diff --git a/datatypes/freemonad.html b/datatypes/freemonad.html
index e0dd2a4155..21dbc902e6 100644
--- a/datatypes/freemonad.html
+++ b/datatypes/freemonad.html
@@ -718,7 +718,7 @@ 

import TeletypeOps._ val state = program.foldMap(interpreter) -// state: TeletypeState[Unit] = cats.data.IndexedStateT@53935844 +// state: TeletypeState[Unit] = cats.data.IndexedStateT@d55932e val initialState = Nil // initialState: Nil.type = List() val (stored, _) = state.run(initialState).value @@ -789,7 +789,7 @@

val evaluated = hoisted.foldMap(tryInterpreter) // evaluated: OptTry[Int] = OptionT(value = Success(value = Some(value = 12))) diff --git a/datatypes/state.html b/datatypes/state.html index 02f35ec128..d57e72e994 100644 --- a/datatypes/state.html +++ b/datatypes/state.html @@ -474,7 +474,7 @@

_ <- close _ <- open } yield () -// valid: IndexedStateT[Eval, Closed.type, Open.type, Unit] = cats.data.IndexedStateT@2432b167

+// valid: IndexedStateT[Eval, Closed.type, Open.type, Unit] = cats.data.IndexedStateT@2492a7f5

Note that the inferred type of valid correctly models that this computation can be executed only with an initial Closed state.

valid.run(Open)
 // error: type mismatch;
@@ -483,7 +483,7 @@ 

valid.run(Closed) -// res6: Eval[(Open.type, Unit)] = cats.Eval$$anon$1@8c0f0e3

+// res6: Eval[(Open.type, Unit)] = cats.Eval$$anon$1@6b8e5faf diff --git a/js/sponsors.js b/js/sponsors.js index c64d9e270c..fd22d9ad62 100644 --- a/js/sponsors.js +++ b/js/sponsors.js @@ -38,11 +38,11 @@ var sponsors = async function () { for (i = 0; i < members.length; i++) { var member = members[i]; switch (member.tier ? member.tier.name : null) { - case 'platinum-sponsor': + case 'Platinum Sponsor': addSponsor('platinum-sponsors', member.account, PlatinumSize); - case 'gold-sponsor': + case 'Gold Sponsor': addSponsor('gold-sponsors', member.account, GoldSize); - case 'silver-sponsor': + case 'Silver Sponsor': addSponsor('silver-sponsors', member.account, SilverSize); case 'backer': addSponsor('backers', member.account, BackerSize); diff --git a/typeclasses/bifoldable.html b/typeclasses/bifoldable.html index f4110d94e2..8cff27c825 100644 --- a/typeclasses/bifoldable.html +++ b/typeclasses/bifoldable.html @@ -338,7 +338,7 @@

s, acc) => acc.map(_ |+| s), (s, acc) => acc.map(_ |+| s) ) -// right: Eval[String] = cats.Eval$$anon$1@4c6ef4c5 +// right: Eval[String] = cats.Eval$$anon$1@62b4fe4 left === expected // res2: Boolean = true @@ -354,7 +354,7 @@

s, acc) => acc.map(_ |+| s), (s, acc) => acc.map(_ |+| s) ) -// reversedRight: Eval[String] = cats.Eval$$anon$1@5d861092 +// reversedRight: Eval[String] = cats.Eval$$anon$1@3e286c6c reversedRight.value === expected // res4: Boolean = false diff --git a/typeclasses/bifunctor.html b/typeclasses/bifunctor.html index b9bcac47cb..1cd0f08a4e 100644 --- a/typeclasses/bifunctor.html +++ b/typeclasses/bifunctor.html @@ -246,7 +246,7 @@

error => DomainError(error.getMessage), dateTime => dateTime.toEpochSecond ) -// res0: Either[DomainError, Long] = Right(value = 1727638230L) +// res0: Either[DomainError, Long] = Right(value = 1728152602L)

Bifunctor also defines a convenience function called leftMap, which is defined as follows:

def leftMap[A, B, C](fab: F[A, B])(f: A => C): F[C, B] = bimap(fab)(f, identity)

There is no rightMap however - use map instead. The reasoning behind this is that in Cats, the instances of diff --git a/typeclasses/bimonad.html b/typeclasses/bimonad.html index 524c8dffe4..90b91df6c2 100644 --- a/typeclasses/bimonad.html +++ b/typeclasses/bimonad.html @@ -263,7 +263,7 @@

override def tailRecM[A, B](a: A)(fn: A => NonEmptyList[Either[A, B]]): NonEmptyList[B] = ??? } -// nelBimonad: Bimonad[NonEmptyList] = repl.MdocSession$MdocApp$$anon$1@1da821b0 +// nelBimonad: Bimonad[NonEmptyList] = repl.MdocSession$MdocApp$$anon$1@101f7ec0

Note the equivalence:

nelBimonad.pure(true).extract === NonEmptyList.one(true).head
 // res0: Boolean = true
diff --git a/typeclasses/contravariant.html b/typeclasses/contravariant.html index d4f3002919..f049967a1f 100644 --- a/typeclasses/contravariant.html +++ b/typeclasses/contravariant.html @@ -246,7 +246,7 @@

implicit val showSalary: Show[Salary] = showMoney.contramap(_.size) -// showSalary: Show[Salary] = cats.Show$$anon$2$$Lambda$12805/0x00007f6e4429b928@232b8604 +// showSalary: Show[Salary] = cats.Show$$anon$2$$Lambda$15307/0x00007fea83995438@284cb248 Salary(Money(1000)).show // res0: String = "$1000" @@ -266,7 +266,7 @@

import scala.math.Ordered._ implicit val moneyOrdering: Ordering[Money] = Ordering.by(_.amount) -// moneyOrdering: Ordering[Money] = scala.math.Ordering$$anon$5@2b1863e9 +// moneyOrdering: Ordering[Money] = scala.math.Ordering$$anon$5@52877b54 Money(100) < Money(200) // res3: Boolean = true @@ -276,17 +276,17 @@

class A class B extends A val b: B = new B -// b: B = repl.MdocSession$MdocApp$B@444f250c +// b: B = repl.MdocSession$MdocApp$B@2ee08a07 val a: A = b -// a: A = repl.MdocSession$MdocApp$B@444f250c +// a: A = repl.MdocSession$MdocApp$B@2ee08a07 val showA: Show[A] = Show.show(a => "a!") -// showA: Show[A] = cats.Show$$$Lambda$12804/0x00007f6e4429b4b0@55da9d6f +// showA: Show[A] = cats.Show$$$Lambda$15306/0x00007fea83994fc0@6396896f val showB1: Show[B] = showA.contramap(b => b: A) -// showB1: Show[B] = cats.Show$$anon$2$$Lambda$12805/0x00007f6e4429b928@237e7243 +// showB1: Show[B] = cats.Show$$anon$2$$Lambda$15307/0x00007fea83995438@4d5ec84c val showB2: Show[B] = showA.contramap(identity[A]) -// showB2: Show[B] = cats.Show$$anon$2$$Lambda$12805/0x00007f6e4429b928@115f4bc3 +// showB2: Show[B] = cats.Show$$anon$2$$Lambda$15307/0x00007fea83995438@371f9b9e val showB3: Show[B] = Contravariant[Show].narrow[A, B](showA) -// showB3: Show[B] = cats.Show$$$Lambda$12804/0x00007f6e4429b4b0@55da9d6f +// showB3: Show[B] = cats.Show$$$Lambda$15306/0x00007fea83994fc0@6396896f

Subtyping relationships are "lifted backwards" by contravariant functors, such that if F is a lawful contravariant functor and B <: A then F[A] <: F[B], which is expressed by Contravariant.narrow.

diff --git a/typeclasses/eq.html b/typeclasses/eq.html index d8cf23cffa..759317a82e 100644 --- a/typeclasses/eq.html +++ b/typeclasses/eq.html @@ -257,7 +257,7 @@

Eq

implicit val eqFoo: Eq[Foo] = Eq.fromUniversalEquals -// eqFoo: Eq[Foo] = cats.kernel.Eq$$anonfun$fromUniversalEquals$2@58d2cf89 +// eqFoo: Eq[Foo] = cats.kernel.Eq$$anonfun$fromUniversalEquals$2@5bfc5dda Foo(10, "") === Foo(10, "") diff --git a/typeclasses/semigroup.html b/typeclasses/semigroup.html index bd6da831d2..f925681cef 100644 --- a/typeclasses/semigroup.html +++ b/typeclasses/semigroup.html @@ -269,23 +269,23 @@

import cats.Semigroup import cats.syntax.all._
Semigroup[Int]
-// res8: Semigroup[Int] = cats.kernel.instances.IntGroup@2f125634
+// res8: Semigroup[Int] = cats.kernel.instances.IntGroup@6a0a4003
 Semigroup[String]
-// res9: Semigroup[String] = cats.kernel.instances.StringMonoid@53ce2717
+// res9: Semigroup[String] = cats.kernel.instances.StringMonoid@3bd0b462

Instances for type constructors regardless of their type parameter such as List (++) and Set (union)...

Semigroup[List[Byte]]
-// res10: Semigroup[List[Byte]] = cats.kernel.instances.ListMonoid@7ee996c6
+// res10: Semigroup[List[Byte]] = cats.kernel.instances.ListMonoid@3bb480aa
 Semigroup[Set[Int]]
-// res11: Semigroup[Set[Int]] = cats.kernel.instances.SetSemilattice@5780470e
+// res11: Semigroup[Set[Int]] = cats.kernel.instances.SetSemilattice@262b384c
 
 trait Foo
 Semigroup[List[Foo]]
-// res12: Semigroup[List[Foo]] = cats.kernel.instances.ListMonoid@7ee996c6
+// res12: Semigroup[List[Foo]] = cats.kernel.instances.ListMonoid@3bb480aa

And instances for type constructors that depend on (one of) their type parameters having instances such as tuples (pointwise combine).

Semigroup[(List[Foo], Int)]
-// res13: Semigroup[(List[Foo], Int)] = cats.kernel.Monoid$$anon$2@6a9e083c
+// res13: Semigroup[(List[Foo], Int)] = cats.kernel.Monoid$$anon$2@1e197ed2

Example usage: Merging maps

Consider a function that merges two Maps that combines values if they share diff --git a/typeclasses/show.html b/typeclasses/show.html index ff1aa45e28..47fdcce781 100644 --- a/typeclasses/show.html +++ b/typeclasses/show.html @@ -229,7 +229,7 @@

Show

Most often, this is unwanted behaviour, as the standard implementation of toString on non case classes is mostly gibberish. Consider the following example:

(new {}).toString
-// res0: String = "repl.MdocSession$MdocApp$$anon$1@1f73b36f"
+// res0: String = "repl.MdocSession$MdocApp$$anon$1@41a57d10"

The fact that this code compiles is a design flaw of the Java API. We want to make things like this impossible, by offering the toString equivalent as a type class, instead of the root of the class hierarchy. In short, Show allows us to only have String-conversions defined for the data types we actually want.

@@ -245,12 +245,12 @@

Show

case class Person(name: String, age: Int) implicit val showPerson: Show[Person] = Show.show(person => person.name) -// showPerson: Show[Person] = cats.Show$$$Lambda$12804/0x00007f6e4429b4b0@11f15e94 +// showPerson: Show[Person] = cats.Show$$$Lambda$15306/0x00007fea83994fc0@27ea03a2 case class Department(id: Int, name: String) implicit val showDep: Show[Department] = Show.fromToString -// showDep: Show[Department] = cats.Show$$$Lambda$11848/0x00007f6e43fc4ca8@6b6162b0 +// showDep: Show[Department] = cats.Show$$$Lambda$14350/0x00007fea836332a8@3569af1d

This still may not seem useful to you, because case classes already automatically implement toString, while show would have to be implemented manually for each case class. Thankfully with the help of a small library called kittens a lot of type class instances including Show can be derived automatically!

Cats also offers Show syntax to make working with it easier.