I was told that Scala 3 tuple behave like shapeless HList in Scala 2, so I did a simple experiment:
val tuple = (1, "String", 1.1)
val _: *:[Int, *:[String, Double]] = tuple // not working
val _: *:[Double, *:[String, Int]] = tuple // not working
either one of them should be working based on HList definition, how did this happen?
Full error:
[Error] /home/peng/git/dottyspike/src/main/scala/com/tribbloids/spike/dotty/NewTuple.scala:15:42: Found: (tuple : (Int, String, Double))
Required: Int *: String *: Double
Explanation
===========
Tree: tuple
I tried to show that
(tuple : (Int, String, Double))
conforms to
Int *: String *: Double
but none of the attempts shown below succeeded:
==> (tuple : (Int, String, Double)) <: Int *: String *: Double class dotty.tools.dotc.core.Types$CachedTermRef class dotty.tools.dotc.core.Types$CachedAppliedType
==> (Int, String, Double) <: Int *: String *: Double class dotty.tools.dotc.core.Types$CachedAppliedType class dotty.tools.dotc.core.Types$CachedAppliedType
==> (String, Double) <: String *: Double class dotty.tools.dotc.core.Types$CachedAppliedType class dotty.tools.dotc.core.Types$CachedAppliedType
==> Double *: EmptyTuple.type <: Double class dotty.tools.dotc.core.Types$CachedAppliedType class dotty.tools.dotc.core.Types$CachedTypeRef = false
The tests were made under the empty constraint
[Error] /home/peng/git/dottyspike/src/main/scala/com/tribbloids/spike/dotty/NewTuple.scala:17:42: Found: (tuple : (Int, String, Double))
Required: Double *: String *: Int
Explanation
===========
Tree: tuple
I tried to show that
(tuple : (Int, String, Double))
conforms to
Double *: String *: Int
but none of the attempts shown below succeeded:
==> (tuple : (Int, String, Double)) <: Double *: String *: Int class dotty.tools.dotc.core.Types$CachedTermRef class dotty.tools.dotc.core.Types$CachedAppliedType
==> (Int, String, Double) <: Double *: String *: Int class dotty.tools.dotc.core.Types$CachedAppliedType class dotty.tools.dotc.core.Types$CachedAppliedType
==> Int <: Double class dotty.tools.dotc.core.Types$CachedTypeRef class dotty.tools.dotc.core.Types$CachedTypeRef = false
The tests were made under the empty constraint
two errors found
Found the correct definition: