Skip to content

Instantly share code, notes, and snippets.

View pshirshov's full-sized avatar
😹

Paul S. pshirshov

😹
View GitHub Profile
@pshirshov
pshirshov / lambda-context.scala
Last active April 14, 2019 22:47
Lamda context extraction / PoC for zio
/*
libraryDependencies += "org.ow2.asm" % "asm" % "7.1"
Java 8+ only
file:line extraction will work for lambdas only. For anonymous classes it will point to the class definition
*/
import java.lang.invoke.SerializedLambda
import org.objectweb.asm._
@pshirshov
pshirshov / flattenizer.scala
Last active March 19, 2019 21:49
dirty json flattenizer / draft
package com.github.pshirshov.izumi.idealingua.runtime.flatjson
import com.github.pshirshov.izumi.functional.IzEither._
import io.circe._
import io.circe.literal._
import scala.annotation.switch
import scala.collection.mutable.ArrayBuffer
import scala.util.control.NonFatal
https://dl.bintray.com/sbt/sbt-plugin-releases/
http://repo.typesafe.com/typesafe/ivy-releases/
http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
http://repo.typesafe.com/typesafe/releases/
@pshirshov
pshirshov / Problem.scala
Last active November 3, 2018 13:35
Polymorphic abstract modules in Scala: projections and path-dependant types equality can't be proven
import scala.languageFeature.higherKinds
import scala.languageFeature.implicitConversions
trait IORunner[IO[+_]] {
def run[T](io: IO[T]): T = ???
}
trait Context {
type IO[+T]
@pshirshov
pshirshov / unicorn.md
Last active September 27, 2018 20:31

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGZCAMAAACQbpc2AAADAFBMVEWEBz6FAD6FAD6GAD+MAEGOAEOKAEGOAEOGAD+IAECOAEOOAUOOAEOOAEOOAEOOAEOOAEOOAEOCACyOAEQAAACKAEJpoJ2KADqu0eSKAD2BAD+KAD6AxCNqwoX1Ziawo9LYnGuwhL7aiwaIyYudst6DlrnhcWvCcVvlbE9PvsL2u3uYmdCZum9Rns7clUYsreOYp2nuj37kiZLUfqhvxafqfmrNWEjA22uz1Vu6lsiRAArWhLfgdoONnF36rWrzpz/ajy/LbqR8pdWDVXx8faN6m0+6hE3+1pmHP2mTy1b4k1p/ueFlj7vMfzyBs1v/2GfLpFL5rQD+7teQABj4n0/rpCz6r1Z8apP+4rrfw1iV0JyLUkqQACTDnah5AACtaEt9zcGNhleJbU5lsOFRvE5FuOPS4WLSt7+8ajvXcJpcyNvhztSwUkTGgZz9uDSxRnPZwsnTkqy7jpsPt/AxyvnAeJMAxPnMiqPJYIyzf4/KqrPedaK5bIsQwfTo2t72hUepPWvn6mO8VoXrgbDRaJXle6r75FzZm7S2TnyTNUXv5eiDAA6j0WmKyWv51liRAACjP0OZNVuwa4L+uQAcw/SiNGH57mIxxPKmU3DgpL2sX3rutc3/vh9gu1D3tNEAtvOSKVAmxfagRmbnrcWZJVaTJET2qsv84eyk04PzcEb71OX0u9OUzHD1nsR+1PhtwFUBvfQ5x/RizvdQy/VZzPWaz3b8uST+wFWDABqKAC6m03uGx2X+xGKBxmL2iWDQjb777/Nt0Pf+xmlCyPT+v032hVv+yXD3lGx2wlr99/hJyvX1gFV20vf1e1DCaqr6xdz+wlzJe7T2jmWFACT3i7v+0IP9u0R8xF7Oh7r+zHn/+WLHc7CQGUP3vtePEUT0i7qHADORIUyEAC2BAACf0Hr3j73zhLX7x96RGkrMgbePFEiRDUeOA0

@pshirshov
pshirshov / bifunctorio.scala
Created September 13, 2018 10:40
Bifunctor IO wrapper for DIStage workshop
import scalaz.zio.{ExitResult, IO, RTS, Schedule}
import scala.concurrent.duration.{Duration, FiniteDuration}
import scala.language.implicitConversions
import scala.util.{Failure, Success, Try}
trait BifunctorIO[R[+ _, + _]] extends {
type Or[+E, +V] = R[E, V]
type Just[+V] = R[Nothing, V]
@pshirshov
pshirshov / sbtconfig.sh
Last active January 4, 2019 22:13
sbt plugins to enable globally
cat > ~/.sbt/1.0/plugins/build.sbt <<EOL
scalaVersion := "2.12.8"
// https://github.com/coursier/coursier
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M8")
//https://github.com/aiyanbo/sbt-dependency-updates
addSbtPlugin("org.jmotor.sbt" % "sbt-dependency-updates" % "1.1.13")
// https://github.com/sbt/sbt-dirty-money
@pshirshov
pshirshov / scalac_invoke.scala
Created July 3, 2018 21:30
scala.tools.nsc invokation example
private def isRunningUnderSbt: Boolean = {
Option(System.getProperty("java.class.path")).exists(_.contains("sbt-launch.jar"))
}
import scala.tools.nsc.{Global, Settings}
val settings = new Settings()
settings.d.value = ctarget.toString
settings.feature.value = true
settings.warnUnused.add("_")
@pshirshov
pshirshov / scala_inference_failure.scala
Last active June 15, 2018 17:15
Failing scala inference, works in dotty
// works in dotty, not in scala
trait Provider[P] {
def provide: P
}
implicit object IntProvider extends Provider[Int] {
override def provide = 1
}
implicit object StringProvider extends Provider[String] {