Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Port to cats #25

Merged
merged 8 commits into from
Dec 19, 2017
Merged
Changes from 1 commit
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
20 changes: 8 additions & 12 deletions core/src/test/scala/GraphTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,16 @@ object GraphTests extends Properties("Graph") {
s"Paths different: cheapest = $cPath, shortest = $sPath" |: sPath === cPath
}

{
import GDecomp._
import org.scalacheck.ScalacheckShapeless._
import GDecomp._
import org.scalacheck.ScalacheckShapeless._

// TODO Clean these up, probably into a GraphCogen class. Keep the questionable ones hidden.
// TODO Clean these up, probably into a GraphCogen class. Keep the questionable ones hidden.
implicit def cogenMap[K: Cogen: Ordering, V: Cogen]: Cogen[Map[K, V]] =
Cogen.it(_.toVector.sortBy(_._1).iterator)
implicit def cogenContext[V: Cogen: Ordering, A: Cogen, B: Cogen: Ordering]: Cogen[Context[V, A, B]] =
Cogen[(V, GrContext[V, A, B])].contramap(c => c.vertex -> c.toGrContext)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are falsely getting flagged as unused in certain versions of Scala. I believe they will be unnecessary after a new release of scalacheck.

This is sloppy, but since it doesn't affect the public API, I'm content to live with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

cogenMap won't be necessary, but cogenContext will be because of the no-ordering assumption


implicit def cogenMap[K: Cogen: Ordering, V: Cogen]: Cogen[Map[K, V]] =
Cogen.it(_.toVector.sortBy(_._1).iterator)

implicit def cogenContext[V: Cogen: Ordering, A: Cogen, B: Cogen: Ordering]: Cogen[Context[V, A, B]] =
Cogen[(V, GrContext[V, A, B])].contramap(c => c.vertex -> c.toGrContext)

include(ComonadTests[({type λ[α] = GDecomp[N,α,Int]})#λ].comonad[Int, Int, Int].all)
}
include(ComonadTests[({type λ[α] = GDecomp[N,α,Int]})#λ].comonad[Int, Int, Int].all)

property("The shortest path through a graph should be the shortest path between all subpaths") = forAll {
(tpg: (Graph[N,Int,Int], LNode[N, Int], LNode[N, Int])) =>
Expand Down