def hash(a: A): Intmakes me sad. What about hashing to 64 bits or SL2 Fp?def MapHash[A, B: Hash]: Hash[Map[A, B]]is a bit odd. Why notA: Hash?reflexiveLaw + symmetryLaw + transitivityLawis too weak for "equality". This defines a general equivalence relationship only.val AnyEqual: Equal[Any]is worrisome, considering all the resolution bugs!val DoubleEqual: Equal[Double]should be implemented usingjava.lang.Double.doubleToRawLongBits.- A combintation of [
trait Ord[-A] extends Equal[A]](https://github.com/zio/zi
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
| sealed trait Free[+F[_], A] | |
| object Free { | |
| def eval[F[_], A](fa: Free[F, A])(implicit F: Monad[F]): F[A] = { | |
| type State = (Free[F, Any], List[Any => Free[F, Any]]) | |
| def go(s: State): F[Either[State, Any]] = s match { | |
| case (current, stack) => | |
| current match { | |
| case Done(a) => | |
| stack match { | |
| case Nil => |
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
| /////////////////////////////////////////////////////////////////// | |
| // STEP 1 - Evaluation by need monad | |
| /////////////////////////////////////////////////////////////////// | |
| import scala.annotation.unchecked.{ uncheckedVariance => uV } | |
| final class Need[+A](private[this] var thunk: Need.Thunk[A @uV]) { A => | |
| import Need._ | |
| def value: A = thunk match { | |
| case Done(x) => x |
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
| // This sums up my understanding of | |
| // https://github.com/lampepfl/dotty/issues/9359 | |
| // and https://github.com/lampepfl/dotty/issues/8430 | |
| // == on AnyVal does not imply singleton type equality | |
| class Test[A](val x: Int) extends AnyVal | |
| def coerce1[A, B](a: A): B = { | |
| val x = new Test[A](1) | |
| val y = new Test[B](1) |
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 CharReader { | |
| def current(): Int | |
| def advance(): Unit | |
| } | |
| object CharReader { | |
| final val EOF: Int = -1 | |
| final val EOB: Int = -2 | |
| @silent final class FromString(val text: String, end: Int) extends CharReader { | |
| var index = 0 |
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
| from itertools import * | |
| # Compute our D(pi) function | |
| elements = {} | |
| for p in permutations([1,2,3,4]): | |
| d = [i+1 for i in range(3) if p[i] > p[i + 1]] | |
| elements[p] = frozenset(d) | |
| # Make a graph with the given pi < tau relation. | |
| graph = {} |
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.Eval | |
| import cats.syntax.all._ | |
| trait Eq[A] { | |
| def eqv(x: A, y: A): Eval[Boolean] | |
| } | |
| trait Eq1[F[_]] { | |
| def eqv1[A](x: F[A], y: F[A])(implicit A: Eq[A]): Eval[Boolean] | |
| } |
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.Eq | |
| trait Eq1[F[_]] { | |
| def eqv1[A](x: F[A], y: F[A])(implicit A: Eq[A]): Boolean | |
| } | |
| final case class Fix[F[_]](unfix: F[Fix[F]]) | |
| object Fix { | |
| implicit def eqv[F[_]: Eq1]: Eq[Fix[F]] = new Eq[Fix[F]] { | |
| def eqv(x: Fix[F], y: Fix[F]): Boolean = |
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
| #if __ENDIAN_LITTLE__ | |
| # define NATIVE_LITTLE_ENDIAN 1 | |
| #endif | |
| #if __LITTLE_ENDIAN__ | |
| # define NATIVE_LITTLE_ENDIAN 1 | |
| #endif | |
| #define BLAKE2S_BLOCKBYTES 64 |
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
| from collections import namedtuple | |
| Add = namedtuple('Add', 'args') | |
| Xor = namedtuple('Xor', 'left right') | |
| Rot = namedtuple('Rot', 'left right') | |
| Input = namedtuple('Input', 'name') | |
| Const = namedtuple('Const', 'value') | |
| Set = namedtuple('Set', 'var expr') | |
| IV0p = 0x6b08e647 |