Skip to content

Instantly share code, notes, and snippets.

View ariwaranosai's full-sized avatar
🐒
hou

在原佐为 ariwaranosai

🐒
hou
  • HangZhou
View GitHub Profile
@ariwaranosai
ariwaranosai / test.sc
Created January 13, 2016 11:40
implicit
trait CanTruthy[A] {
def truthys(a: A): Boolean
}
object CanTruthy {
def apply[A](implicit ev: CanTruthy[A]): CanTruthy[A] = ev
def truthys[A](f: A => Boolean): CanTruthy[A] = new CanTruthy[A] {
def truthys(a: A): Boolean = f(a)
}
}
@ariwaranosai
ariwaranosai / flatten.scala
Created December 8, 2015 05:51 — forked from Centaur/flatten.scala
Shapeless tuple flatten
import shapeless._
import poly._
import shapeless.ops.tuple.FlatMapper
import syntax.std.tuple._
object Flatten {
trait LowPriorityFlatten extends Poly1 {
implicit def default[T] = at[T](Tuple1(_))
}
object flatten extends LowPriorityFlatten {