Skip to content

Instantly share code, notes, and snippets.

trait StableColl[CC[Elem]] {
def builder[Elem](): mutable.Builder[Elem, CC[Elem]]
}
object StableColl {
def apply[CC[Elem]](implicit stableColl: StableColl[CC]): StableColl[CC] = stableColl
implicit def stableCollSeq: StableColl[Seq] =
new StableColl[Seq] {
def builder[Elem]() = new mutable.ListBuffer[Elem]
object Obs {
import shapeless._, poly._
import shapeless.ops.tuple.Mapper
object values extends (Obs ~> Id) {
def apply[T](t: Obs[T]) = t.value
}
@alexarchambault
alexarchambault / keybase.md
Created September 17, 2014 19:14
keybase.md

Keybase proof

I hereby claim:

  • I am alexarchambault on github.
  • I am alexarchambault (https://keybase.io/alexarchambault) on keybase.
  • I have a public key whose fingerprint is 2CA0 E053 21D7 A40B D59B 94F5 61CE DA47 F0A5 3342

To claim this, I am signing this object:

@alexarchambault
alexarchambault / gist:c104ecffcb6190a546d2
Last active August 29, 2015 14:11
Lazy - should not compile, stackoverflow
trait TC[T] {
def apply(t: T): String
}
object TC {
implicit def hnilTC: TC[HNil] =
new TC[HNil] {
def apply(l: HNil) = "HNil"
}
@alexarchambault
alexarchambault / Lgen.scala
Created January 2, 2015 00:47
LabelledGeneric, scala 2.10
case class Foo0()
case class Foo1(i: Int)
object Lgen {
import shapeless._
LabelledGeneric[Foo0]
LabelledGeneric[Foo1]
}
@alexarchambault
alexarchambault / Lgen2.scala
Created January 2, 2015 00:48
LabelledGeneric, scala 2.10 (2)
case class Foo0()
case class Foo1(i: Int)
object Lgen2 {
import shapeless._
import language.experimental.macros
// Works with this one, but hard to do anything with it then...
implicit def lgen[T]: shapeless.LabelledGeneric[T] = macro shapeless.GenericMacros.materializeLabelled[T, Nothing]
@alexarchambault
alexarchambault / Base.scala
Last active August 29, 2015 14:12
Lazy & case object constructors
sealed trait Base0
case class Foo0() extends Base0
case class Bar0() extends Base0
sealed trait Base1
case object Foo1 extends Base1
case object Bar1 extends Base1
object Base {
Generic[Foo0]
@alexarchambault
alexarchambault / TC NonLabelled.scala
Last active August 29, 2015 14:13
Lazy, labels, and scalaz.@@
package shapeless
package examples
import scalaz.@@
import labelled._
import record._
trait TC[T] {
def apply(): String
}
@alexarchambault
alexarchambault / Test.scala
Last active August 29, 2015 14:13
LabelledGeneric and tags
import tag.@@
import record._
trait CustomTag
case class Dummy(i: Int @@ CustomTag)
case class DummyTagged(b: Boolean, i: Int @@ CustomTag)
object Test extends App {
val gen = Generic[Dummy]
@alexarchambault
alexarchambault / Dummy.scala
Last active August 29, 2015 14:13
sbt launchconfig issue
import java.util.Locale
import javax.servlet.http.{Cookie, HttpServletResponse}
class Dummy extends xsbti.AppMain {
def run(config: xsbti.AppConfiguration) =
try {
// Creating a dummy HttpServletResponse
// - succeeds from sbt run or sbt console
// - fails through launchconfig using the `dummy` script below (NoClassDefFound exception)
val r = new HttpServletResponse {