Skip to content

Instantly share code, notes, and snippets.

View smarter's full-sized avatar

Guillaume Martres smarter

View GitHub Profile
object foo {
abstract sealed class num
final case class One() extends num
final case class Bit0(a: num) extends num
final case class Bit1(a: num) extends num
abstract sealed class char
final case class zero_char() extends char
final case class Char(a: num) extends char
trait Stream[+F[_], +A]
object Stream {
// Make scalac get over its oudenophobia.
type Nothing2[X] <: Nothing
def emits[F[x] >: Nothing2[x], A](as: List[A]): Stream[F, A] = new Stream[F, A] {}
implicit class InvariantOps[F[x] >: Nothing2[x], A](private val self: Stream[F, A]) extends AnyVal {
def ethrough[B](p: Stream[F, A] => Stream[F, B]): Stream[F, B] = p(self)
% jstack 368186
2018-07-05 02:28:18
Full thread dump OpenJDK 64-Bit Server VM (25.171-b11 mixed mode):
"Attach Listener" #25 daemon prio=9 os_prio=0 tid=0x00007fda08001000 nid=0x59ff3 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"ForkJoinPool-1-worker-0" #24 daemon prio=5 os_prio=0 tid=0x00007fd9f4e61800 nid=0x59ec3 in Object.wait() [0x00007fda513ac000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
@smarter
smarter / fmap.scala
Last active November 18, 2019 08:55
Should work with 0.20.0-RC1
// Compiles with https://github.com/lampepfl/dotty/pull/4672
// ./bin/dotc -classpath "$(coursier fetch -p org.typelevel:cats-core_2.13:2.0.0)" out/fmap.scala
import cats._
import cats.implicits._
object Test {
val fmap: [A, B] -> (A => B) => [F[_]] -> F[A] => (given Functor[F]) => F[B] = [A, B] -> (f: A => B) => ([F[_]] -> (fa: F[A]) => (given ev: Functor[F]) => fa.map(f))
val addOne = fmap((x: Int) => x + 1)
// Compiles with https://github.com/lampepfl/dotty/pull/4672
// ./bin/dotc -classpath "$(coursier fetch -p org.typelevel:cats-effect_2.12:1.0.0-RC2)" out/blocking.scala
import scala.language.implicitConversions
import cats.implicits._
import cats.effect._
import scala.concurrent.ExecutionContext
object Blocking {
# allocated trees: 3316387
Detail of allocated trees:
(dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:293),350797)
(dotty.tools.dotc.parsing.Parsers$Parser.makeIdent(Parsers.scala:527),165153)
(dotty.tools.dotc.transform.Erasure$Typer.typedValDef(Erasure.scala:540),120536)
(dotty.tools.dotc.typer.Typer.$anonfun$typedValDef$1(Typer.scala:1361),81026)
(dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:507),79324)
(dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:575),70002)
(dotty.tools.dotc.typer.Typer.$anonfun$typedIdent$1(Typer.scala:409),68091)
(dotty.tools.dotc.transform.PatternMatcher$Translator.emit(PatternMatcher.scala:911),68043)
# allocated trees: 3169938
Detail of allocated trees: (dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:293),350797)
(dotty.tools.dotc.parsing.Parsers$Parser.makeIdent(Parsers.scala:527),165152)
(dotty.tools.dotc.transform.Erasure$Typer.typedValDef(Erasure.scala:540),120536)
(dotty.tools.dotc.typer.Typer.$anonfun$typedValDef$1(Typer.scala:1361),81026)
(dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:575),70002)
(dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:507),68626)
(dotty.tools.dotc.typer.Typer.$anonfun$typedIdent$1(Typer.scala:409),68091)
(dotty.tools.dotc.transform.PatternMatcher$Translator.emit(PatternMatcher.scala:911),68043)
(dotty.tools.dotc.typer.Applications$TypedApply.app0$1(Applications.scala:599),60317)
ZSH_HIGHLIGHT_STYLES[alias]='none'
ZSH_HIGHLIGHT_STYLES[unknown-token]='none'
ZSH_HIGHLIGHT_STYLES[builtin]='none'
ZSH_HIGHLIGHT_STYLES[function]='none'
ZSH_HIGHLIGHT_STYLES[command]='none'
ZSH_HIGHLIGHT_STYLES[precommand]='none'
ZSH_HIGHLIGHT_STYLES[path]='none'
ZSH_HIGHLIGHT_STYLES[path_prefix]='none'
ZSH_HIGHLIGHT_STYLES[path_approx]='none'
[log frontend] ==> search implicit scala.collection.generic.CanBuildFrom[scala.collection.SortedMap[dotty.tools.dottydoc.model.comment.Inline, dotty.tools.dottydoc.model.comment.Block], String, That], arg = <empty>: <notype>?
[log frontend] ==> computeEligible scala.collection.generic.CanBuildFrom[scala.collection.SortedMap[dotty.tools.dottydoc.model.comment.Inline, dotty.tools.dottydoc.model.comment.Block], String, (?)] in ((text: String): dotty.tools.dottydoc.model.comment.HtmlParsers.StringToMarkdown)(dotty.tools.dottydoc.model.comment.HtmlParsers.StringToMarkdown), ((markdown: com.vladsch.flexmark.ast.Node): dotty.tools.dottydoc.model.comment.HtmlParsers.MarkdownToHtml)(dotty.tools.dottydoc.model.comment.HtmlParsers.MarkdownToHtml), ((text: String): dotty.tools.dottydoc.model.comment.HtmlParsers.StringToWiki)(dotty.tools.dottydoc.model.comment.HtmlParsers.StringToWiki), ((body: dotty.tools.dottydoc.model.comment.Body): dotty.tools.dottydoc.model.comment.HtmlParsers.BodyToHtml)(dotty.tools.dottydoc.mode
[log frontend] ==> search implicit scala.collection.generic.CanBuildFrom[scala.collection.SortedMap[dotty.tools.dottydoc.model.comment.Inline, dotty.tools.dottydoc.model.comment.Block], String, That], arg = <empty>: <notype>?
[log frontend] ==> computeEligible scala.collection.generic.CanBuildFrom[scala.collection.SortedMap[dotty.tools.dottydoc.model.comment.Inline, dotty.tools.dottydoc.model.comment.Block], String, (?)] in ((text: String): dotty.tools.dottydoc.model.comment.HtmlParsers.StringToMarkdown)(dotty.tools.dottydoc.model.comment.HtmlParsers.StringToMarkdown), ((markdown: com.vladsch.flexmark.ast.Node): dotty.tools.dottydoc.model.comment.HtmlParsers.MarkdownToHtml)(dotty.tools.dottydoc.model.comment.HtmlParsers.MarkdownToHtml), ((text: String): dotty.tools.dottydoc.model.comment.HtmlParsers.StringToWiki)(dotty.tools.dottydoc.model.comment.HtmlParsers.StringToWiki), ((body: dotty.tools.dottydoc.model.comment.Body): dotty.tools.dottydoc.model.comment.HtmlParsers.BodyToHtml)(dotty.tools.dottydoc.mode