4

I'm very new to Scala, and have been looking at the shapeless package to provide HList-like operations for Scala's tuples.

I'm running scala 2.10.5, and I've successfully installed the package (version 2.2.0-RC6) as well as all dependencies.

When I try to run the following example (from the shapeless feature overview) in the REPL,

    scala> import shapeless._; import syntax.std.tuple._
    scala > (23, "foo", true).head

I get the following error message:

<console>:17: error: could not find implicit value for parameter c: shapeless.ops.tuple.IsComposite[(Int, String, Boolean)]
          (23, "foo", true).head

I'll bet this is a silly error on my part, and I've been digging through a lot of forums on this.

What am I missing?

Thanks in advance for your help.

plmedici
  • 61
  • 3

1 Answers1

3

You're likely missing the macro paradise dependency. Without that, I get the same error you see, with it, the example compiles.

Your build.sbt should include something like this:

libraryDependencies ++= Seq(
  "com.chuusai" %% "shapeless" % "2.2.0-RC6",
  compilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full)
)
Ryan
  • 7,227
  • 5
  • 29
  • 40
  • Thanks for your response. I should've mentioned I'm actually using Maven to build my project in Eclipse (rather than sbt). I had already tried adding the macro_paradise plugin (both as a Xplugin argument and by directly adding the dependency to the POM file). Neither worked. – plmedici May 26 '15 at 22:18
  • Did you add it as a compiler plugin? http://stackoverflow.com/questions/19086241/enabling-the-macro-paradise-scala-compiler-plugin-in-maven-projects – Ryan May 26 '15 at 22:19
  • Yep. Followed the instructions in that post. – plmedici May 26 '15 at 22:23
  • That post mentions a very old version of the paradise plugin (it even has outdated group and artefact ids) ... have you updated them to use the ids and version mentioned in the shapeless documentation? – Miles Sabin May 27 '15 at 06:46