Skip to content

Instantly share code, notes, and snippets.

# checkoutその他は省略
- run: sbt compileなどの他のタスク色々 writeExternalDependencies
- name: upload dependencies.txt
if: github.event_name == 'push'
run: |
# いい感じにuploadとdownloadできれば、
# github actionsのartifactでもなんでも良い。
# 最近某所ではS3の方が便利というか楽なので、それ使ったりもしているので、その場合の例
aws s3 cp target/dependencies.txt s3://適当なURI/${{github.ref_name}}/dependencies.txt
- id: get_previous_dependencies
commands += {
def getProjects(s: State): Seq[String] = {
val extracted = Project.extract(s)
val currentBuildUri = extracted.currentRef.build
val buildStructure = extracted.structure
val buildUnitsMap = buildStructure.units
val currentBuildUnit = buildUnitsMap(currentBuildUri)
val projectsMap = currentBuildUnit.defined
projectsMap.values.map(_.id).toVector
}
trait Functor[F[_]]
def map [A, B](fa: F[A])(f: A => B ): F[B]
trait Applicative[F[_]]
def ap [A, B](fa: F[A])(f: F[A => B]): F[B]
trait Monad[F[_]]
def bind [A, B](fa: F[A])(f: A => F[B]): F[B]
trait Contravariant[F[_]]
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18" exclude ("com.typesafe.play", "twirl-api_2.12"))
resolvers += Resolver.sbtPluginRepo("releases")
import scala.sys.process.Process
Seq(Compile, Test).map { x =>
(x / TaskKey[File]("dependencySvg")) := {
val output = target.value / s"dependencies-${x.name}.svg"
Process(Seq(
@xuwei-k
xuwei-k / gist:eda3bcb11e919734069642486b91e4d0
Created October 21, 2022 08:42
Binary compatibility org.slf4j slf4j-api 1.7.36 2.0.3
* class org.slf4j.event.EventRecodingLogger does not have a correspondent in current version
filter with: ProblemFilters.exclude[MissingClassProblem]("org.slf4j.event.EventRecodingLogger")
* abstract method getMarker()org.slf4j.Marker in interface org.slf4j.event.LoggingEvent does not have a correspondent in current version
filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("org.slf4j.event.LoggingEvent.getMarker")
* abstract method getArguments()java.util.List in interface org.slf4j.event.LoggingEvent is present only in current version
filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.slf4j.event.LoggingEvent.getArguments")
* abstract method getMarkers()java.util.List in interface org.slf4j.event.LoggingEvent is present only in current version
filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.slf4j.event.LoggingEvent.getMarkers")
* abstract method getKeyValuePairs()java.util.List in interface org.slf4j.event.LoggingEvent is present only
$ scala --version
Scala code runner version 2.13.10 -- Copyright 2002-2022, LAMP/EPFL and Lightbend, Inc.
$ scala -Wperformance -Xprint:jvm -e "def foo: Int = { var a = 10; @annotation.tailrec def loop(): Int = if (a == 0) 3 else { a -= 1 ; loop() } ; loop() }"
/var/folders/nz/vb2z3s8j7719gg71zgz9gj_40000gn/T/scalacmd2181293633408592115.scala:1: warning: Modification of variable a within a closure causes it to be boxed.
def foo: Int = { var a = 10; @annotation.tailrec def loop(): Int = if (a == 0) 3 else { a -= 1 ; loop() } ; loop() }
^
[[syntax trees at end of jvm]] // scalacmd2181293633408592115.scala
package <empty> {
object Main extends Object {
def main(args: Array[String]): Unit = {
package either_and_future_sample
import scalaz._
import scala.concurrent.{ExecutionContext, Future}
import scalaz.std.scalaFuture._ // for scalaz 7.1.0
// import scalaz.contrib.std.scalaFuture._ // for scalaz 7.0.x
import either_and_future_sample.Main.{UserId, context}
sealed trait Error
/** 引数であたえられたUserIdのUserが、そもそも存在しなかった場合 */
$ scala -version
Scala code runner version 2.13.9 -- Copyright 2002-2022, LAMP/EPFL and Lightbend, Inc.
$ java -version
openjdk version "17.0.3" 2022-04-19 LTS
OpenJDK Runtime Environment Zulu17.34+19-CA (build 17.0.3+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.34+19-CA (build 17.0.3+7-LTS, mixed mode, sharing)
$ scala -release:help
Usage: -release:<release> where <release> choices are 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 (default: 17).
$ jenv shell 11
@xuwei-k
xuwei-k / InliningProfile.scala
Last active August 29, 2022 14:25
Scala 3 inlining phase profile compiler plugin
package example
import dotty.tools.dotc.CompilationUnit
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.plugins.ResearchPlugin
import dotty.tools.dotc.transform.Inlining
class InliningProfile extends ResearchPlugin {
override val name: String = "my-inlining"
package fix
import scalafix.Diagnostic
import scalafix.Patch
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import scala.meta.Term
import scalafix.lint.LintSeverity
class WrongStringInterpolation extends SyntacticRule("WrongStringInterpolation") {