Created
May 19, 2016 21:36
-
-
Save nightscape/63f475338968457bf1b5c952fb2c70bb to your computer and use it in GitHub Desktop.
Trying to apply shapeless LiftAll instances to an HList
This file contains hidden or 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.LiftAll | |
import shapeless._ | |
import syntax.singleton._ | |
import shapeless.ops.hlist.ZipWithKeys | |
case class SingletonOf[T, U](value: U) | |
object SingletonOf { | |
implicit def mkSingletonOf[T <: AnyRef](implicit t: T): SingletonOf[T, t.type] = SingletonOf(t) | |
} | |
trait Showable[T] { | |
def show(t: T): String | |
} | |
object Showable { | |
implicit def stringShowable = new Showable[String] { | |
def show(t: String) = s"String: $t" | |
} | |
} | |
def test[L <: HList, U <: { type Out <: HList }](l: L)( | |
implicit | |
zippable: ZipWithKeys[L, U#Out], | |
showable: LiftAll[Showable, L], | |
allShowable: SingletonOf[LiftAll[Showable, L], U] | |
) = | |
showable.instances.asInstanceOf[U#Out].zipWithKeys(l) | |
test("foo" :: HNil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment