Good scalaz introduction [closed]

Hieko Seeberger has recently started blogging on functional programming and category theory applied to Scala. Two opening posts are very educative (and easy to read), and can help getting over the initial barrier in learning scalaz. EDIT: When you get comfortable with the fundamentals, I would recommend you to read through http://apocalisp.wordpress.com/ (blog driven by … Read more

Akka Kill vs. Stop vs. Poison Pill?

Both stop and PoisonPill will terminate the actor and stop the message queue. They will cause the actor to cease processing messages, send a stop call to all its children, wait for them to terminate, then call its postStop hook. All further messages are sent to the dead letters mailbox. The difference is in which … Read more

How to get started with Akka Streams? [closed]

This answer is based on akka-stream version 2.4.2. The API can be slightly different in other versions. The dependency can be consumed by sbt: libraryDependencies += “com.typesafe.akka” %% “akka-stream” % “2.4.2” Alright, lets get started. The API of Akka Streams consists of three main types. In contrast to Reactive Streams, these types are a lot … Read more

Scala 2.8 breakOut

The answer is found on the definition of map: def map[B, That](f : (A) => B)(implicit bf : CanBuildFrom[Repr, B, That]) : That Note that it has two parameters. The first is your function and the second is an implicit. If you do not provide that implicit, Scala will choose the most specific one available. … Read more

What does `:_*` (colon underscore star) do in Scala?

It “splats”1 the sequence. Look at the constructor signature new Elem(prefix: String, label: String, attributes: MetaData, scope: NamespaceBinding, child: Node*) which is called as new Elem(prefix, label, attributes, scope, child1, child2, … childN) but here there is only a sequence, not child1, child2, etc. so this allows the result sequence to be used as the … Read more

Get item in the list in Scala?

Use parentheses: data(2) But you don’t really want to do that with lists very often, since linked lists take time to traverse. If you want to index into a collection, use Vector (immutable) or ArrayBuffer (mutable) or possibly Array (which is just a Java array, except again you index into it with (i) instead of … Read more

Difference between case object and object

Here’s one difference – case objects extend the Serializable trait, so they can be serialized. Regular objects cannot by default: scala> object A defined module A scala> case object B defined module B scala> import java.io._ import java.io._ scala> val bos = new ByteArrayOutputStream bos: java.io.ByteArrayOutputStream = scala> val oos = new ObjectOutputStream(bos) oos: java.io.ObjectOutputStream … Read more

Case objects vs Enumerations in Scala

One big difference is that Enumerations come with support for instantiating them from some name String. For example: object Currency extends Enumeration { val GBP = Value(“GBP”) val EUR = Value(“EUR”) //etc. } Then you can do: val ccy = Currency.withName(“EUR”) This is useful when wishing to persist enumerations (for example, to a database) or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)