Skip to content

Instantly share code, notes, and snippets.

View patrick-premont's full-sized avatar

Patrick Prémont patrick-premont

  • Gatineau-Ottawa, Canada
View GitHub Profile
def main() = {
val lv: Int = 0
def ld : Int = 0
trait A {
val v: Int
def d : Int
def d0() : Int
val vf : () => Int
def df : () => Int
}
@patrick-premont
patrick-premont / gist:5733621
Created June 8, 2013 02:04
This code attempts to show one way asynchronous requests can be batched in a type safe manner.
// This code attempts to show one way asynchronous requests can be batched in a type safe manner.
object BatchableRequests {
sealed trait Request[A] {
def serialize(): String
def deserialize(s: String): Option[(A, String)]
def pair[B](b: Request[B]): Request[(A, B)] = RequestPair(this, b)
}
case class RequestPair[A, B](a: Request[A], b: Request[B]) extends Request[(A, B)] {