Skip to content

Commit

Permalink
added hash conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed Dec 18, 2017
1 parent b32a7c7 commit 0f34e7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/hash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cats
package instances


trait HashInstances {
trait HashInstances extends kernel.instances.HashInstances {

implicit val catsContravariantForHash: Contravariant[Hash] =
new Contravariant[Hash] {
Expand Down
6 changes: 6 additions & 0 deletions kernel/src/main/scala/cats/kernel/Hash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ object Hash extends HashFunctions[Hash] {
}

}

trait HashToHashingConversion {
implicit def catsKernelHashToHashing[A](implicit ev: Hash[A]): Hashing[A] = new Hashing[A] {
override def hash(x: A): Int = ev.hash(x)
}
}
1 change: 1 addition & 0 deletions kernel/src/main/scala/cats/kernel/instances/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ trait AllInstances
with DurationInstances
with FloatInstances
with FunctionInstances
with HashInstances
with IntInstances
with ListInstances
with LongInstances
Expand Down
6 changes: 6 additions & 0 deletions kernel/src/main/scala/cats/kernel/instances/hash.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cats.kernel
package instances

trait HashInstances extends HashToHashingConversion

object hash extends HashInstances

0 comments on commit 0f34e7c

Please sign in to comment.