Last active
April 20, 2017 20:08
-
-
Save jferris/051f85fee9da2018a299a183738db35d to your computer and use it in GitHub Desktop.
Reproduction for Shapeless Issue: Can't Comap a type with two type parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shapeless._ | |
import ops.hlist._ | |
case class Wrap2[T, U](t: T, u: U) | |
class WrapTest[T, WL <: HList, L <: HList] { | |
def unwrap | |
(wrapped: WL) | |
(implicit comapped: Comapped.Aux[WL, ({ type l[U] = Wrap2[T, U] })#l, L]) | |
= true | |
} | |
object WrapTest { | |
def main: Unit = { | |
val wrapped = Wrap2[Int, String](1, "one") :: | |
Wrap2[Int, Boolean](2, true) :: | |
HNil | |
new WrapTest[ | |
Int, | |
Wrap2[Int, String] :: Wrap2[Int, Boolean] :: HNil, | |
String :: Boolean :: HNil | |
].unwrap(wrapped) | |
// On this line: | |
// could not find implicit value for parameter comapped: | |
// shapeless.ops.hlist.Comapped.Aux[shapeless.::[Wrap2[Int,String], | |
// shapeless.::[Wrap2[Int,Boolean],shapeless.HNil]],[U]Wrap2[Int,U], | |
// shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]]] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shapeless._ | |
import ops.hlist._ | |
case class Wrap2[T, U](t: T, u: U) | |
class Wrap1[T] { | |
type W[U] = Wrap2[T, U] | |
} | |
class Wrap2Test[T, WL <: HList, L <: HList] { | |
def unwrap(wrap1: Wrap1[T], wrapped: WL)(implicit comapped: Comapped.Aux[WL, | |
wrap1.W, | |
L]) = true | |
} | |
object Wrap2Test { | |
def main: Unit = { | |
val wrap1 = new Wrap1[Int] | |
val wrapped = Wrap2[Int, String](1, "one") :: | |
Wrap2[Int, Boolean](2, true) :: | |
HNil | |
new Wrap2Test[ | |
Int, | |
wrap1.W[String] :: wrap1.W[Boolean] :: HNil, | |
String :: Boolean :: HNil | |
].unwrap(wrap1, wrapped) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment