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 com.github.nscala_time.time.StaticInterval | |
import com.twitter.algebird.Monoid | |
import shapeless._, record._, syntax.singleton._ | |
import shapeless.ops.record.SelectAll | |
/** Represents a path component generator, basically a function keysTemplate.type -> Set[Seq[String]] | |
* | |
*/ | |
trait PathPattern { |
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 com.github.nscala_time.time.StaticInterval | |
import com.twitter.algebird.Monoid | |
import shapeless._, record._, syntax.singleton._ | |
import shapeless.ops.record.SelectAll | |
/** Represents a path component generator, basically a function keysTemplate.type -> Set[Seq[String]] | |
* | |
*/ | |
trait PathPattern { |
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
// Would love to use the following, sadly TypedPipe is not really monadic: | |
// * a bind/flatMap operator is missing: | |
// Indeed flatMap currently has the following signature: | |
// def flatMap[U](f: (T) ⇒ TraversableOnce[U]): TypedPipe[U] | |
// whereas a monadic bind would look like this | |
// def flatMap[U](f: (T) ⇒ TypedPipe[U]): TypedPipe[U] | |
// * return/unit can be implemented in such way: | |
// return[A]: A => TypedPipe[A] = a => TypedPipe.from(List(a)) | |
for { |
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 Monoid { | |
fn zero() -> Self; | |
fn append(this: Self, that: Self) -> Self; | |
} | |
impl Monoid for int { | |
fn zero() -> int { 0 } | |
fn append (this: int, that: int) -> int { this + that } | |
} |
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
module GameSkeleton where | |
import Window | |
import Keyboard | |
import Random | |
{-- Part 1: Model the user input ---------------------------------------------- | |
What information do you need to represent all relevant user input? |
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
'use strict'; | |
angular.module('firebase', []).value('Firebase', Firebase); | |
// Implicit syncing. angularFire binds a model to $scope and keeps the dat | |
// synchronized with a Firebase location both ways. | |
// TODO: Optimize to use child events instead of whole 'value'. | |
angular.module('firebase').factory('angularFire', ['$q', function($q) { | |
return function(url, scope, name, ret) { | |
var af = new AngularFire($q, url); |
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.reflect.runtime.universe._ | |
import scala.reflect._ | |
object testtypetag { | |
class ReqTT[T : TypeTag] | |
case class Dummy | |
new ReqTT[Dummy] // Compiler : No TypeTag available for Dummy, thus no implicit evidence | |
} |
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
/* | |
Par exemple, dans le pseudo-code suivant, tous les appels sont asynchrones mais séquentiels | |
les uns par rapport aux autres. | |
Si l'un d'entre eux échoue, la chaine d'appels s'arrete et 'pictures' est lui-meme considéré | |
comme un echec et contient l'erreur/exception du point d'abandon. | |
*/ | |
//'pictures' est ici une composition des différents appels différés (Future) | |
val pictures: Future[List[Picture]] = for { |
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 ModelService[T] { | |
val selectAll = Queryable[T] // Compiler error : No TypeTag for T, plus issues with "evidences" | |
val selectById = (id:Int) => selectAll.filter(_.id == id) | |
def all: Try[Option[Vector[T]]] | |
def get (id:Int): Try[Option[T]] | |
def add (obj: T): Try[Option[Int]] | |
def update (id:Int, obj:T): Try[Option[Int]] | |
def delete (id:Int):Try[Option[Int]] |