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
Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val map0 = Map.empty[Int, Int] withDefaultValue 0 | |
map0: scala.collection.immutable.Map[Int,Int] = Map() | |
scala> val map1 = map0 mapValues(identity) | |
map1: scala.collection.immutable.Map[Int,Int] = 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
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import play.api.libs.json._; import play.api.libs.functional.Applicative; | |
import play.api.libs.json._ | |
import play.api.libs.functional.Applicative | |
scala> val expected = JsSuccess(10, JsPath(List(KeyPathNode("somekey")))) | |
expected: play.api.libs.json.JsSuccess[Int] = JsSuccess(10,/somekey) |
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 scalaz._, Scalaz._ | |
def setS(i: Int): State[List[Int], Unit] = modify(i :: _) | |
val s = (1 to 10000).foldLeft(state[List[Int], Unit](()).lift[Free.Trampoline]) { | |
case (st, i) => st *> setS(i).lift[Free.Trampoline] | |
} | |
s(Nil).run |
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 scalaz.Id.Id | |
import scalaz.BijectionT._ | |
import scalaz.Lens | |
trait Bijectionz[A, C] { | |
def apply(str: C): A | |
def unapply(a: A): Option[C] |
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.nicta.rng.Rng | |
import org.joda.time.DateTime | |
import scalaz._ | |
import Scalaz._ | |
object Foo extends App { | |
def time[A](f: => A): (Long, Long, Long) = { | |
val t0 = System.currentTimeMillis | |
val a = f |
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 Writes[T] { | |
def writes(o: T): JsValue | |
} | |
trait Reads[T] { | |
def reads(json: JsValue): T | |
} | |
trait Format[T] extends Writes[T] with Reads[T] |
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
/* This is how I am globally handling fatal exceptions thrown from Rx subscribers. | |
* It is what I came up with in response to my stackoverflow question here | |
* http://stackoverflow.com/questions/7210051/catching-exceptions-which-may-be-thrown-from-a-subscription-onnext-action | |
* This is far from ideal. From what I understand, exception handling has been improved greately in Rx for .NET 4.5 | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
using System.Threading.Tasks; |
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 com.bostontechnologies.cscore.amqp | |
import com.weiglewilczek.slf4s.Logging | |
import collection.JavaConversions._ | |
import collection.mutable.{SynchronizedSet, HashSet, ConcurrentMap} | |
import java.lang.String | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.atomic.AtomicBoolean | |
import org.springframework.amqp.core.{Queue, Binding, AmqpAdmin, Exchange} | |
import org.springframework.amqp.rabbit.core.RabbitAdmin |
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 com.mypackage | |
import org.specs.SpecificationWithJUnit | |
import scalaz._ | |
import Scalaz._ | |
class ValidationTests extends SpecificationWithJUnit { | |
"I should be able to convert List[Validation[A, B]] to Validation[List[A], List[B]]" >> { |
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
Show hidden characters
/* | |
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings, | |
and don't need to be repeated here. Anything listed here will take precedence, however. | |
*/ | |
[ | |
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }, | |
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }, | |
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} }, | |
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }, | |
... |
OlderNewer