Data dodania Pytanie
2017-02-18 22:02 Generalizing DivisibleBy in type-level programming with Scala »
I'm trying to generalize a divisible-by relation in Scala using type level programming. This is my Nat number definitions: trait Nat { type plus[N&...
(1) odpowiedzi
2017-02-18 21:02 Scala String toInt - Int does not take parameters »
So I'm learning Scala and I came across this finicky issue... If we have a String and want to convert it to an Int, all examples that I've found onli...
(1) odpowiedzi
2017-02-18 13:02 How to use Apply for Function Application »
I have the following validation logic: def one(a : String) : Validation[String, Int] = if (a == "one") { Success(1) } else { Fa...
(1) odpowiedzi
2017-02-18 02:02 Reconstructing object tree from joined query »
Let's assume I have following DB model (not a real case so please forgive me the utter silliness of this example): I want to fetch joined result fr...
(0) odpowiedzi
2017-02-17 21:02 Functional way to find a pair of integers, which sum to X, in a sorted array »
This is a follow-up to my previous question. Suppose I want to find a pair of integers, which sum to a given number x, in a given sorted array. The we...
(4) odpowiedzi
2017-02-17 15:02 Circe: decode multi-level ADT efficiently »
I want to decode the following ADT with Circe: sealed trait PaymentType object PaymentType extends EnumEncoder[PaymentType] { case object DebitCard...
(1) odpowiedzi
2017-02-17 13:02 Matching against Value Classes in Akka »
I've created the Value Class final class Feature(val value: Vector[Double]) extends AnyVal To match against that class in scala: val d = new Featu...
(1) odpowiedzi
2017-02-17 06:02 Which Monad Transformer to use? »
I am trying to write the validate function below so that the validation stops after the first error encountered. The return type of three is different...
(2) odpowiedzi
2017-02-16 14:02 Scala way of applying function to list and getting highest result with input »
best_acc = 0 for split in split_candidates: acc = self.get_split_score(t_series_distances, split) if acc > best_acc: best_acc = acc...
(1) odpowiedzi
2017-02-16 12:02 How to traverse array from both left to right and from right to left? »
Suppose I have an imperative algorithm that keeps two indices left and right and moves them from left to right and from right to left var left = 0 v...
(3) odpowiedzi
2017-02-16 10:02 Pattern matching java.lang.Long »
I'm confused with scala pattern matching behaviour, see code below: import java.util.concurrent.atomic.AtomicLong object LongPatternMatching { de...
(2) odpowiedzi
2017-02-15 23:02 Scala compilation time report »
I've got a project that isn't a crazy number of lines of code, but its compilation time is really long on a clean compile. I have the feeling there ar...
(0) odpowiedzi
2017-02-15 11:02 Obtaining the full info about fields of the case class in Scala »
Consider the following class and method: case class User(id: Long, name: String) { private var foo = "Foo" // shouldn't be printed val bar = "bar...
(1) odpowiedzi
2017-02-15 02:02 Count number of Strings that can be converted to Int in a List »
For example, my input is: scala> val myList = List("7842", "abf45", "abd", "56") myList: List[String] = List(7842, abf45, abd, 56) 7842 and 56 c...
(4) odpowiedzi
2017-02-14 20:02 are there advantages for using value class (without methods) vs type alias? »
Let's say I have this ADT : case class Person(id: String) case class Kid(id: String, name: String) I would like to represent the id field in more e...
(3) odpowiedzi
2017-02-14 08:02 Why Final variables in scala are allowed to change values »
Why Final variables in Scala are allowed to change values. As per my understanding once declared final, they shouldn't be allowed to change. class fo...
(3) odpowiedzi
2017-02-14 00:02 Implicit class resolution for parameterized types »
In the following example, it seems that the Scala compiler only recognizes an implicit class when it is defined to take the higher-kinded representati...
(2) odpowiedzi
2017-02-13 17:02 Circe decoder for scalaz.Maybe »
Here's a simple finch server, using circe as decoder: import com.twitter.finagle.http.RequestBuilder import com.twitter.io.Buf import io.circe.generi...
(2) odpowiedzi
2017-02-13 14:02 Should I create traits to represent enum values for my models? »
Say I have a model like: case class User( id: Int, name: String, userType: Int) Should I then do this: sealed trait UserType case object Member...
(3) odpowiedzi
2017-02-13 13:02 Get a message out of an Akka Actor »
I've built an Akka actor that queries an API at regular intervals, like this: val cancellable = system.scheduler.schedule(0 milliseconds, ...
(1) odpowiedzi
2017-02-12 19:02 Unable to handle String literals size greater than 65535 characters. Compiler throws IllegalArgumentException »
I am trying to decode a Base64 encoded Image in Scala. The string literal is over 65535 characters long. Whenever I try to compile the below code, the...
(2) odpowiedzi
2017-02-12 12:02 Apache Spark unable to find class »
I'm trying to develop stand alone app using apache spark alongside scala sbt I'm getting this error again and again. Exception in thread "main" ja...
(1) odpowiedzi
2017-02-12 02:02 How to filter elements in List where predicate is over entire other List »
How to filter a List l1 where if an element in other List l2 is contained in l1. Given two Lists ls1 , ls2 : val ls1 = List("a b c" , "a c d" , "d...
(1) odpowiedzi
2017-02-11 20:02 Currying vs. anonymous function in Scala »
I was comparing two ways of defining a higher-order function in Scala: def f1(elem: Int)(other: Int) = (elem == other) def f2(elem: Int) = (other: I...
(1) odpowiedzi
2017-02-11 17:02 Why does scalac rise a "diverging implicit expansion" error here? »
In the following code I try to derive typeclass instances with shapeless. However, in the case of a more complex case class (which is converted to a m...
(1) odpowiedzi
2017-02-11 01:02 Avoid global state in Scala »
I'm writing a Plugin Manager which allows user to register new plugin from jar file. PM can be access (read only) from other objects and only one inst...
(1) odpowiedzi
2017-02-10 23:02 Why does this public field have a PRIVATE flag? »
I'm writing a Scala macro and am traversing the tree to find non-private fields in classes. Consider this code that the macro looks at: class Foo { ...
(1) odpowiedzi
2017-02-10 18:02 How to decode an ADT with circe without disambiguating objects »
Suppose I've got an ADT like this: sealed trait Event case class Foo(i: Int) extends Event case class Bar(s: String) extends Event case class Baz(c:...
(1) odpowiedzi
2017-02-10 01:02 My API is all returning Future[Option[T]], how to combine them nicely in a for-compr »
All of my API methods return Future[Option[T]], trying to figure out how to elegantly perform the following: case class UserProfile(user: User, locat...
(1) odpowiedzi
2017-02-09 15:02 'tee' operation on Scala's option type? »
Is there some sort of 'tee' operation on Option in Scala's standard library available? The best I could find is foreach, however its return type is Un...
(3) odpowiedzi
2017-02-09 05:02 Scala – Make implicit value classes available in another scope »
I have a package foo which contains class FStream. The package object of foo defines a few implicit value classes that provide extender methods for FS...
(1) odpowiedzi
2017-02-09 03:02 Scala currying example »
I am new to scala and was going through the coursera course for scala functional development. Below the code snippet explains about currying import...
(2) odpowiedzi
2017-02-09 01:02 Separating application logs in Logback from Spark Logs in log4j »
I have a Scala Maven project using that uses Spark, and I am trying implement logging using Logback. I am compiling my application to a jar, and deplo...
(1) odpowiedzi
2017-02-08 19:02 Scala: Lensing vs mutable design »
My basic understanding of lensing is that, "a lens is a value representing maps between a complex type and one of its constituents. This map works bot...
(1) odpowiedzi
2017-02-08 18:02 type mismatch when running reduceLeft »
I have a ConfigRule trait which has transform method as trait ConfigRule { final def transform(doc: Node): Node = { .....} } Then I have ConfigTr...
(2) odpowiedzi