This file contains hidden or 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
case class GenericCache[A[_,_], B, C](instance: A[B,C], getf: B=>C, putf: (B,C)=>Unit) { | |
def retrieve(b: B) = getf(b) | |
def insert(b: B, c: C) = putf(b,c) | |
} | |
//Notice how neither cache implementations have to even be aware of the existnace of the typeclass. much more flexible than inheritance | |
class FastCache[A,B] { | |
private var m = Map[A,B]() //excuse mutability for illustration purposes | |
def add(a: A, b: B): Unit = { | |
m = m + (a->b) |
This file contains hidden or 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 java.util.concurrent.atomic.AtomicReference | |
import java.util.concurrent.CountDownLatch | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext | |
import ExecutionContext.Implicits.global | |
object TxMapTest { | |
/* | |
* Example Usage | |
* We want to show two threads working with the same data source having both of their effects succeed |
This file contains hidden or 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
using System; | |
using System.Threading; | |
using XSharpx; | |
using System.Collections; | |
using System.Net; | |
namespace TestProj | |
{ | |
class MainClass | |
{ |
This file contains hidden or 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 vsxmpp | |
import scalaz.EitherT | |
import scalaz._ | |
import Scalaz._ | |
case class ABC(s:String) | |
object ABC { | |
This file contains hidden or 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
//Reader Monad and its extension class to give it SelectMany(bind/flatMap) capabilities for use in LINQ queries | |
public static class ReaderMonadExt | |
{ | |
public static ReaderMonad<T, C> SelectMany<T, A, B, C>(this ReaderMonad<T, A> rm, Func<A, ReaderMonad<T, B>> bindf, Func<A, B, C> select) | |
{ | |
return new ReaderMonad<T, C>(t => | |
{ | |
var a = rm.Run(t); | |
return select(a, bindf(a).Run(t)); | |
}); |
This file contains hidden or 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 java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.CountDownLatch | |
import akka.dispatch.Future | |
import akka.dispatch.Promise | |
import scala.collection.JavaConversions._ | |
import scala.collection.JavaConversions | |
import akka.dispatch.ExecutionContext | |
import java.util.concurrent.Executors | |
import java.util.concurrent.atomic.AtomicReference |
This file contains hidden or 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 java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.CountDownLatch | |
import akka.actor.Actor | |
import akka.dispatch.Future | |
import akka.actor.ActorSystem | |
import akka.actor._ | |
import scala.collection.JavaConversions._ | |
import scala.collection.JavaConversions | |
import akka.pattern._ | |
import akka.util.Timeout |
NewerOlder