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.crowd.plugin.usermanagement.rest.controller; | |
import com.atlassian.fugue.Option; | |
import static com.atlassian.crowd.plugin.usermanagement.rest.controller.Visibility.Internal; | |
import static com.atlassian.fugue.Option.some; | |
class Main { | |
public static void main(String[] args) { | |
CreateComment comment1 = CreateComment.build( |
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
// | |
// each TC companion declares a Has[F] that expresses a relation to that TC | |
// impls obvs. have themselves as Has relations | |
// | |
// pro: no subtyping between TCs as the TC relations are encoded in the HasX subtypes | |
// pro: survives multiple relations | |
// cons: boilerplate for TC authors, and a little tricky to get right | |
// cons: impl needs to impl the full laundry list (can have template impls that do this eg: Monad.Template | |
trait Functor[F[_]] extends Functor.Has[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
import kadai.concurrent.Atomic | |
class Memoize[A](thunk: => Option[A]) { | |
val atom: Atomic[Ref] = Atomic(Empty) | |
def get: A = | |
atom.get match { | |
case Value(a) => a | |
case exec @ Executing() => exec.await match { | |
case Some(a) => if (atom.get == exec && atom.compareAndSet(exec, Value(a))) a else get |
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.syntax.functor._ | |
object LiftNaturalTransform { | |
def transform[F[_], G[_], M[_]: Functor, A](implicit nt: F ~> G): M[F[A]] => M[G[A]] = | |
_ map nt.apply | |
implicit class NaturalTransformSyntax[F[_], G[_]](f2g: F ~> G) { | |
def lift[M[_]: Functor] = |
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 A { | |
sealed trait Foo | |
case object Bar extends Foo | |
case class Baz() extends Foo | |
def isBar(f: Foo) = f match { | |
case Bar => true | |
case Baz() => false | |
} | |
} |
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.runtime.AbstractFunction2 | |
class Foo[A, B, C] | |
extends AbstractFunction2[String, Int, Int] with ((String, Int) => Int) { | |
def apply(a: String, i: Int) = 3 | |
} |
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 test | |
// Type definitions | |
object Types { | |
type Tag = String | |
} | |
import Types._ | |
// Marker definitions | |
case class OperatingHours(hours: 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
object To { | |
trait Bijection[A, B] { | |
def to: A => B | |
def from: B => A | |
} | |
sealed trait Translate[A] { | |
type T | |
def apply(a: A): 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
package stuff | |
import akka.actor.{ Actor, actorRef2Scala } | |
import kadai.log.Logging | |
import spray.http.{ HttpFailure, HttpResponse } | |
import spray.http.HttpEntity.apply | |
trait IOActor extends Actor { | |
log: Logging => |
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] | |
} |
NewerOlder