Sebastian M Cheung | 24 Jul 16:35 2015

How to improve distributed app in Scala?

What are best practices in improving distributed Scala app performances?


--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sebastian M Cheung | 23 Jul 21:15 2015

Why after updating Array element I still get old array values?

Why after updating Array element I still get old array values?

var compactWay = Array("I", "like", "this", "way")>compactWay: Array[String] = Array(I, like, this, way)
compactWay(0) = "We"
println(compactWay.mkString(" "))>We like this way res3: Unit = ()
var secondList = Array("Something else")var thirdList = compactWay++secondList>thirdList: Array[String] = Array(I, like, this, way, Something else)
(expecting to see Array(We, like, this, way, Something else)

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sebastian M Cheung | 23 Jul 19:36 2015

Why cannot do var x,y,z = 0 in Intellij worksheet?

This is ok in .scala file:

var x, y, z = 0

but not in WorkSheet?

Error:(1, 6) constructor cannot be instantiated to expected type;
 found   : (T1, T2)
 required: Int
var (x,y) = { 0;};}
    ^

Also enabling ShowLine Numbers in WorkSheet only temporarily makes line numbers appear. As soon
as clicking anywhere in WorkSheet area line numbers disappear again?

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
杨博 | 14 Jul 14:46 2015
Picon

Each, a maco library that creates monadic expression, released

Hello, all,

I am glad to announce Each, a new library that converts native imperative syntax to scalaz's monadic expression.

Each allows you create monadic expression in a pretty simple way.

import com.thoughtworks.each.Monadic._ import scalaz.std.scalaFuture._ // Returns a Future of the sum of the length of each string in each parameter Future, // without blocking any thread. def concat(future1: Future[String], future2: Future[String]): Future[Int] = monadic[Future] { future1.each.length + future2.each.length }

import com.thoughtworks.each.Monadic._ import scalaz.std.option._ def plusOne(intOption: Option[Int]) = monadic[Option] { intOption.each + 1 } assertEquals(None, plusOne(None)) assertEquals(Some(16), plusOne(Some(15)))

import com.thoughtworks.each.Monadic._ import scalaz.std.list._ def plusOne(intSeq: List[Int]) = monadic[List] { intSeq.each + 1 } assertEquals(Nil, plusOne(Nil)) assertEquals(List(16), plusOne(List(15))) assertEquals(List(16, -1, 10), plusOne(List(15, -2, 9))
We also provided a generic monad implementation for all types that support for comprehension. The ComprehensionImplicits is able to implicitly create Seq monad, Set monad, Vector monad, etc.
import com.thoughtworks.each.ComprehensionImplicits._ import com.thoughtworks.each.Monadic._ def plusOne(intSeq: Seq[Int]) = monadic[Seq] { intSeq.each + 1 } assertEquals(Seq.empty, plusOne(Seq.empty)) assertEquals(Seq(16), plusOne(Seq(15))) assertEquals(Seq(16, -1, 10), plusOne(Seq(15, -2, 9)))

Each is like Effectful, except we support fully-featured Scala expressions in our monadic block, while Effectful only supports a subset of Scala expressions.


Thanks to all contributors in ThoughtWorks Xi'an office.
Cheers,
--
杨博 (Yang Bo)

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Phillips | 13 Jul 22:09 2015
Picon

Are Errors in a Future body rethrown, as per the documentation?

Hi all

With regard to the handling of Errors, the "Futures and Promises" documentation [1] states:

ExecutionException - stored when the computation fails due to an unhandled InterruptedException, Error or a scala.util.control.ControlThrowable. In this case the ExecutionException has the unhandled exception as its cause. These exceptions are rethrown in the thread executing the failed asynchronous computation.

Is this latter statement true in general, e.g. also if you supply your own ExecutionContext? Or does it depend on the ExecutionContext implementation?

In this example at least, nothing seems to be rethrown (or passed to reportFailure, for that matter):

Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_40).

import scala.concurrent.Future
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success}

implicit object SameThreadExecutionContext extends ExecutionContext {
  override def execute(runnable: Runnable): Unit = {
    println("DEBUG: running " + runnable)
    runnable.run()
  }
  override def reportFailure(t: Throwable): Unit = ??? // never called?
}

scala> Future { throw new Error("bang!") }.value
DEBUG: running scala.concurrent.impl.Future$PromiseCompletingRunnable <at> 887b5d0
res1: Option[scala.util.Try[Nothing]] = Some(Failure(java.util.concurrent.ExecutionException: Boxed Error))

