Last active
August 29, 2015 14:13
-
-
Save alexarchambault/d591ad927984f01f221c to your computer and use it in GitHub Desktop.
LabelledGeneric and tags
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
info] Compiling 1 Scala source to /Users/alexandre/projects/shapeless/core/target/scala-2.11/classes... | |
[info] Running shapeless.examples.Test | |
Dummy(0) | |
[error] (run-main-9) java.lang.AbstractMethodError: shapeless.examples.Test$fresh$macro$4$1.from(Ljava/lang/Object;)Ljava/lang/Object; | |
java.lang.AbstractMethodError: shapeless.examples.Test$fresh$macro$4$1.from(Ljava/lang/Object;)Ljava/lang/Object; | |
at shapeless.examples.Test$.delayedEndpoint$shapeless$examples$Test$1(TCTag.scala:17) | |
at shapeless.examples.Test$delayedInit$body.apply(TCTag.scala:12) | |
at scala.Function0$class.apply$mcV$sp(Function0.scala:40) | |
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) | |
at scala.App$$anonfun$main$1.apply(App.scala:76) | |
at scala.App$$anonfun$main$1.apply(App.scala:76) | |
at scala.collection.immutable.List.foreach(List.scala:381) | |
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) | |
at scala.App$class.main(App.scala:76) | |
at shapeless.examples.Test$.main(TCTag.scala:12) | |
at shapeless.examples.Test.main(TCTag.scala) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:606) | |
[trace] Stack trace suppressed: run 'last shapeless-examples/compile:runMain' for the full output. | |
java.lang.RuntimeException: Nonzero exit code: 1 | |
at scala.sys.package$.error(package.scala:27) | |
[trace] Stack trace suppressed: run 'last shapeless-examples/compile:runMain' for the full output. | |
[error] (shapeless-examples/compile:runMain) Nonzero exit code: 1 | |
[error] Total time: 1 s, completed 12 janv. 2015 00:08:56 |
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 tag.@@ | |
import record._ | |
trait CustomTag | |
case class Dummy(i: Int @@ CustomTag) | |
case class DummyTagged(b: Boolean, i: Int @@ CustomTag) | |
object Test extends App { | |
val gen = Generic[Dummy] | |
val lgen = LabelledGeneric[Dummy] | |
Console.out println s"${gen from HList(tag[CustomTag](0))}" | |
Console.out println s"${lgen from Record(i=tag[CustomTag](0))}" | |
val gent = Generic[DummyTagged] | |
val lgent = LabelledGeneric[DummyTagged] | |
Console.out println s"${gent from HList(true, tag[CustomTag](0))}" | |
Console.out println s"${lgent from Record(b=true, i=tag[CustomTag](0))}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment