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

Added EmptyK instance for Map #3677

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion alleycats-core/src/main/scala/alleycats/Empty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Empty extends EmptyInstances0 {
def apply[A](a: => A): Empty[A] =
new Empty[A] { lazy val empty: A = a }

def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T]
implicit def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like kittens can't handle this: typelevel/kittens#299


/* ======================================================================== */
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */
Expand Down
6 changes: 5 additions & 1 deletion alleycats-core/src/main/scala/alleycats/EmptyK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.annotation.implicitNotFound
}
}

object EmptyK {
object EmptyK extends EmptyKInstances0 {

/* ======================================================================== */
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */
Expand Down Expand Up @@ -59,3 +59,7 @@ object EmptyK {
/* ======================================================================== */

}

private[alleycats] trait EmptyKInstances0 {
implicit def alleycatsEmptyKForMap[K]: EmptyK[Map[K, *]] = alleycats.std.map.alletcatsStdMapEmptyK[K]
}
6 changes: 6 additions & 0 deletions alleycats-core/src/main/scala/alleycats/std/map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ trait MapInstances {
}
}) { chain => chain.foldLeft(Map.empty[K, B]) { case (m, (k, b)) => m.updated(k, b) } }
}

implicit def alletcatsStdMapEmptyK[K]: EmptyK[Map[K, *]] =
new EmptyK[Map[K, *]] {
def empty[A]: Map[K, A] = Map.empty[K, A]
}

}