Skip to content

HList example for DiffShow #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions test/Main.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ai.x.diff._
import shapeless._
import scala.collection.immutable.SortedMap
sealed trait Parent
case class Bar( s: String, i: Int ) extends Parent
Expand Down Expand Up @@ -90,6 +91,28 @@ object Main extends App {
)
}

{
implicit def HListDiffShow: DiffShow[HList] = new DiffShow[shapeless.HList] {
def show(t: HList) = t.toString
def diff(left: HList, right: HList) = if (left == right) Identical(left) else Different(left, right)
override def diffable(left: HList, right: HList) = left.runtimeLength == right.runtimeLength
}

println(
DiffShow.diff(
"abcd" :: 123 :: 'c' :: HNil,
"abcd" :: 123 :: 'c' :: HNil
)
)

println(
DiffShow.diff(
"abcd" :: 123 :: 'c' :: HNil,
"abcd" :: 125 :: 'b' :: HNil
)
)
}

/*

//import pprint.Config.Defaults._
Expand Down