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
object lib: | |
import scala.annotation.implicitNotFound | |
import scala.util.boundary, boundary.* | |
opaque type Lab[T <: Singleton] >: Unit = Unit | |
object Lab: | |
inline def apply[T <: Singleton]: Lab[T] = () | |
inline def label[T <: Singleton & String]( | |
inline f: Label[Lab[T]] ?=> Unit |
cats-effect Resource
is extremely handy for managing the lifecycle of stateful resources, for example database or queue connections. It gives a main interface of:
trait Resource[F[_], A] {
/** - Acquire resource
* - Run f
* - guarantee that if acquire ran, release will run, even if `use` is cancelled or `f` fails
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.language.higherKinds | |
/* | |
Mainline Profunctor Heirarchy for Optics: https://r6research.livejournal.com/27476.html | |
Profunctor Optics: The Categorical Approach - Bartosz Milewski: https://www.youtube.com/watch?v=l1FCXUi6Vlw | |
*/ | |
object ProfunctorOpticsSimpleImpl { | |
trait Functor[F[_]] { | |
def map[A, B](x: F[A])(f: A => B): F[B] |
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.languageFeature.higherKinds | |
import cats.{Applicative, Id, ~>} | |
object Shapes { | |
case class Child[F[_]](nickname: F[String], age: F[Int]) | |
case class Adult[F[_]](job: F[String], innerChild: Child[F]) | |
class ApplicativeTrans[F[_]](implicit applicativeF: Applicative[F]) extends ~>[Id, F] { | |
override def apply[A](value: A): F[A] = applicativeF.pure(value) |
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
// ==UserScript== | |
// @name Mike's timesheet improvements | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Add plus time buttons to the new GetMyTime | |
// @author Michael Maurizi | |
// @match https://app.getmytime.com/timesheet.aspx | |
// @grant none | |
// ==/UserScript== |
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
/* | |
Monads laws examples with List monads | |
Summary from article: https://devth.com/2015/monad-laws-in-scala | |
*/ | |
val f: (Int => List[Int]) = x => List(x - 1, x, x + 1) |
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
class Nil | |
class Cons[X, Xs] | |
class First[List] { type X } | |
object First { | |
type Aux[List, X0] = First[List] { type X = X0 } | |
implicit val nilFirst: Aux[Nil, Nil] = ??? | |
implicit def consFirst[X0, Xs]: Aux[Cons[X0, Xs], X0] = ??? | |
} |
NewerOlder