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.github.jeremyrsmith.util | |
import scala.language.experimental.macros | |
import scala.reflect.macros.blackbox.Context | |
import _root_.spray.json._ | |
package object spray { | |
object MacroImpl { | |
def impl[T: c.WeakTypeTag](c: Context): c.Expr[JsonFormat[T]] = { | |
import c.universe._, Flag._, definitions._ |
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 demonstrates creating a trivial protocol and service on top of Mux. | |
* The protocol used is scala.pickling, but it could just as easily use Scodec, | |
* Avro, or anything else that can SerDe to/from a byte array. All that would | |
* need replacing is the BinaryPickleFilter and the PickleBinaryFilter. | |
* | |
*/ | |
import com.twitter.finagle._ | |
import com.twitter.io.Buf |
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 shapeless._ | |
trait TestTypeclassRecursive[T] { | |
def doFoo(t: T): String | |
} | |
object TestTypeclassRecursive { | |
implicit val hnil: TestTypeclassRecursive[HNil] = new TestTypeclassRecursive[HNil] { |
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 Option[+T] | |
case object None extends Option[Nothing] | |
case class Some[@specialized +T](value: T) extends Option[T] | |
object Option { | |
implicit class Ops[A](val opt: Option[A]) extends AnyVal { | |
@inline final def get(): A = opt match { |
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.reflect.macros.whitebox | |
import shapeless._ | |
import scala.language.experimental.macros | |
trait SingletonChars[S <: String] { | |
type Out <: HList | |
} | |
object SingletonChars { |
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.language.higherKinds | |
trait Foo[A] { | |
type Out[_] | |
def apply[T](t: T): Out[T] | |
} | |
object Foo { | |
type Aux[A, Out0[_]] = Foo[A] { type Out[A] = Out0[A] } |