Skip to content

Instantly share code, notes, and snippets.

@folone
Last active December 19, 2015 23:59
Show Gist options
  • Save folone/6038517 to your computer and use it in GitHub Desktop.
Save folone/6038517 to your computer and use it in GitHub Desktop.
> shapeless-examples/console
[warn] Credentials file /home/folone/.ivy2/.credentials does not exist
[warn] Binary version (2.10) for dependency org.scala-lang#scala-library;2.10.2
[warn] in com.chuusai#shapeless_2.10.2;2.0.0-SNAPSHOT differs from Scala binary version in project (2.10.2).
[warn] Binary version (2.10) for dependency org.scala-lang#scala-compiler;2.10.2
[warn] in com.chuusai#shapeless_2.10.2;2.0.0-SNAPSHOT differs from Scala binary version in project (2.10.2).
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.2 (OpenJDK 64-Bit Server VM, Java 1.7.0_40).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import shapeless._
import shapeless._
scala> import nat._
import nat._
scala> import examples.FactorialExamples.Factorial._
import examples.FactorialExamples.Factorial._
scala> factorial(5)
res0: shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[...]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]...
scala> toInt(res0)
res1: Int = 120
scala> factorial(6)
res2: shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[...]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]...
scala> toInt(res2)
error:
while compiling: <console>
during phase: typer
library version: version 2.10.2
compiler version: version 2.10.2
reconstructed args: -language:higherKinds -language:implicitConversions -deprecation -feature -bootclasspath /usr/lib/jvm/java-7-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/netx.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/plugin.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk/jre/lib/jfr.jar:/usr/lib/jvm/java-7-openjdk/jre/classes:/home/folone/.sbt/boot/scala-2.10.2/lib/scala-library.jar -unchecked -Yrepl-sync -classpath /home/folone/workspace/shapeless/examples/target/scala-2.10.2/classes:/home/folone/workspace/shapeless/core/target/scala-2.10.2/classes:/home/folone/.sbt/boot/scala-2.10.2/lib/scala-compiler.jar:/home/folone/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.10.2.jar:/home/folone/.sbt/boot/scala-2.10.2/lib/scala-compiler.jar:/home/folone/.sbt/boot/scala-2.10.2/lib/jansi.jar:/home/folone/.sbt/boot/scala-2.10.2/lib/jline.jar:/home/folone/.sbt/boot/scala-2.10.2/lib/scala-reflect.jar
last tree to typer: Select(This(package shapeless), ToInt)
symbol: object ToInt in package shapeless (flags: <module> <triedcooking>)
symbol definition: object ToInt
tpe: shapeless.ToInt.type
symbol owners: object ToInt -> package shapeless
context owners: value res3 -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $read -> package $line24
== Enclosing template or block ==
Template( // val <local $iw>: <notype>
"java.lang.Object" // parents
ValDef(
private
"_"
<tpt>
<empty>
)
// 2 statements
DefDef( // def <init>: <?>
<method>
"<init>"
[]
List(Nil)
<tpt>
Block(
Apply(
super."<init>"
Nil
)
()
)
)
ValDef( // private[this] val res3: <?>
private <local>
"res3"
<tpt>
Apply(
"toInt"
"res2"
)
)
)
== Expanded type of tree ==
SingleType(pre = ThisType(package shapeless), object ToInt)
uncaught exception during compilation: java.lang.StackOverflowError
java.lang.StackOverflowError
at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$8.apply(Implicits.scala:402)
at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$8.apply(Implicits.scala:402)
at scala.reflect.internal.Types$FilterTypeCollector.traverse(Types.scala:4966)
at scala.reflect.internal.Types$TypeTraverser.apply(Types.scala:4342)
at scala.reflect.internal.Types$TypeTraverser.apply(Types.scala:4340)
at scala.collection.immutable.List.loop$1(List.scala:170)
at scala.collection.immutable.List.mapConserve(List.scala:186)
at scala.reflect.internal.Types$TypeMap.mapOver(Types.scala:4176)
...
at scala.reflect.internal.Types$FilterTypeCollector.traverse(Types.scala:4967)
at scala.reflect.internal.Types$TypeTraverser.apply(Types.scala:4342)
That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]
Abandoning crashed session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment