This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using jmh | |
//> using toolkit 0.7.0 | |
//> using scala 3.7.0 | |
//> using dep org.scala-lang::scala3-compiler:3.7.0 | |
package bench | |
import dotty.tools.dotc.Driver | |
import org.openjdk.jmh.annotations.State | |
import org.openjdk.jmh.annotations.Scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NamedTuple.{Names, AnyNamedTuple, NamedTuple} | |
type ContainsAll[X <: Tuple, Y <: Tuple] <: Boolean = X match | |
case x *: xs => Tuple.Contains[Y, x] match | |
case true => ContainsAll[xs, Y] | |
case false => false | |
case EmptyTuple => true | |
type FilterName0[N, Ns1 <: Tuple, Vs1 <: Tuple] <: Option[Any] = | |
(Ns1, Vs1) match | |
case (N *: ns, v *: vs) => Some[v] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example of a "type level function" resolved via implicit search using inline match - to get around named tuple types not working with match types | |
sealed trait Foo | |
type TypeFun[Cases <: Tuple] = [T] =>> TypeFun.Resolved[T, Cases] | |
type ->>[Case, R] = (Case, R) | |
object TypeFun: | |
sealed trait Wild[F[_]] | |
final class Resolved[T, Cases <: Tuple]: | |
type Out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright 2017 Marco Vermeulen | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using toolkit default | |
//> using options -experimental | |
//> using scala 3.6.1 | |
// This script copies from scala3/sbt-test/unroll-annot to dotty/tests/run | |
// current directory is repo for github.com/scala/scala3 | |
val srcDir = os.pwd / "sbt-test" / "unroll-annot" | |
val destDir = os.pwd / "tests" / "run" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using repository "https://repo.e-iceblue.com/nexus/content/groups/public/" | |
//> using dep "e-iceblue:spire.pdf:9.10.3" | |
//> using dep "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0" | |
//> using scala 3.4.0 | |
//> using toolkit default | |
import com.spire.pdf.PdfDocument | |
import scala.util.Using, Using.Releasable | |
import scala.util.chaining.given |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val hello = "Hello, world!" | |
val multiline = s""" | |
))) | |
)))))))))))))) | |
)))))))))))))))))))))))))))))) | |
)))))))))))))))))))))))))))))) | |
)))))))))))))))))))))))))))))) | |
))))))))))))))))))))))@@@@@@ | |
)))))))@@@@@@@@@@@@@@@@@@@@))) | |
@@@@@@@@@@@@))))))))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala "3.4.0-RC1-namedtuples-bin-SNAPSHOT" | |
// original solution taken from https://scalacenter.github.io/scala-advent-of-code/puzzles/day17#final-code (by @bishabosha) | |
import scala.language.experimental.namedTuples | |
type Target = (xs: Range, ys: Range) | |
type Point = (x: Int, y: Int) | |
type Probe = (position: Point, velocity: Point) | |
val initial = (x = 0, y = 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using toolkit 0.2.1 | |
//> using scala 3.3.1 | |
//> using dep ch.epfl.scala::tasty-query:0.11.0 | |
//> using dep org.scala-lang::scala3-compiler:3.3.1 | |
//> using dep io.get-coursier:coursier_2.13:2.1.7 | |
package tastyquery.jdk.classpaths | |
import tastyquery.Classpaths.Classpath | |
import tastyquery.Classpaths.ClasspathEntry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import scala.annotation.static | |
import java.lang.invoke.{MethodHandle, MethodHandles, MethodType} | |
class MH | |
object MH: | |
@static private val lookup = MethodHandles.lookup() |
NewerOlder