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.annotation.tailrec | |
sealed trait Tree[+A] { | |
def isSymmetric: Boolean | |
} | |
object Tree { | |
final case class Node[+A](left: Tree[A], value: A, right: Tree[A]) extends Tree[A] { | |
def isSymmetric: Boolean = { | |
@tailrec def loop( |
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 Test { | |
import shapeless._ | |
import shapeless.labelled._ | |
trait Convert[A, B] { | |
def apply(a: A): B | |
} | |
object Convert { | |
implicit def id[A]: Convert[A, A] = x => x |
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 | |
// Whitebox ... | |
trait Schema[T, R] { | |
def conv(t: T): R | |
} | |
object Schema { | |
// Whitebox macro: R is computed from T | |
implicit def mkSchema[T, R]: Schema[T, R] = ??? // macro ... |
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
/** Enable MTL-style programming by avoiding ambiguous implicits. */ | |
class MTL[M](val M: M) extends AnyVal | |
object MTL { | |
type MonadMTL[F[_]] <: Monad[F] | |
implicit def mtl[M](implicit M: M): MTL[M] = new MTL[M](M) | |
private def MonadMTL[M[f[_]] <: Monad[f], F[_]](M: M[F]): MonadMTL[F] = | |
M.asInstanceOf[MonadMTL[F]] | |
/** An artificial hierarchy for MTL type classes. */ |
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 abstract class SingletonOf[A, +B] { | |
} | |
object SingletonOf { | |
} | |
type <::[A, +B] = SingletonOf[A, B] | |
def single[A <: Singleton](a: A): SingletonOf[A, A] = | |
new SingletonOf[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 cats.Functor | |
import shapeless._ | |
import scala.language.higherKinds | |
trait Unfix[A] { | |
type F[_] | |
def apply(a: A): Fix[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 shapeless._ | |
import shapeless.labelled._ | |
import shapeless.ops.hlist._ | |
import shapeless.ops.record._ | |
import shapeless.syntax.singleton._ | |
object MkLenses { | |
object mkLenses extends Poly1 { | |
implicit def mkLens[R <: HList, K](implicit mk: MkRecordSelectLens[R, K]) = | |
at[K](_ => mk()) |
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._ | |
import shapeless.ops.coproduct.Selector | |
import shapeless.ops.coproduct.ToHList | |
import shapeless.ops.hlist.LiftAll | |
import shapeless.ops.hlist.Mapper | |
import shapeless.ops.hlist.ZipConst | |
object Partition extends App { | |
trait Dummy[-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 org.apache.flink.api.common.io.OutputFormat | |
import org.apache.flink.configuration.Configuration | |
import org.apache.hadoop.hbase._ | |
import client._ | |
import util.Bytes | |
import language.{ implicitConversions, reflectiveCalls } | |
import java.math.BigDecimal | |
import java.nio.ByteBuffer |
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
interface EvalExpr<E extends EvalExpr<E>> extends Expr<E> { | |
int eval(); | |
} | |
interface EvalExprFix extends EvalExpr<EvalExprFix> { | |
} | |
class EvalConst<E extends EvalExpr<E>> extends Const<E> implements EvalExpr<E> { |