milessabin / shapeless

Generic programming for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support HList.diff for records

schlichtanders opened this issue · comments

import shapeless._
import shapeless.record._

val a = Record(x = 1)
val b = Record(x = 2)
a.diff(b)

is expected to work, I guess. however will throw the following error

error: type mismatch;
 found   : shapeless.::[shapeless.labelled.FieldType[shapeless.tag.@@[Symbol,String("x")],Int],shapeless.HNil]
    (which expands to)  shapeless.::[Int with shapeless.labelled.KeyTag[Symbol with shapeless.tag.Tagged[String("x")],Int],shapeless.HNil]
 required: shapeless.ops.hlist.Diff[shapeless.::[shapeless.labelled.FieldType[shapeless.tag.@@[Symbol,String("x")],Int],shapeless.HNil],?]
    (which expands to)  shapeless.ops.hlist.Diff[shapeless.::[Int with shapeless.labelled.KeyTag[Symbol with shapeless.tag.Tagged[String("x")],Int],shapeless.HNil],?]
       a.diff(b)
              ^

I am using shapeless version = "com.chuusai" %% "shapeless" % "2.3.3"
with Scala 2.11.12

That's not the API of diff. It works like this a.diff[B] - you pass a type not a value.