This is now an actual repo:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
class A2 extends A | |
class B | |
trait M[X] | |
// | |
// Upper Type Bound | |
// | |
def upperTypeBound[AA <: A](x: AA): A = x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait RestHelper extends LiftRules.DispatchPF { | |
... | |
/** | |
* A function that chooses JSON or XML based on the request.. | |
* Use with serveType | |
*/ | |
implicit def jxSel(req: Req): Box[JsonXmlSelect] = | |
if (jsonResponse_?(req)) Full(JsonSelect) | |
else if (xmlResponse_?(req)) Full(XmlSelect) | |
else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ListBuffer | |
import akka.actor.{Actor,ActorRef} | |
import akka.actor.Actor._ | |
import akka.routing.{ Listeners, Listen } | |
//Represents a domain event | |
trait Event | |
//A builder to create domain entities | |
trait EntityBuilder[Entity] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The way Scala for-comprehensions work is that: | |
for (x <- c) f(x) | |
// simply translates to: | |
c.foreach(x => f(x)) | |
// Likewise: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Aggregator(recipients: Iterable[ActorRef]) extends Actor{ | |
def receive = { | |
case msg @ Message(text) => | |
println("Started processing message `%s`" format(text)) | |
val result = Promise[String]() | |
val promises = List.fill(recipients.size)(Promise[String]()) | |
recipients.zip(promises).map{case (recipient, promise) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Part Zero : 10:15 Saturday Night | |
* | |
* (In which we will see how to let the type system help you handle failure)... | |
* | |
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0) | |
*/ | |
import scalaz._ | |
import Scalaz._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.elasticsearch; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nlist | |
sealed trait Even[A <: Nat] | |
object Even { | |
implicit def isEven[A <: Nat](implicit e: A#IsEven =:= True): Even[A] = | |
new Even[A]{} | |
} | |
sealed trait Bool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//harry huang [[email protected]] | |
// | |
//After reading the original post [http://jboner.github.com/2008/10/06/real-world-scala-dependency-injection-di.html, ] | |
//the original cake pattern seems quite verbose for me, and it is quite invasive, so I spent a bit time | |
//and come up with an improved version of cake pattern, which I call it "Auto Cake DI". It is working | |
//well with any POST(plain old scala trait)/POSO(plain old scala object) which means that anything can be | |
//injected without modification or introducing new traits. | |
/*---------inject trait---------*/ | |
trait Inject[+T] { def inject: T } |
OlderNewer