Skip to content

Instantly share code, notes, and snippets.

@alexarchambault
alexarchambault / IssueGen.scala
Last active August 29, 2015 14:13
Lazy & generics
package gen
import shapeless._, record._, labelled._
trait TC[T]
object TC {
def apply[T](implicit tc: TC[T]): TC[T] = tc
implicit val booleanTC: TC[Boolean] = new TC[Boolean] {}
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
import scala.annotation.meta.getter
object FirstAnnotation {
def applyImpl[T: c.WeakTypeTag, Ann: c.WeakTypeTag](c: whitebox.Context): c.Tree = {
import c.universe._
val tpe = weakTypeOf[T]
val annTpe = weakTypeOf[Ann]
def cast[T](v: Any): Unit = v.asInstanceOf[T]
def cast1[T](v: Any): T = v.asInstanceOf[T]
val v = BigInt(3)
cast[Double](v) // no exception, there should be one
cast1[Double](v) // exception, but from repl code after cast1 itself
@alexarchambault
alexarchambault / AmmonitePPrintTest.scala
Created April 13, 2015 08:05
Ammonite PPrint derivation failing
import ammonite.pprint._, Config.Defaults._
object AmmonitePPrintTest extends App {
println(PPrint(ObjDefinitions.Foo(2, "ab")).mkString)
println(PPrint(ClsDefinitions.Foo(2, "ab")).mkString)
}
/*
Fails with Ammonite 0.2.7, and more recent dev versions too
@ object ODef { case class Foo(i: Int, s: String) }
defined object ODef
@ ODef.Foo(2, "ba")
res1: cmd0.ODef.Foo = Foo(2, "ba")
@ class CDef { case class Foo(i: Int, s: String) }
defined class CDef
@ object CDef extends CDef
defined object CDef
@ CDef.Foo(2, "ba")
res4: cmd3.CDef.Foo = Foo(2, "ba")
@alexarchambault
alexarchambault / Test.scala
Last active August 29, 2015 14:21
rapture issue
import rapture.json.jsonBackends.jackson._
import rapture.json._
import rapture.core._
import modes.returnTry
import formatters.humanReadable._
case class Dog(name: String, age: Int)
case class DogOwner(dog: Dog, name: String)
case class Dog1[T](name: String, age: T)
@alexarchambault
alexarchambault / mima-output
Created June 8, 2015 13:34
shapeless 2.2.1 / 2.2.0 binary compatibility
> mima-report-binary-issues
[warn] Credentials file /home/alexandre/.ivy2/.credentials does not exist
[info] Resolving org.scala-lang#scala-library;2.11.6 ...
[info] Compiling 1 Scala source to /home/alexandre/projects/shapeless/core/target/scala-2.11/classes...
[info] core: found 18 potential binary incompatibilities
[error] * method noopRotateLeftImpl()shapeless.ops.coproduct#RotateLeft in object shapeless.ops.coproduct#RotateLeft does not have a correspondent in new version
[error] filter with: ProblemFilters.exclude[MissingMethodProblem]("shapeless.ops.coproduct#RotateLeft.noopRotateLeftImpl")
[error] * method implToRotateLeft(shapeless.ops.coproduct#Length,shapeless.ops.nat#Mod,shapeless.ops.coproduct#RotateLeft#Impl)shapeless.ops.coproduct#RotateLeft in object shapeless.ops.coproduct#RotateLeft does not have a correspondent in new version
[error] filter with: ProblemFilters.exclude[MissingMethodProblem]("shapeless.ops.coproduct#RotateLeft.implToRotateLeft")
[error] * interface shapeless.ops.cop
@alexarchambault
alexarchambault / resolve.scala
Created November 24, 2015 20:52 — forked from larsrh/resolve.scala
Resolving multiple artifacts
def fetchPIDE(version: Version)(implicit ec: ExecutionContext): Future[List[Path]] = {
val repositories = Seq(Repository.ivy2Local, Repository.mavenCentral, Repository.sonatypeReleases)
val files = coursier.Files(
Seq("https://" -> new File(sys.props("user.home") + "/.libisabelle/cache")),
() => sys.error("impossible")
)
val cachePolicy = Repository.CachePolicy.Default
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.