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 class Scope[F[+_]] { | |
def ^[T](value: F[T]): Value[F, T, this.type] = new Value(value) | |
} | |
final class Ref[+T, Tag] { | |
def !(using ctx: Ctx[Tag]): T = ctx(this) | |
} | |
final class Value[F[+_], +T, Tag](val value: F[T]) extends AnyVal { | |
def flatMap[U](fn: Ref[T, Tag] => Expr[F, U, Tag]): Expr[F, U, Tag] = { | |
val ref = new Ref[T, Tag] | |
fn(ref).and(ref, value) |
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
trait UEnum[T] { | |
def values: Map[String, T] | |
def name(t: T): String | |
def value(name: String): Option[T] | |
} | |
object UEnum { obj => | |
final case class DefaultUEnum[T](seq: T*) extends UEnum[T] { |
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 Plane = (Double, Double) | |
type Matrix = (Plane, Plane) | |
type TaggedEvents = Map[String, Plane] | |
private val sin45 = Math.sqrt(0.5) | |
private val matrixMinus45 = ((sin45, sin45), (-sin45, sin45)) | |
private val matrixPlus45 = ((sin45, -sin45), (sin45, sin45)) |
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 utility.functional | |
import scala.language.{higherKinds, reflectiveCalls} | |
import cats.Applicative | |
import shapeless._ | |
/** | |
* Given a HList I0::I1:: ... In::HNil and a type Out | |
* returns a curried function (I0 => I1 => ... In => Out) => Out |