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.atlassian.util.scala.concurrent.Atomic //https://bitbucket.org/jwesleysmith/atlassian-util-scala/src/tip/src/main/scala/com/atlassian/util/scala/concurrent/Atomic.scala | |
package patterns { | |
final class TreiberStack[A] { | |
private[this] val head = Atomic[Node[A]](End) | |
@annotation.tailrec | |
def pop: Option[A] = head.value match { | |
case l @ Link(a, prev) => if (head.compareAndSet(l, prev)) Some(a) else pop | |
case _ => None |
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 reflect.macros.Context | |
import scalaz.{ -\/ , \/-, syntax } | |
import syntax.id._ | |
import util.control.NonFatal | |
object Encoders { | |
trait Base { | |
def instance: String => Result[BigInt] | |
} |
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.6.0_37). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scalaz._, Scalaz._, stream._ | |
import scalaz._ | |
import Scalaz._ | |
import stream._ | |
scala> val chan = io.fileChunkR("build.sbt").mapOut { s => new String(s) } |
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._ | |
trait Root { | |
type FT[A[+_], +B] | |
val FT: MonadTrans[FT] | |
def value: FT[Id, Unit] | |
} | |
trait Child extends Root { child => | |
// error: an't existentially abstract over parameterized type 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 scalaz.{ Free, Functor, Monad, Scalaz, \/, syntax } | |
import Free._ | |
import Scalaz.Id | |
import syntax.id._ | |
import syntax.monad._ | |
package times { | |
case class Times[+A](times: Vector[(Long, String)], a: A) | |
object Times { |
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 koto | |
import scalaz.{Comonad, Equal, Free, Functor, Scalaz } | |
import scalaz.syntax.equal._ | |
import scalaz.syntax.monad._ | |
object box extends Interpreted { | |
trait Box[+A] extends HasFree[A] { | |
def get: A = free.go { _.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 scalaz.Monad | |
import scalaz.syntax.monad._ | |
/** | |
* Non stack-using Foldable substitute | |
*/ | |
trait Folder[F[_], A] { | |
def foldLefterM[G[_], B](z: B)(f: (B, A) => G[B])(implicit M: Monad[G]): G[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
package com.atlassian.variance.test; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import static org.hamcrest.Matchers.notNullValue; | |
import org.junit.Test; | |
import com.google.common.base.Function; | |
final class Optional<A> { | |
private final A 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 scalaz._ | |
import Scalaz._ | |
import java.lang.{Long => JLong} | |
object ParameterizedTags { | |
trait Nanoseconds[A] | |
type SampleDuration[A] = JLong @@ Nanoseconds[A] | |
case class Bar(a: BarDuration) |
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
object Tuples { | |
type AsMap[A] = A => Map[String, String] | |
case class Dooby(a: String) | |
case class Foo(b: String) | |
implicit val DoobyMapper = | |
(ev: Dooby) => Map("a" -> ev.a) |
NewerOlder