Skip to content

Instantly share code, notes, and snippets.

View milessabin's full-sized avatar

Miles Sabin milessabin

View GitHub Profile
This file has been truncated, but you can view the full file.
miles@tarski:perf_tester (topic/miles-byname-implicits)% java -jar target/scala-2.12/perf_tester-assembly-0.1.jar -s /home/miles/projects/scala -r results -a corpus/scala-library -c miles-byname-implicits --user miles -i 50 -p 3
Output logging to /home/miles/projects/perf_tester/results/miles/miles-byname-implicits
ALL
Run Name Cycle samples Wall time (ms) All Wall time (ms) CPU(ms) Idle time (ms) Allocated(MBs)
pre-pr 1 50 9,332.00 [-10.92% +203.33%] 9,332.00 [-10.92% +203.33%] 9,188.06 [-10.64% +196.26%] 0.00 [ NaN% NaN%] 2,743.61 [-0.38% +6.58%]
pre-pr 2 50 9,088.94 [-10.42% +192.67%] 9,088.94 [-10.42% +192.67%] 8,959.18 [-10.03% +185.47%] 0.00 [ NaN% NaN%] 2,745.65 [-0.51% +6.81%]
pre-pr 3 50 9,176.00 [-9.87% +199.00%] 9,176.00 [-9.87%
-----------------------------
ALL
Run Name Cycle samples Wall time (ms) All Wall time (ms) CPU(ms) Idle time (ms) Allocated(MBs)
pre-pr 1 30 9,830.23 [-13.87% +183.84%] 9,830.23 [-13.87% +183.84%] 9,644.07 [-13.42% +178.31%] 0.00 [ NaN% NaN%] 2,775.16 [-0.65% +6.12%]
pr 1 30 9,818.50 [-14.81% +186.90%] 9,818.50 [-14.81% +186.90%] 9,642.10 [-14.13% +181.26%] 0.00 [ NaN% NaN%] 2,762.69 [-0.67% +7.13%]
jason-feedback 1 30 9,805.13 [-14.34% +184.80%] 9,805.13 [-14.34% +184.80%] 9,617.57 [-13.61% +179.12%] 0.00 [ NaN% NaN%] 2,760.19 [-0.62% +6.94%]
-----------------------------
ALL
Run Name Cycle samples Wall time (ms) All Wall time (ms) CPU(ms)
@milessabin
milessabin / typelevelcps.scala
Created May 29, 2018 10:13
Using type level continuation passing style to rewrite a whitebox macro (which relies on fundep materialization) as a blackbox macro
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 ...
// Current Scala 2
trait Concat[A, B] {
type Result
def apply(a: A, b: B): Result
}
object Concat {
def apply[A, B](a: A, b: B)(implicit cab: Concat[A, B]): cab.Result = cab(a, b)
implicit def hnil[B]: Concat[HNil, B] { type Result = B } = new Concat[HNil, B] {
@milessabin
milessabin / functork.scala
Created May 11, 2018 16:16
shapeless-style derivation of a FunctorK (aka HFunctor) instance for an arbitrary product F-algebra
import scala.language.{ higherKinds, implicitConversions }
object Defns {
type Id[T] = T
type ApplyTo[T] = { type λ[F[_]] = F[T] }
type Const1[T] = { type λ[F[_]] = T }
// Natural transform
trait ~>[F[_], G[_]] {
def apply[T](ft: F[T]): G[T]
@milessabin
milessabin / no-effect.scala
Created March 20, 2018 10:38
Side-effects are bad, right?
// What output does this yield? What should it? (try with either 2.12.x or 2.13.x)
// (spoiler: https://github.com/scala/bug/issues/10788)
object Test {
class Box[T](t: T) {
def foo: T = {
println("effect")
t
}
}
import scala.language.higherKinds
class Cartesian[F[_]] {
trait Arbitrary1
trait Arbitrary2
implicit val fa1: F[Arbitrary1] = null.asInstanceOf
implicit val fa2: F[Arbitrary2] = null.asInstanceOf
class QED
implicit def proof(implicit fa12: F[(Arbitrary1, Arbitrary2)]): QED = null
}
@milessabin
milessabin / byname-inductive-implicits.scala
Created September 5, 2017 15:11
Compiles, no macros, induction heuristics applied ... on my scala/scala branch. Coming to a scalac near you soon with any luck ...
@annotation.inductive
trait Show[T] {
def show(t: T): String
}
object Show {
implicit def showUnit: Show[Unit] = new Show[Unit] {
def show(u: Unit): String = "()"
}
@milessabin
milessabin / artifactory.config.latest.xml
Created December 3, 2016 17:12
My local artifactory configuration for community-builds
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://artifactory.jfrog.org/xsd/1.8.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jfrog.org/xsd/artifactory-v1_8_1.xsd">
<offlineMode>false</offlineMode>
<helpLinksEnabled>true</helpLinksEnabled>
<fileUploadMaxSizeMb>100</fileUploadMaxSizeMb>
<dateFormat>dd-MM-yy HH:mm:ss z</dateFormat>
<addons>
<showAddonsInfo>true</showAddonsInfo>
<showAddonsInfoCookie>1480700455180</showAddonsInfoCookie>
</addons>