This file contains 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 vulcan.{AvroError, Codec} | |
import vulcan.generic.* | |
import zio.{ZIO, ZIOAppDefault} | |
sealed trait Foo | |
object Foo { | |
case class A(a: Int, `type`: "A" = "A") extends Foo | |
case class B(b: String, `type`: "B" = "B") extends Foo |
This file contains 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 cats.effect.{IO, IOApp, Resource} | |
import doobie.postgres.PHC | |
import doobie.{ConnectionIO, HC, LogHandler, Transactor} | |
import fs2.Pipe | |
import org.postgresql.PGNotification | |
import scala.concurrent.duration.* | |
import cats.syntax.all.* | |
import doobie.implicits.* | |
import fs2.Stream |
This file contains 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
inline def f2[A, B](x: A | B): String = | |
x match | |
case a: A => "a" | |
case b: B => "b" | |
// doesn't work with subtyping | |
trait T[A] { | |
def foo(a: A): String | |
} |
This file contains 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 _root_.vulcan.Codec | |
import _root_.vulcan.generic.* | |
import foo.Events.{E1, E2} | |
import fs2.kafka.* | |
import fs2.kafka.vulcan.{AvroSettings, SchemaRegistryClientSettings, avroSerializer} | |
import zio.interop.catz.* | |
import zio.interop.catz.implicits.rts | |
import zio.{Scope, Task, ZIO, ZIOAppDefault} | |
| |
object foo extends ZIOAppDefault { |
This file contains 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 $ivy.`dev.zio::zio-prelude:1.0.0-RC15` | |
import zio.prelude.Newtype | |
object newtypes { | |
def derive[A, STA <: Newtype[A], F[_]](implicit ev: STA <:< Newtype[A], typeClass: F[A]): F[STA#Type] = | |
typeClass.asInstanceOf[F[STA#Type]] | |
trait Auto { | |
implicit def auto[A, STA <: Newtype[A], F[_]](implicit ev: STA <:< Newtype[A], typeClass: F[A]): F[STA#Type] = |
This file contains 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
trait F[+A]{ | |
def ++[B >: A](that: F[B]): F[B] | |
def flatMap[B >: A](f: A => F[B]): F[B] | |
def map[B](f: A => B): F[B] | |
} | |
trait A | |
trait B | |
trait C |
This file contains 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 scala.annotation.tailrec | |
type FlatEither[A] = A match | |
case Either[l, r] => FlatEither[l] | FlatEither[r] | |
case _ => A | |
@tailrec | |
def flatEither[A](a: A): FlatEither[A] = a match | |
case e: Either[?, ?] => e match | |
case Right(r) => flatEither(r) |
This file contains 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 sttp.client3.asynchttpclient.zio.{AsyncHttpClientZioBackend, SttpClient} | |
import sttp.tapir.server.ziohttp.ZioHttpInterpreter | |
import zhttp.http.RHttpApp | |
import zhttp.service.{EventLoopGroup, Server} | |
import zhttp.service.server.ServerChannelFactory | |
import zio.{Runtime, ZIO} | |
object tapir { | |
import sttp.tapir.ztapir._ |
This file contains 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 com.byond.infinity.sda | |
import cats.data.{ Kleisli, OptionT } | |
import cats.effect.{ Resource, Sync } | |
import org.http4s.{ HttpRoutes, Response } | |
import cats.syntax.flatMap._ | |
import org.http4s.client.Client | |
object logging { | |
val log = org.log4s.getLogger |
This file contains 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 advent | |
import cats.syntax.all._ | |
object Sixteen extends Inputs: | |
type Rule = Int => Boolean | |
type Ticket = List[Int] | |
type TicketPosition = List[Int -> Int] | |
def parseRule: String => String \/ Rule = { s => |
NewerOlder