Skip to content

Instantly share code, notes, and snippets.


Kai neko-kai

View GitHub Profile
neko-kai / final-case-class.scala
Created Aug 11, 2020
Why you should always declare case classes final
View final-case-class.scala
case class X()
sealed trait Unrelated { def x: Int }
object App extends App {
def getX(xs: List[X]): List[Int] = {
xs.collect {
case u: Unrelated => u.x
neko-kai / DottyImmutableTestSyntax.scala
Last active May 9, 2020
Dotty immutable test syntax
View DottyImmutableTestSyntax.scala
object MyTest extends Test {
val suite =
> "should do x" {
assert(2 + 2 == 4)
> "should do y" {
assert(2 + 2 == 8)
neko-kai / Vessel.scala
Last active May 6, 2020
obsidiansystems/vessel in Scala 2
View Vessel.scala
package example
import example.Has.Has0
import example.Eq.{GEQ, Y}
import example.Vessel.{FlipAp, FlipAp0, VSum}
import scala.language.implicitConversions
final case class LS[F[_]](l: List[F[String]])
final case class LI[F[_]](l: List[F[Int]])
View TRIO.scala
trait TRIO[F[-_, +_, +_]] {
def pure[A](a: A): F[Any, Nothing, A]
def fail[E](e: E): F[Any, E, Nothing]
def flatMap[R1, E1, A, R2 <: R1, E2 >: E1, B](fa: F[R1, E1, A])(fab: A => F[R2, E2, B]): F[R2, E2, B]
def catchAll[R1, E1, A, R2 <: R1, E2, A2 >: A](fa: F[R1, E1, A])(h: E1 => F[R2, E2, A2]): F[R2, E2, A2]
def bracket[R, E, A, B](acquire: F[R, E, A], release: A => F[R, Nothing, Unit], use: A => F[R, E, B]): F[R, E, B]
object TRIO {
neko-kai /
Last active May 31, 2019
ZIO RC5 Release Notes

ZIO Core

  • Added FiberRef, a version of FiberLocal that's inherited by child fibers on forks and joins (#665) (#618)

    • Added inheritFiberRefs
  • ZStream now tracks finalization scopes as part of the stream computations. This means that resources are acquired and released more precisely as part of the stream, including across concurrency combinators such as buffer, zipWith and merge. (#906)

    • ZStream uses ZManaged as the return type for stream folds
    • Several concurrency combinators were added: ZStream#flatMapPar, ZStream.flattenPar and ZStream.mergeAll.
  • Added ZIO Tracing for the JVM - Cause now includes a ZTrace with the fiber's monadic stack trace, execution trace and traces of parent fibers at time of failure. (#849)

neko-kai / PerfTest.scala
Created Jan 7, 2019
logstage perf tests
View PerfTest.scala
package com.github.pshirshov.izumi
import com.github.pshirshov.izumi.logstage.api.logger.LogRouter
import com.github.pshirshov.izumi.logstage.api.{IzLogger, Log}
object PerfTest {
final val acceptingNullRouter = new LogRouter {
override def acceptable(id: Log.LoggerId, messageLevel: Log.Level): Boolean = true
override protected def doLog(entry: Log.Entry): Unit = {}
neko-kai / quantified.scala
Last active Apr 2, 2019
Tagless final for ZIO via quantified constraints
View quantified.scala
package quantified
import cats.Monad
import scala.language.implicitConversions
* C[_] constraint applied to type F[_, _] quantified in first parameter, i.e.
* {{{
neko-kai / StagedInjection.scala
Created Aug 4, 2018
Naive effectful instantiation in distage
View StagedInjection.scala
import distage._
import distage.config._
import com.typesafe.config._
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration
case class DbConf()
case class MsgQueueConf()
View Day.kt
import arrow.*
import arrow.core.*
import arrow.syntax.function.*
import arrow.instances.*
import arrow.typeclasses.*
neko-kai / MonadRandom.scala
Created Jun 13, 2018
difference between mtl-style and tagless final style
View MonadRandom.scala
import cats._
import cats.implicits._
trait MonadRandom[F[_]] {
def getRandom: F[Int]
final case class DummyRandom[A](a: A)
final case class RealRandom[A](a: A)