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[T] { | |
def Zero: T | |
def op: (T,T) => 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
sealed trait Maybe[+A] { | |
// >>= | |
def flatMap[B](f: A => Maybe[B]): Maybe[B] | |
} | |
case class Just[+A](a: A) extends Maybe[A] { | |
override def flatMap[B](f: A => Maybe[B]) = f(a) | |
} | |
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
find . -name "*jar" -print -exec jar -tf '{}' \; | grep -E "jar$|LoggerConfiguration" |
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 java.util.Date | |
abstract class Census | |
abstract class Translation | |
abstract class Passport | |
object VisaRequest { | |
def apply(to: Someone, at: String) = new VisaRequest(to, at) |
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 java.util.Date | |
trait Translation | |
trait MissingTranslation | |
trait AnyTrans extends Translation with MissingTranslation | |
trait Certificate | |
trait MissingCertificate | |
trait AnyCert extends Certificate with MissingCertificate |
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 Future[+A] { | |
private def apply(k: A => Unit): Unit | |
} | |
type Par[+A] = ExecutorService => Future[A] | |
def map2[A, B, C](pa: Par[A], pb: Par[B])(f: (A, B) => C): Par[C] = { | |
ex => | |
{ |
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 java.util.concurrent.ExecutorService | |
import java.util.concurrent.Callable | |
import java.util.concurrent.atomic.AtomicReference | |
import java.util.concurrent.atomic.AtomicInteger | |
import scala.annotation.tailrec | |
final case class Actor[A](strategy: Strategy)(handler: A => Unit, onError: Throwable => Unit = throw (_)) { | |
private class Node[A](var a: A = null.asInstanceOf[A]) extends AtomicReference[Node[A]] |
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.util.parsing.input.Reader | |
import scala.util.parsing.input.CharArrayReader.EofCh | |
import scala.util.parsing.input.Position | |
case class ByteOffsetPosition(offset: Int) extends Position { | |
final val line = 1 | |
def column = offset + 1 | |
def lineContents: String = "" | |
} |
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 BencodeConstants { | |
final val DEFAULT_STRING_ENCODING = "ISO-8859-15" | |
final val DEFAULT_NUMBER_ENCODING = "US-ASCII" | |
final val NUMBER_BEGIN: Char = 'i' | |
final val NUMBER_END: Char = 'e' | |
final val LIST_BEGIN = 'l' | |
final val LIST_END = 'e' |
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 BencodeParser extends Parsers with BencodeConstants { | |
type Elem = Byte | |
implicit def charToParser(ch: Char) = elem(ch.toByte) | |
def delimitedBy[A](left: Parser[Byte], right: Parser[Byte])(p: Parser[A]): Parser[A] = left ~> p <~ right | |
def single_digit = new Parser[String] { |
OlderNewer