scala

Groovy / Scala / Java under the hood

I used Java for like 6-7 years, then some months ago I discovered Groovy and started to save a lot of typing.. then I wondered how certain things worked under the hood (because groovy performance is really poor) and understood that to give you dynamic typing every Groovy object is a MetaClass object that handles all the things that the J...

How to make a Scala Applet whose Applet class is a singleton?

Hi, I don't know if a solution exists but it would be highly desirable. I'm making a Scala Applet, and I want the main Applet class to be a singleton so it can be accessed elsewhere in the applet, sort of like: object App extends Applet { def init { // do init here } } Instead I have to make the App class a normal instantiatab...

Scala XML: create a node not using literals

How can I create a node in Scala without using literals? What I need is to set the node tag name in runtime, for example: var tag = "post" var content = "234" How can I get a node <post>234</post>? ...

Would it make sense to have a separate Scala library in Android market?

As far as I understand it is necessary for people using Scala for Android applications to bundle the Scala classes they used with their application. Considering this adds hundreds of kilobytes to each Scala app redundantly, would it be possible to build a Scala library which can be delivered over the market, so app writers can just depe...

How do I implement a collection in Scala 2.8?

In trying to write an API I'm struggling with Scala's collections in 2.8(.0-beta1). Basically what I need is to write something that: adds functionality to immutable sets of a certain type where all methods like filter and map return a collection of the same type without having to override everything (which is why I went for 2.8 in th...

noClassDefFoundError using Scala Plugin for Eclipse

I successfully implemented and ran several Scala tutorials in Eclipse using the Scala plugin. Then suddenly I tried to compile and run an example, and this error came up: Exception in thread "main" java.lang.NoClassDefFoundError: hello/HelloWorld Caused by: java.lang.ClassNotFoundException: hello.HelloWorld at java.net.URLClassLoader$1...

Equivalent of public static final fields in Scala

I'm learning Scala, and I can't figure out how to best express this simple Java class in Scala: public class Color { public static final Color BLACK = new Color(0, 0, 0); public static final Color WHITE = new Color(255, 255, 255); public static final Color GREEN = new Color(0, 0, 255); private final int red; private fina...

Scala Actors with Java interop to underlying COM libraries

I'm working on a JVM project which uses ESRI components (COM based, wrapped with JIntegra.) The client has requested the JAR files we produce work on the JVM and be accessible to Java code. I'd like to use Scala but I'm worried about how well the library will play with Scala's actors. Particularly I'm worried about the different mecha...

Is there a way to use pre-existing JSP Tag libraries within the Lift framework (e.g. via snippets)?

Hi, I'm fairly new to Lift/Scala but like the ideas of less code writing and function passing etc. I've had a brief look at the Lift web framework but was wondering if it is at all possible to leverage pre-existing JSP Tag libraries, ideally while being able to still place/mix with Lift's snippet tags? As Scala is able to utilise norm...

DocBook sources of "Starting with Lift"

By the looks of it, I wouldn't be surprised if "Starting with Lift" has been created from DocBook. I looked in Lift's Git repositories, but I haven't been able to find the source DocBook documents. So, is it really based on DocBook? And if it is, is it available from some public repository? ...

Function syntax puzzler in scalaz

Following watching Nick Partidge's presentation on deriving scalaz, I got to looking at this example, which is just awesome: import scalaz._ import Scalaz._ def even(x: Int) : Validation[NonEmptyList[String], Int] = if (x % 2 ==0) x.success else "not even: %d".format(x).wrapNel.fail println( even(3) <|*|> even(5) ) //prints: Failu...

Scala libraries and frameworks

Each technology is powerful with libraries and frameworks, written for it. I understand, that Scala is able to use libraries and frameworks, written for Java. But there are already some frameworks, written for Scala in Scala. Like, for example: Lift Framework ScalaTest Scalaz Do you know any more great libraries and frameworks for Sc...

How can I define an anonymous generic Scala function?

Let's say I have this: val myAnon:(Option[String],String)=>String = (a:Option[String],defVal:String) => { a.getOrElse(defVal) } Don't mind what the function does. Is there anyway of making it generic, so I can have an Option[T]? ...

Scala and Java Real-Time System

Just wondering if anybody has run Scala app or web-app on Java Real-Time system? I assume because scala is bytecode compatible with regular JVM, then it should not take much effort to run it on a Real Time JVM such as Sun Java Real-Time System ? Edit: As per http://stackoverflow.com/questions/2564575/sun-java-realtime-system-on-virtual...

How are Scala traits compiled into Java bytecode?

I have played around with Scala for a while now, and I know that traits can act as the Scala equivalent of both interfaces and abstract classes. Recently I've been wondering how exactly traits are compiled into Java bytecode. I found some short explanations that stated traits are compiled exactly like Java interfaces when possible, and...

Scalaz Kleisli question

There is a trait called Kleisli in the scalaz library. Looking at the code: import scalaz._ import Scalaz._ type StringPair = (String, String) val f: Int => List[String] = (i: Int) => List((i |+| 1).toString, (i |+| 2).toString) val g: String => List[StringPair] = (s: String) => List("X" -> s, s -> "Y") val k = kleisli(f) >=> k...

Scalaz: request for use case for Cokleisli composition

This question isn't meant as flame-bait! As it might be apparent, I've been looking at Scalaz recently. I'm trying to understand why I need some of the functionality that the library provides. Here's something: import scalaz._ import Scalaz._ type NEL[A] = NonEmptyList[A] val NEL = NonEmptyList I put some println statements in my func...

How do I "get" a Scala case object from Java?

I created a hierarchy of case objects in Scala that looks like the following: package my.awesome.package sealed abstract class PresetShapeType(val displayName: String) case object AccelerationSensor extends PresetShapeType("Acceleration Sensor") case object DisplacementSensor extends PresetShapeType("Displacement Sensor") case object ...

What are the best features of Scala?

I can say that I really love Scala but now I would like to know the features you cannot live without when working with Scala? What about Scala 2.8? ...

Why does one of these statements compile in Scala but not the other?

(Note: I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty simple -- creating a map based on the values in a simple, 2-column CSV file -- and I've completed it easily enough, but I'm perplexed at why my first attempt didn't compile. Here's the code: // Returns Iterator[String] private def getLines = Source.fromFile(csvFil...