scala-2.11

How can I handle a > 22 column table with Slick using nested tuples or HLists?

柔情痞子 提交于 2019-11-29 11:09:49
问题 I'm new to Scala (using 2.10) and Slick (using 2.0-M2). I see that one of the ways to get around the 22 column limit for tables in Slick is to use nested tuples. I can't figure out how to do that, despite finding this partial code on GitHub. Current dev branch Scala (2.11-M5) supports case classes with more than 22 elements, but not tuples with arity > 22. And Slick is not yet distributed for Scala 2.11 pre-releases. How can I define a 33 column table (and have it work with all Slick's

Scala macro to print code?

大兔子大兔子 提交于 2019-11-29 07:32:31
I want to do something like this: def assuming[A](condition: => Boolean)(f: => A): A = { require(condition, /* print source-code of condition */) f } Sample usage: def fib(n: Int) = n match { // yes, yes, I know this is not efficient case 0 => 0 case 1 => 1 case i => assuming(i > 0) { fib(i-1) + fib(i-2) } } Now, for example, if you call fib(-20) , I want it to throw an exception with a message like Assertion failed: -20 > 0 or Assertation failed: i > 0 Dude, isn't an assert macro one of the basic use cases you implement to learn how to use macros? Well, that's what I thought, too. By "glean

How to use JSR-223 to get Scala interpreter in sbt console?

旧街凉风 提交于 2019-11-29 04:51:06
In the sbt console, sbt version 0.13.5, Scala version 2.11.1, I can get javax.script.ScriptEngine for Scala: scala> val engine = new javax.script.ScriptEngineManager().getEngineByName("scala") engine: javax.script.ScriptEngine = scala.tools.nsc.interpreter.IMain@bf78a9 However, I can't use it: scala> engine.eval("3") [init] error: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar(java/lang/Object.class) Failed to initialize compiler: object scala in compiler mirror not found. ** Note that as of 2.8

Trying to cross compile a project to Scala 2.11 fails with “error while loading Object, Missing dependency 'object scala in compiler mirror'”

ⅰ亾dé卋堺 提交于 2019-11-28 11:57:44
I'm trying to compile my project to Scala 2.10 and 2.11 so that I can release versions for both scala versions, but every time I try to do it it fails with the following message: #( 04/26/14@ 7:40 )( mauricio@Mauricios-MacBook-Pro ):~/projects/scala/postgresql-netty@scala-2.11✔ sbt compile [info] Loading project definition from /Users/mauricio/projects/scala/postgresql-netty/project [info] Set current project to db-async-base (in build file:/Users/mauricio/projects/scala/postgresql-netty/) [info] Compiling 61 Scala sources and 1 Java source to /Users/mauricio/projects/scala/postgresql-netty/db

How to use JSR-223 to get Scala interpreter in sbt console?

99封情书 提交于 2019-11-27 18:39:19
问题 In the sbt console, sbt version 0.13.5, Scala version 2.11.1, I can get javax.script.ScriptEngine for Scala: scala> val engine = new javax.script.ScriptEngineManager().getEngineByName("scala") engine: javax.script.ScriptEngine = scala.tools.nsc.interpreter.IMain@bf78a9 However, I can't use it: scala> engine.eval("3") [init] error: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar(java/lang/Object.class

Dynamically compiling scala class files at runtime in Scala 2.11

人走茶凉 提交于 2019-11-27 12:30:21
I have the following code that works in Scala 2.10 to compile external classes at runtime in Scala /** * Compile scala files and keep them loaded in memory * @param classDir Directory storing the generated scala files * @throws IOException if there is problem reading the source files * @return Classloader that contains the compiled external classes */ @throws[IOException] def compileFiles(classDir: String): AbstractFileClassLoader = { val files = recursiveListFiles(new File(classDir)) .filter(_.getName.endsWith("scala")) println("Loaded files: \n" + files.mkString("[", ",\n", "]")) val

Trying to cross compile a project to Scala 2.11 fails with “error while loading Object, Missing dependency 'object scala in compiler mirror'”

谁说胖子不能爱 提交于 2019-11-27 06:38:14
问题 I'm trying to compile my project to Scala 2.10 and 2.11 so that I can release versions for both scala versions, but every time I try to do it it fails with the following message: #( 04/26/14@ 7:40 )( mauricio@Mauricios-MacBook-Pro ):~/projects/scala/postgresql-netty@scala-2.11✔ sbt compile [info] Loading project definition from /Users/mauricio/projects/scala/postgresql-netty/project [info] Set current project to db-async-base (in build file:/Users/mauricio/projects/scala/postgresql-netty/)