Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First two missing instances #3380

Merged
merged 4 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ private[cats] trait ScalaVersionSpecificTraverseFilterInstances {
cats.instances.stream.catsStdTraverseFilterForStream
}

private[cats] trait ScalaVersionSpecificAlignInstances
private[cats] trait ScalaVersionSpecificAlignInstances {
implicit def catsAlignForStream: Align[Stream] =
cats.instances.stream.catsStdInstancesForStream
}
2 changes: 2 additions & 0 deletions kernel/src/main/scala/cats/kernel/Semigroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ private[kernel] trait MonoidInstances extends BandInstances {
cats.kernel.instances.function.catsKernelMonoidForFunction0[A]
implicit def catsKernelMonoidForFunction1[A, B: Monoid]: Monoid[A => B] =
cats.kernel.instances.function.catsKernelMonoidForFunction1[A, B]
implicit def catsKernelMonoidForMap[K, V: Semigroup]: Monoid[Map[K, V]] =
cats.kernel.instances.map.catsKernelStdMonoidForMap[K, V]
implicit def catsKernelMonoidForSortedMap[K: Order, V: Semigroup]: Monoid[SortedMap[K, V]] =
cats.kernel.instances.sortedMap.catsKernelStdMonoidForSortedMap[K, V]
implicit def catsKernelMonoidForEither[A, B: Monoid]: Monoid[Either[A, B]] =
Expand Down
9 changes: 8 additions & 1 deletion tests/src/test/scala/cats/tests/MapSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package cats.tests

import cats.{Align, FlatMap, FunctorFilter, MonoidK, Semigroupal, Show, UnorderedTraverse}
import cats.arrow.Compose
import cats.instances.all._
import cats.kernel.{CommutativeMonoid, Monoid}
import cats.kernel.instances.StaticMethods.wrapMutableMap
import cats.kernel.laws.discipline.{CommutativeMonoidTests, HashTests, MonoidTests}
import cats.laws.discipline.{
AlignTests,
ComposeTests,
Expand Down Expand Up @@ -41,6 +42,12 @@ class MapSuite extends CatsSuite {
checkAll("Map[Int, Int]", AlignTests[Map[Int, *]].align[Int, Int, Int, Int])
checkAll("Align[Map]", SerializableTests.serializable(Align[Map[Int, *]]))

checkAll("Hash[Map[Int, String]]", HashTests[Map[Int, String]].hash)
checkAll("CommutativeMonoid[Map[String, Int]]", CommutativeMonoidTests[Map[String, Int]].commutativeMonoid)
checkAll("CommutativeMonoid[Map[String, Int]]", SerializableTests.serializable(CommutativeMonoid[Map[String, Int]]))
checkAll("Monoid[Map[String, String]]", MonoidTests[Map[String, String]].monoid)
checkAll("Monoid[Map[String, String]]", SerializableTests.serializable(Monoid[Map[String, String]]))

test("show isn't empty and is formatted as expected") {
forAll { (map: Map[Int, String]) =>
map.show.nonEmpty should ===(true)
Expand Down
1 change: 0 additions & 1 deletion tests/src/test/scala/cats/tests/StreamSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats.tests

import cats.{Align, Alternative, CoflatMap, Monad, Semigroupal, Traverse, TraverseFilter}
import cats.data.ZipStream
import cats.instances.all._
import cats.laws.discipline.{
AlignTests,
AlternativeTests,
Expand Down