scala

Pimp my function in scala - applying implicit conversions on functions

I have some problems when I want to use implicit methods to convert a function to something else. I'm implementing a small DSL in Scala 2.8 for testing purposes. It should support various checks (assertions if you like) on instances. The whole DSL is a bit complex, but the following simplified example shows my problem: object PimpMyFun...

Simple-Build-Tool Error highligtning in JEdit

Hello All I currently experimenting with different lightweight texteditors for Scala development. JEdit seems to enable the user to make many tweaks. However im currently having a problem with its error and warning highlightning, via the Console plugin. It marks some lines as errors without actually being it. Thats why I wanted to ...

Convert a Scala Buffer to Java ArrayList

In my Scala function, i'm traversing a Java ArrayCollection, extracting specific elements which should form a new collection. At the end, it has to be a Java-ArrayList again, because i'm interacting with a Java Framework. My Code: // to make scala-style iterating over arraylist possible import scala.collection.JavaConversions._ // Arra...

Scala collection: totally unpredictable behaviours...

Have been pretty frustrated by Scala 2.8 collection behaviours. Here's the problem: I'm creating a Sudoku board. I'm labelling the cells from A1 to I9 (the letters being the rows and the digits being the columns). I want to get a list of units on the board, which is the 9 rows, the night columns, and the night quadrants. Here's my scala...

Unable to instantiate trait

I try to define a simple trait like this: scala> trait T { def p[A,B]: Map[A,B] } defined trait T scala> new T { def p = Map(0 -> 1) } <console>:7: error: object creation impossible, since method p in trait T of type [A,B]Map[A,B] is not defined new T { def p = Map(0 -> 1) } ^ How come? Thanks ...

How do I sign my ProGuard'ed Scala stand-alone JARs?

I've built a (command-line) application in Scala that I want to distribute as a standalone JAR. I'm building it with sbt: import sbt._ class Project(info: ProjectInfo) extends DefaultProject(info) with ProguardProject { override def parallelExecution = true override def mainClass: Option[String] = // whatever override def ...

What is Scala trying to tell me and how do I fix this? [ required: java.util.List[?0] where type ?0]

I am in the process of learning Scala and today I felt confident to introduce it to one of our projects. The application does a lot of JPA / Hibernate stuff and I started implementing one of the Java interfaces in Scala. All went well, until I tried to translate some unittest-code to Scala. I make a lot of use of Easymock, the code is ...

Use variable value as a Type in Scala

Hi Guys. I'm playing with serialisation, and hitting an issue with typing when reading back in from a file. My current plan of action is to use a filename prefix to suggest the correct type, then base the deserialisation on that type. (This may well be a "Very Bad Idea", so any suggestions otherwise would be most gratefully received!)...

Problem creating an executable jar from scala file.

I'm tryign to export my project as a jar with IntelliJ 9.0. My project compiles and runs with no problem in Intellij, but when I write it to a .jar and open it, it will show an error. My Main class is something like: package Main //Imports object Main{ def main(args: Array[String]) { println("Main: Hello, world!") //do stuf...

Scala, Charts and Google Visualisation API

Hi Guys, Those anyone know of a Scala Library for Graphs / Charts or an implementation of the Google Visualisation API. Cheers ...

Filtering tokens from Scala Parser Combinators

How do I filter the sequence of tokens coming from my Lexer to my Parser when using Scala parser combinators? Let me explain - suppose I have the fairly standard pattern of a Lexer (extending StdLexical) and a Parser (extending StdTokenParsers). The lexer turns a sequence of characters to a sequence of tokens, then the parser turns the ...

ProcessBuilder - Start another process / JVM in Scala - HowTo?

I already handled to start another VM in Java. See ProcessBuilder - Start another process / JVM - HowTo? For some reason, I can't manage to do the same in Scala. Here's my code object NewProcTest { def main(args :Array[String]) { println("Main") // val clazz = classOf[O3] val clazz = O4.getClass Proc.spawn(clazz, true...

In Scala, how can I subclass a Java class with multiple constructors?

Suppose I have a Java class with multiple constructors: class Base { Base(int arg1) {...}; Base(String arg2) {...}; Base(double arg3) {...}; } How can I extend it in Scala and still provide access to all three of Base's constructors? In Scala, a subclass can only call one of it's superclass's constructors. How can I work a...

Is there a way of creating an IdentityMap in scala 2.8

There used to be an IdentityHashMap in collection.jcl: is there a way of constructing the same thing in the new 2.8 collections library (perhaps with a bespoke equality-relation)? ...

Run scala unit test from command line separately with Maven

Well, Maven is too good, when talking about speed. But I want something that is more acceptable. Imagine I wrote a test org.fun.AbcTestCase In such TestCase, I include some JUnit / TestNG tests Now I want to run only this test case, said org.fun.AbcTestCase from command line. How can I do that? I know it's easy to do it within Eclipse o...

RemoteActor.select - result deterministic?

I wonder if there is any determinism when calling val delegate = RemoteActor.select(). I'm asking this, because I noticed that the program doesn't terminate, when I'm sending delegates over the net. Are there any other side effects, which depend on the delegate? Are there any rules, when RemoteActor.select will return the same delega...

Scala Remote Actors - Pitfalls

While writing Scala RemoteActor code, I noticed some pitfalls: RemoteActor.classLoader = getClass().getClassLoader() has to be set in order to avoid "java.lang.ClassNotFoundException" link doesn't always work due to "a race condition for which a NetKernel (the facility responsible for forwarding messages remotely) that backs a remote ...

range lock in java

I have a large array to be accessed by multiple thread. Single lock is not efficient enough.Is there a range lock class in java or scala? ...

Under what conditions is inferring Nothing desirable?

In my own code, and on numerous mailing list postings, I've noticed confusion due to Nothing being inferred as the least upper bound of two other types. The answer may be obvious to you*, but I'm lazy, so I'm asking you*: Under what conditions is inferring Nothing in this way the most desirable outcome? Would it make sense to hav...

Stream of readLines

I'm attempting to create an infinite stream of strings from readLine calls: import java.io.{BufferedReader, InputStreamReader} val in = new BufferedReader(new InputStreamReader(System in)) val input: Stream[String] = Stream.cons(in readLine, input) But it appears that the readLine call isn't being called lazily. Immediately after ente...