scala

Write table on the fly...

Hi, I have the following function, and I would like to write to the page instead of the println. How can I do that? I need a table with that information in my page, But I did't find any information about that, I saw how to write collections to the page, but I would rather prefer write to the page on the fly. Thanks in advance and I hop...

Sort ArrayBuffer[A] in scala?

I have an array in scala with the class "ArrayBuffer[Actor]", where Actor is a class that implements the "Ordered[Actor]" trait. How do I sort this array without coding it manually? I know there is an Object called Sorting, but it doesnt seem to work since ArrayBuffer doesn't implement/extend the right classes. How do I sort ArrayBuffe...

Is is possible to use Spring MVC with Groovy or Scala?

I wanted to know if it was possible to use Spring MVC with a dynamic language like Groovy or Scala. Or can Groovy only be run on Grails? Also if it is possible, is this something which people try often, or do they just stick to the framework traditionally used? ...

Can Scala be used to write GWT applications?

Can Scala be used to write GWT applications? (NOTE: Java/Scala novice here...) ...

Groovy, Scala maybe making my life easier?

I don't want to break any rules here but happy christmas everyone of you! In a silent hour an idea crossed my mind: Is it possible to replace any java coding which I use daily with groovy or scala? E.g. writing small webapps which include servlets/portlets etc. ...

Can I get AST from live scala code ?

I said "live code" because I mean not from text source files or source strings, but from partialFunctions / lambdas. (I know Ruby1.8's parseTree and C# linq can do it) consider a partialFunction f: val f = (i: Int, j: Int) => (i + j) * 2 I hope there is some tool works like this: getBodyAstFrom(f) //=> (Infix('*'), (Infix('+'), Id('...

Case classes with an upper type bound

I ran into a problem using case classes and parameterized types with an upper type bound. The Scala compiler tells me that it finds type DefaultEdge but requires Edge[Type]. I tried using something like case DefaultEdge[Type] but I get syntax errors. Here is my setup. I have a couple of edge case classes which correspond to different ty...

How to define column that is not actually related to another table by keys, but by keywords

I am using JPA to see how helpful it will be, rather than using straight SQL, and I realized today that one of my columns is incorrect. I have a playlist application. Each playlist has a title and a list of keywords that signify the songs to include. So, I may have this as one row, where there are three keywords. Exercise steady...

What's the point of using monads in an interpreter?

I recently discovered this little scala example called Simple interpreter using monads: object simpleInterpreter { case class M[A](value: A) { def bind[B](k: A => M[B]): M[B] = k(value) def map[B](f: A => B): M[B] = bind(x => unitM(f(x))) def flatMap[B](f: A => M[B]): M[B] = bind(f) } def unitM[A](a: A): M[A] = M(a...

Does Scala have introspection capable of something similar to Python's dir()?

Yes, I know it's considered lazy by the non-Pythonistas. The reason I ask is that documentation is still woefully lacking in many Scala libraries (e.g. Scala-dbc, but that's not all I'm looking at), and if I could see the attributes of an object/class at runtime, I could at least figure out what's available. Thanks. ...

String representation of objects as in Scala REPL

Is there a simple way to convert a Scala object to the string representation given in the REPL? For example, for Array(2, 3, 5), I'd like to get the string "Array(2, 3, 5)", and for Stream from 2, I'd like to get "Stream(2, ?)". ...

create a database with scala/lift and a simple interface to log in

Hi, I'm a beginner with scala/lift and POO. At first, i would like to create a database and a simple interface to log in (ID and password). Then create an application to allow the user to modify this database. My problem is: i didn't find anything (like a tutorial) to do something like that. Maybe somebody could help? ...

Compile Scala 2.8.x code with Apache Buildr

I have been struggling to get Buildr to compile my Scala 2.8 project and I was hoping someone might have figured this out already. Currently I have the standard HelloWorld application with a buildfile like the following: ENV['JAVA_HOME'] = 'C:\Program Files (x86)\Java\jdk1.6.0_17' ENV['SCALA_HOME'] = 'C:\scala-2.8.0.Beta1-RC6' define ...

What's the Future of Lift framework and current work being done?

I keep reading the developments being done on frameworks like Grails and other Java frameworks but not much of a buzz in the Lift camp. And also Lift 1.0 was announced long back. Is the community working on Lift framework? What are the future prospects of the framework? Is it better than Grails and other Java frameworks? (Groovy being le...

Declaring multiple variables in scala

I'd like to use on val to declare multiple variable like this: val a = 1, b = 2, c = 3 But for whatever reason, it's a syntax error, so I ended up using either: val a = 1 val b = 2 val c = 3 or val a = 1; val b = 2; val c = 3; I personally find both options overly verbose and kinda ugly. Is there a better option? Also, I know ...

Does it make sense to use a pool of Actors?

I'm just learning, and really liking, the Actor pattern. I'm using Scala right now, but I'm interested in the architectural style in general, as it's used in Scala, Erlang, Groovy, etc. The case I'm thinking of is where I need to do things concurrently, such as, let's say "run a job". With threading, I would create a thread pool and a...

How to eliminate stack trace when running Specs through SBT?

I have a Scala project that I'm using SBT and Specs on. When I run sbt test, it correctly runs my tests, but a failing test results in a huge stack trace. [info] == caravan.DependenciesSpec == [info] specifies [info] x Status should mirror single job org.specs.specification.FailureExceptionWithResult: 'caravan.Status(2)' is not eq...

Applying a function to a tuple in Scala

This should be an easy one. How do I apply a function to a tuple in Scala? Viz: scala> def f (i : Int, j : Int) = i + j f: (Int,Int)Int scala> val p = (3,4) p: (Int, Int) = (3,4) scala> f p :6: error: missing arguments for method f in object $iw; follow this method with `_' if you want to treat it as a partially applied function ...

Ant-Ivy-Scala Template: any suggestions on improvements?

I just created a template project for Scala using Ant and Apache Ivy. I want to get the communitie's input on any improvements to the Template so it can be improved. The Environment effectively consists of 3 files: build.xml ivy.xml ivysettings.xml running ant init will create all needed directories. I was wondering if there are an...

Pattern matching structural types in Scala

Why does this print wtf? Does pattern matching not work on structural types? "hello" match { case s: { def doesNotExist(i: Int, x: List[_]): Double } => println("wtf?") case _ => println("okie dokie") } ...