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 cats.effect.syntax.all.* | |
import cats.syntax.all.* | |
import cats.effect.* | |
import fs2.Stream | |
import cats.effect.std.Queue | |
import scala.concurrent.duration.* | |
case class FSM[F[_], S, I, O](run: (S, I) => F[(S, O)]) | |
case class Ping[F[_]](replyTo: Deferred[F, String]) |
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 * as S from '@typed/fp/Stream'; | |
import * as E from 'fp-ts/Either'; | |
import { pipe } from 'fp-ts/function'; | |
import * as TE from 'fp-ts/TaskEither'; | |
export function streamFromTaskEither<A>(taskEither: TE.TaskEither<Error, A>): S.Stream<A> { | |
return pipe( | |
taskEither, | |
S.fromTask, | |
S.chain(E.match(S.throwError, S.of)), |
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
final case class ArrayLog[A]( | |
private val arr: Array[A], | |
private val curWriteIdx: Int, | |
maxLength: Int | |
)(using ct: ClassTag[A]) { x => | |
private inline def offset: Int = | |
if curWriteIdx < maxLength then 0 else curWriteIdx - maxLength | |
inline def size: Int = |
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 infrastructure.repository.codec | |
import skunk.Codec | |
import PgRangeSupportUtils.* | |
enum EdgeType: | |
case `[_,_)` | |
case `(_,_]` | |
case `(_,_)` | |
case `[_,_]` |
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 cats.Id | |
import cats.effect.{ IO, Resource } | |
import cats.effect.unsafe.IORuntime | |
import cats.implicits.* | |
import com.codedx.util.MapK | |
import fs2.Stream | |
import fs2.concurrent.Topic | |
import scala.collection.mutable.ListBuffer | |
import scala.concurrent.duration.* |
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 cats.implicits.* | |
import cats.Id | |
import scala.collection.mutable.ListBuffer | |
import fs2.Stream | |
// The message broking interface | |
trait MessageBroker[F[_], Router[_]]: | |
def push[MsgKey: ValueOf](value: Router[MsgKey]): F[Unit] | |
def subscribe[MsgKey: ValueOf]: Stream[F, Router[MsgKey]] |
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 akka.http.scaladsl.marshalling.{GenericMarshallers, ToResponseMarshaller} | |
import cats.Id | |
import cats.effect.IO | |
import cats.effect.std.Dispatcher | |
import cats.syntax.apply.* | |
import scala.concurrent.Future | |
object FMarshaller: | |
given [A](using m: ToResponseMarshaller[A]): ToResponseMarshaller[Future[A]] = | |
GenericMarshallers.futureMarshaller |
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
case class TradeEvent() | |
case class OrderEvent() | |
type Channel = "trades" | "orders" | |
// def sub2[Channels <: Tuple](channels: Channels)(using Channel <:< Tuple.Union[Channels]) = channels.toList | |
type SelChannel[C <: Tuple] = C match { | |
case "trades" *: xs => TradeEvent | SelChannel[xs] | |
case "orders" *: xs => OrderEvent | SelChannel[xs] |
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
open System;; | |
let random = new Random(); | |
let _rollTheDice (): (int|string) = | |
let number = random.Next(1, 6) | |
if (number >= 2) then number else "Winner" | |
let cls () = System.Console.Clear();; | |
type A = (int|string|int64) |
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
type CompareResult<'a, 'b> = | |
| FoundPair of 'a * 'b | |
| UnmatchedLHS of 'a | |
| UnmatchedRHS of 'b | |
[<RequireQualifiedAccess>] | |
module ListCompare = | |
let compare xsKeySelector ysKeySelector xs ys = | |
let xs = | |
xs |