Am I missing something or misreading the docs here?

Regards

ap

[1] http://docs.scala-lang.org/overviews/core/futures.html#exceptions

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seth Tisue | 13 Jul 21:06 2015
Picon

`new Foo` vs `new Foo()`

Is there consensus on this? Not sure whether to merge.

https://github.com/scala/scala.github.com/pull/344

Seth

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Arun Nair | 11 Jul 18:47 2015
Picon

Tutorial on building a Restful Scala Web service using Eclipse luna

Hi,
I am looking for a Tutorial on building a Restful Scala Web service using Eclipse luna.  I am fairly new to Scala.

-Arun

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Aravindh S | 11 Jul 16:40 2015

Getting java constructor parameter names via scala reflection

Hi,
 I am trying to get the names of constructor parameters of a java class using scala reflection. I have the following:
Tender.java
public class Tender {
public String name;
public int age;

public Tender(String name,int age){
this.name = name;

this.age = age;
}
}

Program.scala
def classAccessors[T: TypeTag] = typeOf[T].members.head.asMethod.paramLists

private val symbols = classAccessors[Tender]

I am getting the value of symbols as List(List(value x$1, value x$2))
I want the actual names viz `name` & `age` rather than x$1 & x$2. Is there any way to accomplish this?


Thanks
Aravindh.S

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
mar | 10 Jul 01:18 2015
Picon

Overloading methods with multiple parameter lists makes for "syntactic mismatch"

The following compiles without warnings:

object X { def a(x: Int) = x def a(x: Int)(y: Int) = x + y }

Actually trying to use either method gives me a compilation error even though, in my mind, there is no ambiguity: X.a(1) without curryscore would be the first one whereas X.a(1)(2) is the second.

Defining a such that implicit val zero = 0; def a(x: Int)(implicit y: Int) = x + y is a less-than-optimal workaround but what strikes me is that in this case Scala is able to figure out the signature when explicitly providing the second parameter item. Why is it eagerly failing in the first case when it awaits the possible explicit value in the second?

I find this rather confusing and "mentally overloading"

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
杨博 | 9 Jul 06:56 2015
Picon

Proposal: create an Extractor for PartialFunction

Sometimes, when I create a method, I need an extractor parameter for pattern matching, while there is not a generic extractor trait in the Scala Standard Library. So we have to use a PartialFunction as the parameter instead.


When I use the PartialFunction, I had to create pattern matching expression like this.


input match {

  case x if partialFunction.isDefined(x) =>

    val data = partialFunction.apply(x)

    doSomethingWith(data)

}


This approach is not perfect because:

  1. partialFunction.isDefined and partialFunction.apply checked x twice, which is slow if isDefined has complex logical, checking whether a file exists for example.
  2. The if condition around temporary variable x is too trivial.

I think the better approach is converting the PartialFunction to an extractor and matching with that extractor


implicit final class PartialFunctionAsExtractor[A, B](pf: PartialFunction[A, B]) {

  object Extractor {

    def unapply(a: A) = PartialFunction.condOpt(a)(pf)

  }

}


input match {

  case partialFunction.Extractor(data) =>
    doSomethingWith(data)
}

Since this is a common approach, I hope adding the PartialFunctionAsExtractor to scala.Predef .

I would like to create a pull request if people like this idea.

--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sabah A | 9 Jul 01:51 2015
Picon

[scala-language] Fwd: Us congress hearing of maan alsaan Money laundry قضية الكونغجرس لغسيل الأموال للمليادير معن الصانع



 

US Congressional Hearing of

 Saudi billionaire" maan  Al Sanea "

 and Money Laundering  

with bank of America

 

With Arabic Subtitles

 

 

http://www.youtube.com/watch?v=mIBNnQvhU8s

 

 


موقع اليوتيوب الذي عرض فيديوهات جلسة استماع الكونجرس الأمريكي

 لمتابعة نشاطات غسل الأموال ونشاطات

 

السعودي معن عبدالواحد الصانع 

مالك مستشفى  وشركة سعد  ومدارس سعد بالمنطقة الشرقية بالسعودية   ورئيس مجلس ادارة بنك اوال البحريني

 

 وتعليق محطة سي ان بي سي التلفزيونية

 

مترجم باللغة العربية


http://www.youtube.com/watch?v=mIBNnQvhU8s 
















































--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane