Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Zaugg retronym

  • Lightbend
  • Brisbane, Australia
View GitHub Profile
View gist:1fe3802bab258e1814b8732845602146
[error] Options accepted by async:
[error] allkernel=<bool> Only include kernel-mode events.
[error] alluser=<bool> Only include user-mode events.
[error] ann=<bool> Annotate Java method names.
[error] cstack=<mode> How to traverse C stack: Supported: [fp, lbr, no].
[error] dir=<dir> Output directory.
[error] direction=<direction> Direction(s) of flame graph. Supported: [forward,
[error] reverse, both]. (default: [both])
[error] event=<event> Event to sample: cpu, alloc, wall, lock, cache-misses,
[error] etc. (default: [cpu])
@retronym
retronym / type-bounds.scala
Created Dec 16, 2009
Tour of Scala Type Bounds
View type-bounds.scala
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@retronym
retronym / forall.scala
Created Nov 26, 2011
universal quantification
View forall.scala
scala> trait Forall[F[_]]{ def apply[A]: F[A] }
defined trait Forall
scala> type ListFun[A] = List[A] => List[A]
defined type alias ListFun
scala> object Reverse extends Forall[ListFun] { def apply[A] = _.reverse}
defined module Reverse
scala> Reverse[String](List("1", "2"))
View gist:8c49524b31f4a25d8cee38323c15fd91
➜ compiler-benchmark git:(topic/case-class-o-rama) time (for v in 2.12.11 2.12.12-bin-8d19363-SNAPSHOT; do echo $v; sbt clean 'set scalaVersion in compilation := "'$v'"' 'hot -psource=scalap -prof gc -wi 3 -i 3 -f 2' ; done)
2.12.11
[info] Loading settings for project global-plugins from idea.sbt,dirtymoney.sbt,metals.sbt,gpg.sbt ...
[info] Loading global plugins from /Users/jz/.sbt/1.0/plugins
[info] Loading settings for project compiler-benchmark-build from plugins.sbt,build.sbt ...
[info] Loading project definition from /Users/jz/code/compiler-benchmark/project
[info] Loading settings for project compiler-benchmark from build.sbt ...
[info] Set current project to compiler-benchmark (in build file:/Users/jz/code/compiler-benchmark/)
[success] Total time: 0 s, completed 19/05/2020 10:21:18 AM
[info] Defining compilation / scalaVersion
View 2.12.x-to-2.13.x-mergeplan.txt
SKIP * 4dd0abeab2 (origin/2.12.x, topic/unrelated-equals-reflexive, 2.12.x) Merge pull request #8980 from mkeskells/2.12.x_Map_++_regression
|\
| * ed36c8bbcc (origin/pr/8980) fix regression in Map ++
| | .../scala/collection/immutable/HashMap.scala | 2 +-
| | .../scala/collection/immutable/HashMapTest.scala | 26 ++++++++++++++++++++
| | 2 files changed, 27 insertions(+), 1 deletion(-)
PICK * | 1c92061d51 Merge pull request #8971 from joroKr21/implicit-by-namme
|\ \
| * | eaf1b749fc (origin/pr/8971) [nomerge] Convert implicit by-name error to a type error
| | | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 4 ----
View non-static-lambda.txt
scala> :java -c -private NonStaticLambda
Compiled from "<console>"
public class $line3.$read$$iw$$iw$NonStaticLambda {
public scala.Function0<$line3.$read$$iw$$iw$NonStaticLambda> test();
Code:
0: aload_0
1: invokedynamic #45, 0 // InvokeDynamic #0:apply:(L$line3/$read$$iw$$iw$NonStaticLambda;)Lscala/Function0;
6: areturn
public static final $line3.$read$$iw$$iw$NonStaticLambda $anonfun$test$1($line3.$read$$iw$$iw$NonStaticLambda);
View gist:eb09eda939360a5d1955d206df1902ea
scala> :java -c -private NonStaticLambda
Compiled from "<console>"
public class $line3.$read$$iw$$iw$NonStaticLambda {
public scala.Function0<$line3.$read$$iw$$iw$NonStaticLambda> test();
Code:
0: aload_0
1: invokedynamic #45, 0 // InvokeDynamic #0:apply:(L$line3/$read$$iw$$iw$NonStaticLambda;)Lscala/Function0;
6: areturn
public static final $line3.$read$$iw$$iw$NonStaticLambda $anonfun$test$1($line3.$read$$iw$$iw$NonStaticLambda);
View gist:f6629cf39d37df97668b61d5683184b2
scala> val f = new java.io.File("/tmp/test.zip"); val zos = new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(f)); zos.putNextEntry(new java.util.zip.ZipEntry("\u012f" + "/")); zos.closeEntry(); zos.close()
f: java.io.File = /tmp/test.zip
zos: java.util.zip.ZipOutputStream = java.util.zip.ZipOutputStream@6c4e11d0
scala> val zf = new java.util.zip.ZipFile(f); try zf.getEntry("\u012f") finally zf.close()
zf: java.util.zip.ZipFile = java.util.zip.ZipFile@14b0b7f9
res16: java.util.zip.ZipEntry = į/
scala> val zf = new java.util.zip.ZipFile(f); try zf.getEntry("\u012f" + "/") finally zf.close()
zf: java.util.zip.ZipFile = java.util.zip.ZipFile@4700064f
View gist:fb22c2cb56dc6fa5ed29e956dc3800e1
git -P log -1 && git clean -fdx && java -version && sbt 'packagePlugin' 'runDebuggerTests'
commit 468fc60a3f67f2db22c94c4ad1fcb4b94f6617a5 (HEAD -> topic/clean-slate, retronym/idea201.x, origin/idea201.x, idea201.x)
Author: Justin Kaeser <justin.kaeser@jetbrains.com>
Date: Tue Apr 7 23:01:48 2020 +0200
Revert "Not use blocking call in the attachSbtProjectAndRefresh #SCL-17353"
this fix caused the project view not to show the full project tree until the full import completed
when BSP import dialog is disabled, the hanging that this change addresses does not happen, so we can revert it
@retronym
retronym / indylambda.md
Last active Mar 24, 2020
indylambda: Putting invokedynamic to work for Scala
View indylambda.md

indylambda: Putting invokedynamic to work for Scala

Java 8 introduced lambdas to the Java language. While the design choices differ in many regards from Scala's functions, the underlying mechanics used to represent Java lambdas is flexible enough to be used as a target for the Scala compiler.

Lambdas in Java

Java does not have canonical heirarchy of generic function types (ala scala.FunctionN), but instead allows a lambda to be used as a shorthand for an anonymous implementation of an Functional Interface

Here's an example of creating a predicate that closes over one value:

You can’t perform that action at this time.