Skip to content

Instantly share code, notes, and snippets.

@adamgfraser
adamgfraser / hset.scala
Created August 13, 2021 20:18
Type level sets
import scala.annotation.implicitNotFound
import scala.language.implicitConversions
object hset extends App {
type ??? = Nothing
// Set(1, 2, 3) Set of ints
// Set("Adam", "Kit") Set of strings
// "Adam" :*: 1 :*: true :*: HNil
import scala.annotation.tailrec
import Graph._
case class Graph[N, A, B](repr: Map[N, Context[N, A, B]]) {
def &(c: Context[N, A, B]): Graph[N, A, B] = {
val Context(p, v, _, s) = c
if (repr contains v)
throw new IllegalArgumentException("node already exists")
@adamgfraser
adamgfraser / zio_contributor_license_agreement.md
Last active March 18, 2020 15:58
ZIO Contributor License Agreement

ZIO Contributor License Agreement

Thank you for your interest in contributing to the ZIO open source project.

This contributor agreement ("Agreement") describes the terms and conditions under which you may Submit a Contribution to Us. By Submitting a Contribution to Us, you accept the terms and conditions in the Agreement. If you do not accept the terms and conditions in the Agreement, you must not Submit any Contribution to Us.

This is a legally binding document, so please read it carefully before accepting the terms and conditions. If you accept this Agreement, the then-current version of this Agreement shall apply each time you Submit a Contribution. The Agreement may cover more than one software project managed by Us.

1. Definitions

object Reactive {
type Signaled[T] = implicit Signal[_] => T
class Signal[T](expr: Signaled[T]) {
private var myExpr: () => T = _
private var myValue: T = _
private var observers: Set[Signal[_]] = Set()
update(expr)